@@ -39,7 +39,7 @@ import org.geotools.referencing.CRS
39
39
import org .geotools .referencing .crs .DefaultGeographicCRS
40
40
import org .joda .time .DateTime
41
41
import org .junit .runner .RunWith
42
- import org .locationtech .geomesa .core .index .{ IndexSchemaBuilder , _ }
42
+ import org .locationtech .geomesa .core .index ._
43
43
import org .locationtech .geomesa .core .iterators .TestData
44
44
import org .locationtech .geomesa .core .security .{AuthorizationsProvider , DefaultAuthorizationsProvider , FilteringAuthorizationsProvider }
45
45
import org .locationtech .geomesa .core .util .{SelfClosingIterator , CloseableIterator }
@@ -53,6 +53,7 @@ import org.specs2.mutable.Specification
53
53
import org .specs2 .runner .JUnitRunner
54
54
55
55
import scala .collection .JavaConversions ._
56
+ import scala .util .Random
56
57
57
58
@ RunWith (classOf [JUnitRunner ])
58
59
class AccumuloDataStoreTest extends Specification {
@@ -175,6 +176,7 @@ class AccumuloDataStoreTest extends Specification {
175
176
" and there are no results" >> { features.hasNext should be equalTo false }
176
177
}
177
178
}
179
+
178
180
" process a DWithin query correctly" in {
179
181
// create the data store
180
182
val sftName = " dwithintest"
@@ -210,6 +212,55 @@ class AccumuloDataStoreTest extends Specification {
210
212
" and no more results" >> { features.hasNext must beFalse }
211
213
}
212
214
215
+ " process an OR query correctly" in {
216
+ val sftName = " ortest"
217
+ val sft = SimpleFeatureTypes .createType(sftName, s " NAME:String,dtg:Date,*geom:Point:srid=4326 " )
218
+ sft.getUserData.put(SF_PROPERTY_START_TIME , " dtg" )
219
+ ds.createSchema(sft)
220
+
221
+ val fs = ds.getFeatureSource(sftName).asInstanceOf [AccumuloFeatureStore ]
222
+
223
+ {
224
+ val randVal : (Double , Double ) => Double = {
225
+ val r = new Random (System .nanoTime())
226
+ (low, high) => {
227
+ (r.nextDouble() * (high - low)) + low
228
+ }
229
+ }
230
+ val fc = new DefaultFeatureCollection (sftName, sft)
231
+ for (i <- 0 until 1000 ) {
232
+ val lat = randVal(- 0.001 , 0.001 )
233
+ val lon = randVal(- 0.001 , 0.001 )
234
+ val geom = WKTUtils .read(s " POINT( $lat $lon) " )
235
+ val builder = new SimpleFeatureBuilder (sft, featureFactory)
236
+ builder.addAll(List (" testType" , null , geom))
237
+ val feature = builder.buildFeature(s " fid- $i" )
238
+ feature.getUserData.put(Hints .USE_PROVIDED_FID , java.lang.Boolean .TRUE )
239
+ fc.add(feature)
240
+ }
241
+ fs.addFeatures(fc)
242
+ }
243
+
244
+ val geomFactory = JTSFactoryFinder .getGeometryFactory
245
+ val urq = ff.dwithin(ff.property(" geom" ), ff.literal(geomFactory.createPoint(new Coordinate ( 0.0005 , 0.0005 ))), 150.0 , " meters" )
246
+ val llq = ff.dwithin(ff.property(" geom" ), ff.literal(geomFactory.createPoint(new Coordinate (- 0.0005 , - 0.0005 ))), 150.0 , " meters" )
247
+ val orq = ff.or(urq, llq)
248
+ val andq = ff.and(urq, llq)
249
+ val urQuery = new Query (sftName, urq)
250
+ val llQuery = new Query (sftName, llq)
251
+ val orQuery = new Query (sftName, orq)
252
+ val andQuery = new Query (sftName, andq)
253
+
254
+ val urNum = fs.getFeatures( urQuery).features.length
255
+ val llNum = fs.getFeatures( llQuery).features.length
256
+ val orNum = fs.getFeatures( orQuery).features.length
257
+ val andNum = fs.getFeatures(andQuery).features.length
258
+
259
+ " obeying inclusion-exclusion principle" >> {
260
+ (urNum + llNum) mustEqual (orNum + andNum)
261
+ }
262
+ }
263
+
213
264
" handle transformations" in {
214
265
val sftName = " transformtest1"
215
266
val sft = SimpleFeatureTypes .createType(sftName, s " name:String,dtg:Date,*geom:Point:srid=4326 " )
0 commit comments