Object cloneFilter( BinarySpatialOperator bso, Object extraData, Expression ex1, Expression ex2) { DWithin filter = (DWithin) bso; return ff.dwithin(ex1, ex2, filter.getDistance(), filter.getDistanceUnits()); } }.transform(filter, extraData);
/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated modifiable */ public Object parse(ElementInstance instance, Node node, Object value) throws Exception { // TODO: units Expression[] operands = OGCUtils.spatial(node, filterFactory, geometryFactory); double distance = ((Double) node.getChildValue("Distance")).doubleValue(); Object units = node.getChild("Distance").getAttributeValue("units"); return filterFactory.dwithin( operands[0], operands[1], distance, units == null ? null : units.toString()); } }
@Override public Filter replaceExpressions( DWithin filter, Expression expression1, Expression expression2) { return ff.dwithin( expression1, expression2, filter.getDistance(), filter.getDistanceUnits(), filter.getMatchAction()); } });
/** * @see org.geotools.xml.schema.Type#getValue(org.geotools.xml.schema.Element, * org.geotools.xml.schema.ElementValue[], org.xml.sax.Attributes, java.util.Map) */ public Object getValue(Element element, ElementValue[] value, Attributes attrs, Map hints) throws SAXException { FilterFactory2 factory = FilterSchema.filterFactory(hints); try { Expression geometry1 = (Expression) value[0].getValue(); Expression geometry2 = (Expression) value[1].getValue(); Literal literal = (Literal) value[2]; double distance = ((Number) literal.getValue()).doubleValue(); return factory.dwithin(geometry1, geometry2, distance, null); } catch (ClassCastException wrong) { throw new SAXException(wrong); } catch (IllegalFilterException illegalFilterException) { throw new SAXException(illegalFilterException); } }
public DistanceBufferOperator buildSpatialDWithinFilter() throws CQLException { String unit = this.resultStack.popStringValue(); double tolerance = this.resultStack.popDoubleValue(); Expression geom = this.resultStack.popExpression(); Expression property = this.resultStack.popExpression(); FilterFactory2 ff = (FilterFactory2) filterFactory; // TODO this cast must be removed. It depends of Geometry // implementation return ff.dwithin(property, geom, tolerance, unit); }
public Object visit(DWithin filter, Object arg1) { Expression[][] exps = visitBinarySpatialOp(filter); List combinedFilters = new ArrayList(exps.length); for (int i = 0; i < exps.length; i++) { Expression left = exps[i][0]; Expression right = exps[i][1]; Filter unrolled = ff.dwithin( left, right, filter.getDistance(), filter.getDistanceUnits(), filter.getMatchAction()); combinedFilters.add(unrolled); } Filter unrolled = combineOred(combinedFilters); return unrolled; }
if (value.getAttributes().getNamedItem("units") != null) units = value.getAttributes().getNamedItem("units").getTextContent(); return FILTER_FACT.dwithin(left, right, distance, units);
static DWithin dwithin() { return f.dwithin(f.property("the_geom"), f.literal(geometry()), 1.0d, "m"); }
public static DWithin dwithin() { return f.dwithin(f.property("the_geom"), f.literal(geometry()), 1.0d, "m"); }
public Object visit(DWithin filter, Object extraData) { Expression geometry1 = visit(filter.getExpression1(), extraData); Expression geometry2 = visit(filter.getExpression2(), extraData); double distance = filter.getDistance(); String units = filter.getDistanceUnits(); return getFactory(extraData) .dwithin(geometry1, geometry2, distance, units, filter.getMatchAction()); }
public void testDWithin() throws Exception { // Test DWithin PropertyName left = new AttributeExpressionImpl(testSchema, "testGeometry"); Coordinate[] coords2 = new Coordinate[5]; coords2[0] = new Coordinate(10, 10); coords2[1] = new Coordinate(15, 10); coords2[2] = new Coordinate(15, 15); coords2[3] = new Coordinate(10, 15); coords2[4] = new Coordinate(10, 10); GeometryFactory gf = new GeometryFactory(new PrecisionModel()); Literal right = new LiteralExpressionImpl(gf.createPolygon(gf.createLinearRing(coords2), null)); DWithin filter = fac.dwithin(left, right, 20, "m"); LOGGER.finer(filter.toString()); LOGGER.finer("contains feature: " + filter.evaluate(testFeature)); assertTrue(filter.evaluate(testFeature)); filter = fac.dwithin(left, right, 2, "m"); LOGGER.finer(filter.toString()); LOGGER.finer("contains feature: " + filter.evaluate(testFeature)); assertFalse(filter.evaluate(testFeature)); right = new LiteralExpressionImpl(null); filter = fac.dwithin(left, right, 2, "m"); LOGGER.finer(filter.toString()); LOGGER.finer("contains feature: " + filter.evaluate(testFeature)); assertFalse(filter.evaluate(testFeature)); }
@Test public void testDWithin() { Point geom = new GeometryFactory().createPoint(new Coordinate(0, 0)); Filter filter = ff.dwithin(ff.property("name"), ff.literal(geom), 100, "metre"); Envelope env = (Envelope) filter.accept(visitor, null); assertEquals(new Envelope(-100, 100, -100, 100), env); }
private void assertDWithinFilter(int expectedMatches, double distance, String unit) throws IOException { FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null); final PropertyName geomProperty = ff.property(aname("geometry")); final ContentFeatureSource features = dataStore.getFeatureSource(tname("ft1")); // too short distance DWithin filter = ff.dwithin(geomProperty, ff.literal(REFERENCE_POINT), distance, unit); FeatureCollection fc = features.getFeatures(filter); assertEquals(expectedMatches, fc.size()); }
@Test public void testAndDWithin() { Point geom = new GeometryFactory().createPoint(new Coordinate(0, 0)); Filter filter = ff.dwithin(ff.property("geom"), ff.literal(geom), 100, "metre"); filter = ff.and(filter, ff.bbox(ff.property("geom"), 50, 50, 150, 150, null)); Envelope env = (Envelope) filter.accept(visitor, null); assertEquals(new Envelope(50, 100, 50, 100), env); }
public void testDistanceGeometry() throws Exception { Coordinate[] coords2 = new Coordinate[5]; coords2[0] = new Coordinate(10, 10); coords2[1] = new Coordinate(15, 10); coords2[2] = new Coordinate(15, 15); coords2[3] = new Coordinate(10, 15); coords2[4] = new Coordinate(10, 10); GeometryFactory gf = new GeometryFactory(new PrecisionModel()); Literal right = fac.literal(gf.createPolygon(gf.createLinearRing(coords2), null)); DWithin filter = fac.dwithin(fac.property("testGeometry"), right, 10, "m"); assertAttributeName(filter, "testGeometry"); }
public void testDistanceMeters() throws Exception { if (!isGeographySupportAvailable()) { return; } // where does that 74000 come from? Here: // GeodeticCalculator gc = new GeodeticCalculator(); // gc.setStartingGeographicPoint(0, 49); // gc.setDestinationGeographicPoint(1, 49); // System.out.println(gc.getOrthodromicDistance()); --> 73171 m (we round to 74000) // if the proper distance is used, we get back only one point, // otherwise we'll get back them all DWithin filter = ff.dwithin( ff.property(aname("geo")), ff.literal(gf.createPoint(new Coordinate(1, 49))), 74000d, "metre"); FeatureCollection features = dataStore.getFeatureSource(tname("geopoint")).getFeatures(filter); assertEquals(1, features.size()); }
@Override public Filter[] visit(DWithin filter, Object extraData) { return boundedOp(filter, (g1, g2) -> ff.dwithin(g1, g2, filter.getDistance(), filter.getDistanceUnits()), false); }
public void testGeometryCollection() throws Exception { PrecisionModel precisionModel = new PrecisionModel(); int SRID = 4326; GeometryFactory gf = new GeometryFactory(precisionModel, SRID); Coordinate[] points = {new Coordinate(30, 40), new Coordinate(50, 60)}; LineString[] geometries = new LineString[2]; geometries[0] = gf.createLineString(points); Coordinate[] points2 = {new Coordinate(40, 30), new Coordinate(70, 40)}; geometries[1] = gf.createLineString(points2); GeometryFactory factory = new GeometryFactory(); GeometryCollection geometry = new GeometryCollection(geometries, factory); FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null); PropertyName p = ff.property(aname("geom")); Literal collect = ff.literal(geometry); DWithin dwithinGeomCo = ((FilterFactory2) ff).dwithin(p, collect, 5, "meter"); Query dq = new Query(tname("road"), dwithinGeomCo); SimpleFeatureCollection features = dataStore.getFeatureSource(tname("road")).getFeatures(dq); assertEquals(0, features.size()); } }
new Coordinate(-122.33, 47.606), new Coordinate(0.0, 51.5) }); DWithin filter = ff.dwithin(ff.property(aname("geo")), ff.literal(line), 130000d, "metre"); FeatureCollection features = dataStore.getFeatureSource(tname("geopoint")).getFeatures(filter);
filter = fac.disjoint(expr1, expr2); assertEquals(filter.getMatchAction(), MatchAction.ANY); filter = fac.dwithin(expr1, expr2, 0.1, ""); assertEquals(filter.getMatchAction(), MatchAction.ANY); filter = fac.equal(expr1, expr2); filter = fac.disjoint(expr1, expr2, MatchAction.ALL); assertEquals(filter.getMatchAction(), MatchAction.ALL); filter = fac.dwithin(expr1, expr2, 0.1, "", MatchAction.ONE); assertEquals(filter.getMatchAction(), MatchAction.ONE); filter = fac.equal(expr1, expr2, MatchAction.ALL);