use of com.vividsolutions.jts.geom.Geometry in project ddf by codice.
the class PredicateTest method testGeospatialEvaluatorPointRadiusContains.
@Test
public void testGeospatialEvaluatorPointRadiusContains() throws Exception {
LOGGER.debug("************************** START: testGeospatialEvaluator_PointRadius_Contains() ***********************");
// WKT specifies points in LON LAT order
String geometryWkt = "POINT (44.5 34.5)";
String operation = "point_radius";
// 0.6 degrees
double distance = 0.6 * NM_PER_DEG_LAT * METERS_PER_NM;
// latitude in
// meters
double radiusInDegrees = (distance * 180.0) / (Math.PI * EQUATORIAL_RADIUS_IN_METERS);
LOGGER.debug("distance (in meters) = " + distance + ", radiusInDegrees = " + radiusInDegrees);
GeospatialPredicate predicate = new GeospatialPredicate(geometryWkt, operation, radiusInDegrees);
Geometry geoCriteria = predicate.getGeoCriteria();
LOGGER.debug("geoCriteria.toText() = {}", geoCriteria.toText());
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, radiusInDegrees);
boolean status = GeospatialEvaluator.evaluate(gec);
assertTrue(status);
LOGGER.debug("************************** END: testGeospatialEvaluator_PointRadius_Contains() ***********************");
}
use of com.vividsolutions.jts.geom.Geometry in project ddf by codice.
the class SolrFilterDelegate method intersects.
@Override
public SolrQuery intersects(String propertyName, String wkt) {
// error.
if (StringUtils.isNotBlank(wkt) && wkt.toUpperCase().contains("POINT")) {
Geometry geo = getGeometry(wkt);
if (geo != null) {
if (isPoint(geo)) {
Point pnt = (Point) geo;
String pointRadiusQuery = geoPointToCircleQuery(propertyName, DEFAULT_ERROR_IN_DEGREES, pnt);
updateDistanceSort(propertyName, pnt);
return new SolrQuery(pointRadiusQuery);
}
if (MultiPoint.class.getSimpleName().equals(geo.getGeometryType()) && geo.getCoordinates().length == 1) {
Point pnt = GEOMETRY_FACTORY.createPoint(geo.getCoordinate());
String pointRadiusQuery = geoPointToCircleQuery(propertyName, DEFAULT_ERROR_IN_DEGREES, pnt);
updateDistanceSort(propertyName, pnt);
return new SolrQuery(pointRadiusQuery);
}
}
}
return operationToQuery(INTERSECTS_OPERATION, propertyName, wkt);
}
use of com.vividsolutions.jts.geom.Geometry in project ddf by codice.
the class SolrFilterDelegate method operationToQuery.
private SolrQuery operationToQuery(String operation, String propertyName, String wkt) {
String geoIndexName = getMappedPropertyName(propertyName, AttributeFormat.GEOMETRY, false);
if (!StringUtils.isNotEmpty(wkt)) {
throw new UnsupportedOperationException("Wkt should not be null or empty.");
}
String geoQuery = geoIndexName + ":\"" + operation + "(" + fixSelfIntersectingGeometry(wkt) + ")\"";
Geometry pnt = getGeometry(wkt);
if (pnt != null) {
updateDistanceSort(propertyName, pnt.getCentroid());
}
return new SolrQuery(geoQuery);
}
use of com.vividsolutions.jts.geom.Geometry in project ddf by codice.
the class CswFilterFactory method getEnvelopeFromWkt.
private Envelope getEnvelopeFromWkt(String wkt) {
Geometry geo = getGeometryFromWkt(wkt);
Envelope envelope = geo.getEnvelopeInternal();
return envelope;
}
use of com.vividsolutions.jts.geom.Geometry in project ddf by codice.
the class WfsFilterDelegate method createGeometryOperand.
private JAXBElement<?> createGeometryOperand(String wkt) {
String convertedWkt = convertWktToLatLonOrdering(wkt);
Geometry wktGeometry = null;
try {
wktGeometry = getGeometryFromWkt(convertedWkt);
} catch (ParseException e) {
throw new UnsupportedOperationException("Unable to parse WKT Geometry [" + convertedWkt + "]", e);
}
if (wktGeometry instanceof Polygon) {
GeometryOperand polygonOperand = new GeometryOperand();
polygonOperand.setName(Wfs20Constants.POLYGON);
if (isGeometryOperandSupported(polygonOperand)) {
return createPolygon(wktGeometry);
}
GeometryOperand envelopeOperand = new GeometryOperand();
envelopeOperand.setName(Wfs20Constants.ENVELOPE);
if (isGeometryOperandSupported(envelopeOperand)) {
return createEnvelope(wktGeometry);
}
} else if (wktGeometry instanceof Point) {
GeometryOperand pointOperand = new GeometryOperand();
pointOperand.setName(Wfs20Constants.POINT);
if (isGeometryOperandSupported(pointOperand)) {
return createPoint(wktGeometry);
}
} else if (wktGeometry instanceof LineString) {
GeometryOperand lineStringOperand = new GeometryOperand();
lineStringOperand.setName(Wfs20Constants.LINESTRING);
if (isGeometryOperandSupported(lineStringOperand)) {
return createLineString(wktGeometry);
}
}
throw new UnsupportedOperationException("Geometry Operand from WKT [" + convertedWkt + "] is not supported.");
}
Aggregations