org.opengis.filter.spatial.BBOX Java Examples
The following examples show how to use
org.opengis.filter.spatial.BBOX.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StyleConverterServiceTest.java From geomajas-project-server with GNU Affero General Public License v3.0 | 6 votes |
@Test public void testFilters() throws LayerException { Style style = styleConverterService.convert(layerBeansMixedGeometryStyleInfoSld.getUserStyle()); List<Rule> rules = style.featureTypeStyles().get(0).rules(); assertThat(rules.get(0).getFilter()).isInstanceOf(BBOX.class); assertThat(rules.get(1).getFilter()).isInstanceOf(Contains.class); assertThat(rules.get(2).getFilter()).isInstanceOf(Crosses.class); assertThat(rules.get(3).getFilter()).isInstanceOf(Disjoint.class); assertThat(rules.get(4).getFilter()).isInstanceOf(Equals.class); assertThat(rules.get(5).getFilter()).isInstanceOf(Intersects.class); assertThat(rules.get(6).getFilter()).isInstanceOf(Overlaps.class); assertThat(rules.get(7).getFilter()).isInstanceOf(Touches.class); assertThat(rules.get(8).getFilter()).isInstanceOf(Within.class); NamedStyleInfo namedStyleInfo = styleConverterService.convert( layerBeansMixedGeometryStyleInfoSld.getUserStyle(), featureInfo); Assert.assertEquals(9, namedStyleInfo.getFeatureStyles().size()); }
Example #2
Source File: ElasticGeometryFilterIT.java From elasticgeo with GNU General Public License v3.0 | 6 votes |
@Test public void testAlternateGeometry() throws Exception { init("active", "geo2"); SimpleFeatureType schema = featureSource.getSchema(); GeometryDescriptor gd = schema.getGeometryDescriptor(); assertNotNull(gd); assertEquals("geo2", gd.getLocalName()); FilterFactory2 ff = (FilterFactory2) dataStore.getFilterFactory(); BBOX bbox = ff.bbox("geo2", 6.5, 23.5, 7.5, 24.5, "EPSG:4326"); SimpleFeatureCollection features = featureSource.getFeatures(bbox); assertEquals(1, features.size()); SimpleFeatureIterator fsi = features.features(); assertTrue(fsi.hasNext()); assertEquals(fsi.next().getID(), "active.09"); }
Example #3
Source File: ElasticGeometryFilterIT.java From elasticgeo with GNU General Public License v3.0 | 6 votes |
@Test public void testOgrStyleGeoPoint() throws Exception { init("not-active","geo4.coordinates"); FilterFactory2 ff = (FilterFactory2) dataStore.getFilterFactory(); BBOX bbox = ff.bbox("geo4.coordinates", 0, 0, 5, 5, "EPSG:4326"); assertNotNull(featureSource.getSchema().getDescriptor("geo4.coordinates")); assertNull(featureSource.getSchema().getDescriptor("geo4.type")); SimpleFeatureCollection features = featureSource.getFeatures(bbox); assertEquals(1, features.size()); SimpleFeatureIterator fsi = features.features(); assertTrue(fsi.hasNext()); SimpleFeature feature = fsi.next(); assertEquals(feature.getID(), "active.13"); assertNotNull(feature.getDefaultGeometry()); }
Example #4
Source File: ElasticFilterTest.java From elasticgeo with GNU General Public License v3.0 | 6 votes |
@Test public void testGeoShapeBboxFilter() { BBOX filter = ff.bbox("geom", 0., 0., 1.1, 1.1, "EPSG:4326"); List<List<Double>> coords = new ArrayList<>(); coords.add(ImmutableList.of(0.,0.)); coords.add(ImmutableList.of(0.,1.1)); coords.add(ImmutableList.of(1.1,1.1)); coords.add(ImmutableList.of(1.1,0.)); coords.add(ImmutableList.of(0.,0.)); // vertices in reverse order final List<List<Double>> reverseCoords = ImmutableList.of( coords.get(0), coords.get(3), coords.get(2), coords.get(1), coords.get(4) ); Map<String,Object> expected = ImmutableMap.of("bool", ImmutableMap.of("must", MATCH_ALL, "filter", ImmutableMap.of("geo_shape", ImmutableMap.of("geom", ImmutableMap.of("shape", ImmutableMap.of("coordinates", ImmutableList.of(coords), "type", "Polygon"), "relation", "INTERSECTS"))))); builder.visit(filter, null); assertTrue(builder.createCapabilities().fullySupports(filter)); assertThat(builder.getQueryBuilder().toString(), isOneOf(expected.toString(), expected.toString().replace(coords.toString(), reverseCoords.toString()))); }
Example #5
Source File: ElasticGeometryFilterIT.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testBBOXBeyondDateline() throws Exception { init("not-active","geo"); FilterFactory ff = dataStore.getFilterFactory(); BBOX bbox = ff.bbox("geo", 180.5, -90, 182, 90, "EPSG:" + SOURCE_SRID); SimpleFeatureCollection features = featureSource.getFeatures(bbox); assertEquals(1, features.size()); }
Example #6
Source File: CriteriaVisitor.java From geomajas-project-server with GNU Affero General Public License v3.0 | 5 votes |
/** {@inheritDoc} */ @Override public Object visit(BBOX filter, Object userData) { Envelope env = new Envelope(filter.getMinX(), filter.getMaxX(), filter.getMinY(), filter.getMaxY()); String finalName = parsePropertyName(geomName, userData); return SpatialRestrictions.filter(finalName, env, srid); }
Example #7
Source File: ExtractGeometryFilterVisitor.java From geowave with Apache License 2.0 | 5 votes |
@Override public Object visit(final BBOX filter, final Object data) { if (attributeOfInterest.equals(filter.getExpression1().toString())) { final Geometry bbox = bbox(data); final BoundingBox referencedBBox = filter.getBounds(); Geometry bounds = new GeometryFactory().toGeometry( new Envelope( referencedBBox.getMinX(), referencedBBox.getMaxX(), referencedBBox.getMinY(), referencedBBox.getMaxY())); if ((crs != null) && (referencedBBox.getCoordinateReferenceSystem() != null) && !crs.equals(referencedBBox.getCoordinateReferenceSystem())) { try { bounds = JTS.transform( bounds, CRS.findMathTransform(referencedBBox.getCoordinateReferenceSystem(), crs, true)); } catch (MismatchedDimensionException | TransformException | FactoryException e) { LOGGER.error("Unable to transforma bbox", e); } } if (bbox != null) { return bbox.union(bounds); } else { return new ExtractGeometryFilterVisitorResult(bounds, CompareOperation.INTERSECTS); } } else { return new ExtractGeometryFilterVisitorResult(infinity(), null); } }
Example #8
Source File: PropertyIgnoringFilterVisitor.java From geowave with Apache License 2.0 | 5 votes |
@Override public Object visit(final BBOX filter, final Object extraData) { if (!usesProperty(filter)) { return Filter.INCLUDE; } return super.visit(filter, extraData); }
Example #9
Source File: PropertyIgnoringFilterVisitor.java From geowave with Apache License 2.0 | 5 votes |
@Override public Object visit(final BBOX filter, final Object extraData) { if (!usesProperty(filter)) { return Filter.INCLUDE; } return super.visit(filter, extraData); }
Example #10
Source File: ElasticFeatureFilterIT.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testGetFeaturesWithAndLogicFilter() throws Exception { init(); FilterFactory ff = dataStore.getFilterFactory(); PropertyIsEqualTo property = ff.equals(ff.property("standard_ss"), ff.literal("IEEE 802.11b")); BBOX bbox = ff.bbox("geo", -1, -1, 10, 10, "EPSG:" + SOURCE_SRID); And filter = ff.and(property, bbox); SimpleFeatureCollection features = featureSource.getFeatures(filter); assertEquals(3, features.size()); }
Example #11
Source File: ElasticFilterTest.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testGeoPointBboxFilter() { BBOX filter = ff.bbox("geo_point", 0., 0., 1., 1., "EPSG:4326"); Map<String,Object> expected = ImmutableMap.of("bool", ImmutableMap.of("must", MATCH_ALL, "filter", ImmutableMap.of("geo_bounding_box", ImmutableMap.of("geo_point", ImmutableMap.of("top_left", ImmutableList.of(0.,1.) , "bottom_right", ImmutableList.of(1.,0.)))))); builder.visit(filter, null); assertTrue(builder.createCapabilities().fullySupports(filter)); assertEquals(expected, builder.getQueryBuilder()); }
Example #12
Source File: ElasticFilterTest.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testNullBinarySpatialOperatorFilter() { boolean success = false; try { builder.visit((BBOX) null, null); } catch (NullPointerException e) { success = true; } assertTrue(success); }
Example #13
Source File: ElasticGeometryFilterIT.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testBBOXCoveringDateline() throws Exception { init("not-active","geo"); FilterFactory ff = dataStore.getFilterFactory(); BBOX bbox = ff.bbox("geo", 178, -90, 182, 90, "EPSG:" + SOURCE_SRID); SimpleFeatureCollection features = featureSource.getFeatures(bbox); assertEquals(2, features.size()); }
Example #14
Source File: ElasticGeometryFilterIT.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testBBOXAndEqualsFilter() throws Exception { init(); FilterFactory ff = dataStore.getFilterFactory(); PropertyIsEqualTo property = ff.equals(ff.property("standard_ss"), ff.literal("IEEE 802.11b")); BBOX bbox = ff.bbox("geo", -180, -180, 180, 180, "EPSG:" + SOURCE_SRID); And filter = ff.and(property, bbox); SimpleFeatureCollection features = featureSource.getFeatures(filter); assertEquals(7, features.size()); }
Example #15
Source File: ElasticGeometryFilterIT.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testBBOXFilter() throws Exception { init(); FilterFactory ff = dataStore.getFilterFactory(); BBOX bbox = ff.bbox("geo", -180, -98, 180, 98, "EPSG:" + SOURCE_SRID); SimpleFeatureCollection features = featureSource.getFeatures(bbox); assertEquals(11, features.size()); }
Example #16
Source File: FilterToElasticHelper.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
private void visitGeoShapeBinarySpatialOperator(BinarySpatialOperator filter, Expression e1, Expression e2, boolean swapped, Object extraData) { SpatialRelation shapeRelation; if (filter instanceof Disjoint) { shapeRelation = SpatialRelation.DISJOINT; } else if ((!swapped && filter instanceof Within) || (swapped && filter instanceof Contains)) { shapeRelation = SpatialRelation.WITHIN; } else if (filter instanceof Intersects || filter instanceof BBOX) { shapeRelation = SpatialRelation.INTERSECTS; } else { FilterToElastic.LOGGER.fine(filter.getClass().getSimpleName() + " is unsupported for geo_shape types"); shapeRelation = null; delegate.fullySupported = false; } if (shapeRelation != null) { e1.accept(delegate, extraData); key = (String) delegate.field; e2.accept(delegate, extraData); shapeBuilder = delegate.currentShapeBuilder; } if (shapeRelation != null && shapeBuilder != null) { delegate.queryBuilder = ImmutableMap.of("bool", ImmutableMap.of("must", MATCH_ALL, "filter", ImmutableMap.of("geo_shape", ImmutableMap.of(key, ImmutableMap.of("shape", shapeBuilder, "relation", shapeRelation))))); } else { delegate.queryBuilder = MATCH_ALL; } }
Example #17
Source File: ElasticCapabilities.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
public ElasticCapabilities() { super(new ElasticFilterCapabilities()); addAll(LOGICAL_OPENGIS); addAll(SIMPLE_COMPARISONS_OPENGIS); addType(PropertyIsNull.class); addType(PropertyIsBetween.class); addType(Id.class); addType(IncludeFilter.class); addType(ExcludeFilter.class); addType(PropertyIsLike.class); // spatial filters addType(BBOX.class); addType(Contains.class); //addType(Crosses.class); addType(Disjoint.class); //addType(Equals.class); addType(Intersects.class); //addType(Overlaps.class); //addType(Touches.class); addType(Within.class); addType(DWithin.class); addType(Beyond.class); //temporal filters addType(After.class); addType(Before.class); addType(Begins.class); addType(BegunBy.class); addType(During.class); addType(Ends.class); addType(EndedBy.class); addType(TContains.class); addType(TEquals.class); }
Example #18
Source File: BBOXRemovingFilterVisitor.java From elasticgeo with GNU General Public License v3.0 | 4 votes |
@Override public Object visit(BBOX filter, Object extraData) { geometryPropertyName = filter.getExpression1().toString(); return Filter.INCLUDE; }
Example #19
Source File: FilterToElastic.java From elasticgeo with GNU General Public License v3.0 | 4 votes |
public Object visit(BBOX filter, Object extraData) { return visitBinarySpatialOperator(filter, extraData); }
Example #20
Source File: FilterToElasticHelper.java From elasticgeo with GNU General Public License v3.0 | 4 votes |
private void visitGeoPointBinarySpatialOperator(BinarySpatialOperator filter, Expression e1, Expression e2, boolean swapped, Object extraData) { e1.accept(delegate, extraData); key = (String) delegate.field; e2.accept(delegate, extraData); final Geometry geometry = delegate.currentGeometry; if (geometry instanceof Polygon && ((!swapped && filter instanceof Within) || (swapped && filter instanceof Contains) || filter instanceof Intersects)) { final Polygon polygon = (Polygon) geometry; final List<List<Double>> points = new ArrayList<>(); for (final Coordinate coordinate : polygon.getCoordinates()) { points.add(ImmutableList.of(coordinate.x, coordinate.y)); } delegate.queryBuilder = ImmutableMap.of("bool", ImmutableMap.of("must", MATCH_ALL, "filter", ImmutableMap.of("geo_polygon", ImmutableMap.of(key, ImmutableMap.of("points", points))))); } else if (filter instanceof BBOX) { final BoundingBox envelope = ((BBOX) filter).getBounds(); final double minY = clipLat(envelope.getMinY()); final double maxY = clipLat(envelope.getMaxY()); final double minX, maxX; if (envelope.getWidth() < 360) { minX = clipLon(envelope.getMinX()); maxX = clipLon(envelope.getMaxX()); } else { minX = -180; maxX = 180; } delegate.queryBuilder = ImmutableMap.of("bool", ImmutableMap.of("must", MATCH_ALL, "filter", ImmutableMap.of("geo_bounding_box", ImmutableMap.of(key, ImmutableMap.of("top_left", ImmutableList.of(minX, maxY), "bottom_right", ImmutableList.of(maxX, minY)))))); } else { FilterToElastic.LOGGER.fine(filter.getClass().getSimpleName() + " is unsupported for geo_point types"); delegate.fullySupported = false; delegate.queryBuilder = MATCH_ALL; } }
Example #21
Source File: ExtractTimeFilterVisitor.java From geowave with Apache License 2.0 | 4 votes |
@Override public Object visit(final BBOX filter, final Object data) { return new TemporalConstraints(); }