use of ddf.catalog.pubsub.predicate.GeospatialPredicate in project ddf by codice.
the class PredicateTest method testGeospatialEvaluatorOverlaps.
@Test
public void testGeospatialEvaluatorOverlaps() throws Exception {
LOGGER.debug("************************** START: testGeospatialEvaluator_Overlaps() ***********************");
// WKT specifies points in LON LAT order
String geometryWkt = "POLYGON ((40 34, 40 33, 44.5 33, 44.5 34, 40 34))";
String operation = "overlaps";
double distance = 0.0000001;
GeospatialPredicate predicate = new GeospatialPredicate(geometryWkt, operation, distance);
Geometry geoCriteria = predicate.getGeoCriteria();
String geospatialXml = "<gml:Polygon xmlns:gml=\"http://www.opengis.net/gml\" gml:id=\"BGE-1\">\n" + " <gml:exterior>\n" + " <gml:LinearRing>\n" + " <gml:pos>34.0 44.0</gml:pos>\n" + " <gml:pos>33.0 44.0</gml:pos>\n" + " <gml:pos>33.0 45.0</gml:pos>\n" + " <gml:pos>34.0 45.0</gml:pos>\n" + " <gml:pos>34.0 44.0</gml:pos>\n" + " </gml:LinearRing>\n" + " </gml:exterior>\n" + "</gml:Polygon>";
Geometry input = GeospatialEvaluator.buildGeometry(geospatialXml);
LOGGER.debug("input.toText() = {}", input.toText());
GeospatialEvaluationCriteria gec = new GeospatialEvaluationCriteriaImpl(geoCriteria, operation, input, distance);
boolean status = GeospatialEvaluator.evaluate(gec);
assertTrue(status);
LOGGER.debug("************************** END: testGeospatialEvaluator_Overlaps() ***********************");
}
use of ddf.catalog.pubsub.predicate.GeospatialPredicate in project ddf by codice.
the class SubscriptionFilterVisitor method visit.
/**
* Within filter maps to a CONTAINS Spatial search criteria.
*/
@Override
public Object visit(Within filter, Object data) {
LOGGER.debug("ENTERING: Within filter");
LOGGER.debug("Must have received CONTAINS query criteria: {}", filter.getExpression2());
org.locationtech.jts.geom.Geometry jtsGeometry = getJtsGeometery((LiteralExpressionImpl) filter.getExpression2());
Predicate predicate = new GeospatialPredicate(jtsGeometry, SpatialOperator.CONTAINS.name(), 0.0);
LOGGER.debug("EXITING: Within filter");
return predicate;
}
use of ddf.catalog.pubsub.predicate.GeospatialPredicate in project ddf by codice.
the class SubscriptionFilterVisitor method visit.
/**
* DWithin filter maps to a Point/Radius distance Spatial search criteria.
*/
@Override
public Object visit(DWithin filter, Object data) {
LOGGER.debug("ENTERING: DWithin filter");
LOGGER.debug("Must have received point/radius query criteria.");
double radius = filter.getDistance();
org.locationtech.jts.geom.Geometry jtsGeometry = getJtsGeometery((LiteralExpressionImpl) filter.getExpression2());
double radiusInDegrees = (radius * 180.0) / (Math.PI * EQUATORIAL_RADIUS_IN_METERS);
LOGGER.debug("radius in meters : {}", radius);
LOGGER.debug("radius in degrees : {}", radiusInDegrees);
Predicate predicate = new GeospatialPredicate(jtsGeometry, null, radiusInDegrees);
LOGGER.debug("EXITING: DWithin filter");
return predicate;
}
Aggregations