GeoBBoxCondition extends GeospatialCondition { @Override public Query doQuery(SpatialStrategy strategy) { Rectangle rectangle = CONTEXT.makeRectangle(minLongitude, maxLongitude, minLatitude, maxLatitude); SpatialArgs args = new SpatialArgs(SpatialOperation.Intersects, rectangle); return strategy.makeQuery(args); } GeoBBoxCondition(Float boost,
                            String field,
                            Double minLatitude,
                            Double maxLatitude,
                            Double minLongitude,
                            Double maxLongitude); @Override Query doQuery(SpatialStrategy strategy); @Override MoreObjects.ToStringHelper toStringHelper(); final double minLatitude; final double maxLatitude; final double minLongitude; final double maxLongitude; }
@Test public void testQueryWithPointMapper() { Schema schema = schema().mapper("name", geoPointMapper("lat", "lon").maxLevels(8)).build(); GeoBBoxCondition condition = new GeoBBoxCondition(0.5f, "name", -90D, 90D, -180D, 180D); Query query = condition.doQuery(schema); assertNotNull("Query is wrong is not built", query); assertEquals("Query type is wrong", IntersectsRPTVerifyQuery.class, query.getClass()); }
@Test public void testQueryWithShapeMapper() { Schema schema = schema().mapper("name", geoShapeMapper().maxLevels(8)).build(); GeoBBoxCondition condition = new GeoBBoxCondition(0.5f, "name", -90D, 90D, -180D, 180D); Query query = condition.doQuery(schema); assertNotNull("Query is wrong is not built", query); assertEquals("Query type is wrong", IntersectsRPTVerifyQuery.class, query.getClass()); }