use of org.opengis.filter.spatial.Intersects in project ddf by codice.
the class TestCswRecordMapperFilterVisitor method testIntersectsUtm.
@Test
public void testIntersectsUtm() throws FactoryException, TransformException {
double lon = 33.45;
double lat = 25.22;
double easting = 545328.48;
double northing = 2789384.24;
CoordinateReferenceSystem sourceCRS = CRS.decode("EPSG:32636");
GeometryFactory geoFactory = new GeometryFactory();
Geometry utmPoint = geoFactory.createPoint(new Coordinate(easting, northing));
utmPoint.setUserData(sourceCRS);
Expression pt1 = factory.literal(geoFactory.createPoint(new Coordinate(1, 2)));
Expression pt2 = factory.literal(utmPoint);
Intersects filter = factory.intersects(pt1, pt2);
visitor.visit(filter, null);
assertThat(pt2, instanceOf(Literal.class));
Literal literalExpression = (Literal) pt2;
assertThat(literalExpression.getValue(), instanceOf(Geometry.class));
Geometry geometry = (Geometry) literalExpression.getValue();
assertThat(geometry.getCoordinates()[0].x, closeTo(lon, .00001));
assertThat(geometry.getCoordinates()[0].y, closeTo(lat, .00001));
}
use of org.opengis.filter.spatial.Intersects in project polymap4-core by Polymap4.
the class LuceneQueryDialect method supports.
public static boolean supports(Filter _filter) {
final List notSupported = new ArrayList();
_filter.accept(new DefaultFilterVisitor() {
public Object visit(Beyond filter, Object data) {
notSupported.add(filter);
return super.visit(filter, data);
}
public Object visit(Contains filter, Object data) {
notSupported.add(filter);
return super.visit(filter, data);
}
public Object visit(Crosses filter, Object data) {
notSupported.add(filter);
return super.visit(filter, data);
}
public Object visit(Disjoint filter, Object data) {
notSupported.add(filter);
return super.visit(filter, data);
}
public Object visit(Divide expression, Object data) {
notSupported.add(expression);
return super.visit(expression, data);
}
public Object visit(DWithin filter, Object data) {
notSupported.add(filter);
return super.visit(filter, data);
}
public Object visit(org.opengis.filter.expression.Function expression, Object data) {
notSupported.add(expression);
return super.visit(expression, data);
}
public Object visit(Intersects filter, Object data) {
notSupported.add(filter);
return super.visit(filter, data);
}
public Object visit(Multiply expression, Object data) {
notSupported.add(expression);
return super.visit(expression, data);
}
public Object visit(Overlaps filter, Object data) {
notSupported.add(filter);
return super.visit(filter, data);
}
public Object visit(Subtract expression, Object data) {
notSupported.add(expression);
return super.visit(expression, data);
}
public Object visit(Touches filter, Object data) {
notSupported.add(filter);
return super.visit(filter, data);
}
public Object visit(Within filter, Object data) {
notSupported.add(filter);
return super.visit(filter, data);
}
}, notSupported);
return notSupported.isEmpty();
}
use of org.opengis.filter.spatial.Intersects in project ddf by codice.
the class OpenSearchFilterVisitorTest method testIntersectsAndNest.
@Test
public void testIntersectsAndNest() {
Intersects intersectsFilter = (Intersects) geotoolsFilterBuilder.attribute(SPATIAL_ATTRIBUTE_NAME).intersecting().wkt(WKT_POLYGON);
OpenSearchFilterVisitorObject openSearchFilterVisitorObject = new OpenSearchFilterVisitorObject();
openSearchFilterVisitorObject.setCurrentNest(NestedTypes.AND);
OpenSearchFilterVisitorObject result = (OpenSearchFilterVisitorObject) openSearchFilterVisitor.visit(intersectsFilter, openSearchFilterVisitorObject);
assertThat(result.getPointRadiusSearches(), is(empty()));
assertThat(result.getGeometrySearches(), contains(hasToString(is(WKT_POLYGON))));
}
use of org.opengis.filter.spatial.Intersects in project ddf by codice.
the class OpenSearchFilterVisitorTest method testIntersects.
@Test
public void testIntersects() {
Intersects intersectsFilter = (Intersects) geotoolsFilterBuilder.attribute(SPATIAL_ATTRIBUTE_NAME).intersecting().wkt(WKT_POLYGON);
OpenSearchFilterVisitorObject openSearchFilterVisitorObject = new OpenSearchFilterVisitorObject();
openSearchFilterVisitorObject.setCurrentNest(NestedTypes.AND);
OpenSearchFilterVisitorObject result = (OpenSearchFilterVisitorObject) openSearchFilterVisitor.visit(intersectsFilter, openSearchFilterVisitorObject);
assertThat(result.getGeometrySearches(), contains(hasToString(is(WKT_POLYGON))));
}
use of org.opengis.filter.spatial.Intersects in project ddf by codice.
the class OpenSearchFilterVisitorTest method testIntersectsWithMultipolygon.
@Test
public void testIntersectsWithMultipolygon() {
Intersects intersectsFilter = (Intersects) geotoolsFilterBuilder.attribute(SPATIAL_ATTRIBUTE_NAME).intersecting().wkt(WKT_MULTI_POLYGON);
OpenSearchFilterVisitorObject openSearchFilterVisitorObject = new OpenSearchFilterVisitorObject();
openSearchFilterVisitorObject.setCurrentNest(NestedTypes.OR);
OpenSearchFilterVisitorObject result = (OpenSearchFilterVisitorObject) openSearchFilterVisitor.visit(intersectsFilter, openSearchFilterVisitorObject);
assertThat(result.getPointRadiusSearches(), is(empty()));
assertThat(result.getGeometrySearches(), contains(hasToString(is(WKT_MULTI_POLYGON))));
}
Aggregations