org.opengis.filter.spatial.DWithin Java Examples
The following examples show how to use
org.opengis.filter.spatial.DWithin.
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: FilterToElasticHelper.java From elasticgeo with GNU General Public License v3.0 | 6 votes |
private void visitDistanceSpatialOperator(DistanceBufferOperator filter, PropertyName property, Literal geometry, boolean swapped, Object extraData) { property.accept(delegate, extraData); key = (String) delegate.field; geometry.accept(delegate, extraData); final Geometry geo = delegate.currentGeometry; double lat = geo.getCentroid().getY(); double lon = geo.getCentroid().getX(); final double inputDistance = filter.getDistance(); final String inputUnits = filter.getDistanceUnits(); double distance = Double.valueOf(toMeters(inputDistance, inputUnits)); delegate.queryBuilder = ImmutableMap.of("bool", ImmutableMap.of("must", MATCH_ALL, "filter", ImmutableMap.of("geo_distance", ImmutableMap.of("distance", distance +"m", key, ImmutableList.of(lon, lat))))); if ((filter instanceof DWithin && swapped) || (filter instanceof Beyond && !swapped)) { delegate.queryBuilder = ImmutableMap.of("bool", ImmutableMap.of("must_not", delegate.queryBuilder)); } }
Example #2
Source File: ElasticGeometryFilterIT.java From elasticgeo with GNU General Public License v3.0 | 6 votes |
@Test public void testDWithinFilter() throws Exception { init(); FilterFactory2 ff = (FilterFactory2) dataStore.getFilterFactory(); GeometryFactory gf = new GeometryFactory(); PackedCoordinateSequenceFactory sf = new PackedCoordinateSequenceFactory(); Point ls = gf.createPoint(sf.create(new double[] { 0, 0 }, 2)); DWithin f = ff.dwithin(ff.property("geo"), ff.literal(ls), 3, "m"); SimpleFeatureCollection features = featureSource.getFeatures(f); assertEquals(2, features.size()); SimpleFeatureIterator fsi = features.features(); assertTrue(fsi.hasNext()); assertEquals(fsi.next().getID(), "active.01"); assertTrue(fsi.hasNext()); assertEquals(fsi.next().getID(), "active.10"); }
Example #3
Source File: ElasticGeometryFilterIT.java From elasticgeo with GNU General Public License v3.0 | 6 votes |
@Test public void testGeoPointAsArray() throws Exception { init("active","geo5"); FilterFactory2 ff = (FilterFactory2) dataStore.getFilterFactory(); GeometryFactory gf = new GeometryFactory(); PackedCoordinateSequenceFactory sf = new PackedCoordinateSequenceFactory(); Point ls = gf.createPoint(sf.create(new double[] { 0, 0 }, 2)); DWithin f = ff.dwithin(ff.property("geo5"), ff.literal(ls), 3, "m"); SimpleFeatureCollection features = featureSource.getFeatures(f); assertEquals(2, features.size()); SimpleFeatureIterator fsi = features.features(); assertTrue(fsi.hasNext()); SimpleFeature feature = fsi.next(); assertEquals(feature.getID(), "active.01"); assertNotNull(feature.getDefaultGeometry()); assertTrue(fsi.hasNext()); feature = fsi.next(); assertEquals(feature.getID(), "active.10"); assertNotNull(feature.getDefaultGeometry()); }
Example #4
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 #5
Source File: ElasticFilterTest.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testDWithinFilter() throws CQLException { DWithin filter = (DWithin) ECQL.toFilter("DWITHIN(\"geo_point\", POINT(0 1.1), 1.0, meters)"); Map<String,Object> expected = ImmutableMap.of("bool", ImmutableMap.of("must", MATCH_ALL, "filter", ImmutableMap.of("geo_distance", ImmutableMap.of("distance", "1.0m", "geo_point", ImmutableList.of(0.,1.1))))); builder.visit(filter, null); assertTrue(builder.createCapabilities().fullySupports(filter)); assertEquals(expected, builder.getQueryBuilder()); }
Example #6
Source File: ElasticFilterTest.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testDWithinPolygonFilter() throws CQLException { DWithin filter = (DWithin) ECQL.toFilter("DWITHIN(\"geo_point\", POLYGON((0 0, 0 1, 1 1, 1 0, 0 0)), 1.0, meters)"); Map<String,Object> expected = ImmutableMap.of("bool", ImmutableMap.of("must", MATCH_ALL, "filter", ImmutableMap.of("geo_distance", ImmutableMap.of("distance", "1.0m", "geo_point", ImmutableList.of(0.5,0.5))))); builder.visit(filter, null); assertTrue(builder.createCapabilities().fullySupports(filter)); assertEquals(expected, builder.getQueryBuilder()); }
Example #7
Source File: PropertyIgnoringFilterVisitor.java From geowave with Apache License 2.0 | 5 votes |
@Override public Object visit(final DWithin filter, final Object extraData) { if (!usesProperty(filter)) { return Filter.INCLUDE; } return super.visit(filter, extraData); }
Example #8
Source File: PropertyIgnoringFilterVisitor.java From geowave with Apache License 2.0 | 5 votes |
@Override public Object visit(final DWithin filter, final Object extraData) { if (!usesProperty(filter)) { return Filter.INCLUDE; } return super.visit(filter, extraData); }
Example #9
Source File: FilterToElastic.java From elasticgeo with GNU General Public License v3.0 | 4 votes |
public Object visit(DWithin filter, Object extraData) { return visitBinarySpatialOperator(filter, extraData); }
Example #10
Source File: HasDWithinFilterVisitor.java From geowave with Apache License 2.0 | 4 votes |
@Override public Object visit(final DWithin filter, final Object data) { hasDWithin = true; return super.visit(filter, data); }
Example #11
Source File: ExtractTimeFilterVisitor.java From geowave with Apache License 2.0 | 4 votes |
@Override public Object visit(final DWithin filter, final Object data) { return new TemporalConstraints(); }
Example #12
Source File: CriteriaVisitor.java From geomajas-project-server with GNU Affero General Public License v3.0 | 4 votes |
/** {@inheritDoc} */ @Override public Object visit(DWithin filter, Object userData) { throw new UnsupportedOperationException("visit(DWithin filter, Object userData)"); }