GeoDistanceCondition extends GeospatialCondition { private Query query(GeoDistance geoDistance, SpatialStrategy spatialStrategy) { double kms = geoDistance.getValue(GeoDistanceUnit.KILOMETRES); double distance = DistanceUtils.dist2Degrees(kms, DistanceUtils.EARTH_MEAN_RADIUS_KM); Circle circle = CONTEXT.makeCircle(longitude, latitude, distance); SpatialArgs args = new SpatialArgs(SpatialOperation.Intersects, circle); return spatialStrategy.makeQuery(args); } GeoDistanceCondition(Float boost,
                                String field,
                                Double latitude,
                                Double longitude,
                                GeoDistance minGeoDistance,
                                GeoDistance maxGeoDistance); @Override Query doQuery(SpatialStrategy strategy); @Override MoreObjects.ToStringHelper toStringHelper(); final double latitude; final double longitude; final GeoDistance minGeoDistance; final GeoDistance maxGeoDistance; }
@Test(expected = IndexException.class) public void testQueryWithoutValidMapper() { Schema schema = schema().mapper("name", uuidMapper()).build(); Condition condition = new GeoDistanceCondition(0.5f, "name", 90D, -180D, null, GeoDistance.parse("3km")); condition.query(schema); }