org.opengis.filter.spatial.Contains Java Examples
The following examples show how to use
org.opengis.filter.spatial.Contains.
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: 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 #3
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 #4
Source File: ElasticGeometryFilterIT.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testContainsFilter() throws Exception { init("not-active","geo3"); FilterFactory2 ff = (FilterFactory2) dataStore.getFilterFactory(); GeometryFactory gf = new GeometryFactory(); PackedCoordinateSequenceFactory sf = new PackedCoordinateSequenceFactory(); Polygon ls = gf.createPolygon(sf.create(new double[] { 2, 2, 3, 2, 3, 3, 2, 3, 2, 2 }, 2)); Contains f = ff.contains(ff.property("geo3"), ff.literal(ls)); SimpleFeatureCollection features = featureSource.getFeatures(f); assertEquals(1, features.size()); SimpleFeatureIterator fsi = features.features(); assertTrue(fsi.hasNext()); assertEquals(fsi.next().getID(), "active.12"); }
Example #5
Source File: PropertyIgnoringFilterVisitor.java From geowave with Apache License 2.0 | 5 votes |
@Override public Object visit(final Contains filter, final Object extraData) { if (!usesProperty(filter)) { return Filter.INCLUDE; } return super.visit(filter, extraData); }
Example #6
Source File: PropertyIgnoringFilterVisitor.java From geowave with Apache License 2.0 | 5 votes |
@Override public Object visit(final Contains filter, final Object extraData) { if (!usesProperty(filter)) { return Filter.INCLUDE; } return super.visit(filter, extraData); }
Example #7
Source File: ExtractGeometryFilterVisitor.java From geowave with Apache License 2.0 | 5 votes |
@Override public Object visit(final Contains filter, Object data) { if (!attributeOfInterest.equals(filter.getExpression1().toString())) { return new ExtractGeometryFilterVisitorResult(infinity(), null); } data = filter.getExpression2().accept(this, data); // since predicate is defined relative to the query geometry we are // using WITHIN // which is converse of CONTAINS operator // CQL Expression "CONTAINS(geo, QueryGeometry)" is equivalent to // QueryGeometry.WITHIN(geo) return new ExtractGeometryFilterVisitorResult((Geometry) data, CompareOperation.WITHIN); }
Example #8
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 #9
Source File: FilterToElastic.java From elasticgeo with GNU General Public License v3.0 | 4 votes |
public Object visit(Contains filter, Object extraData) { return visitBinarySpatialOperator(filter, extraData); }
Example #10
Source File: ExtractTimeFilterVisitor.java From geowave with Apache License 2.0 | 4 votes |
@Override public Object visit(final Contains filter, final Object data) { return new TemporalConstraints(); }
Example #11
Source File: CriteriaVisitor.java From geomajas-project-server with GNU Affero General Public License v3.0 | 4 votes |
/** {@inheritDoc} */ public Object visit(Contains filter, Object userData) { throw new UnsupportedOperationException("visit(Contains filter, Object userData)"); }