use of com.vividsolutions.jts.geom.Point 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.Point 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.");
}
use of com.vividsolutions.jts.geom.Point in project ddf by codice.
the class Wfs20JTStoGML321Converter method createGeometryPropertyType.
private static GeometryPropertyType createGeometryPropertyType(Geometry geometry, String srsName) {
final GeometryPropertyType geometryPropertyType = GML320_OBJECT_FACTORY.createGeometryPropertyType();
if (geometry instanceof Point) {
PointType pointType = convertToPointType((Point) geometry, srsName);
geometryPropertyType.setAbstractGeometry(convertPointTypeToJAXB(pointType));
} else if (geometry instanceof LineString) {
LineStringType lineStringType = convertToLineStringType((LineString) geometry, srsName);
geometryPropertyType.setAbstractGeometry(convertLineStringTypeToJAXB(lineStringType));
} else if (geometry instanceof Polygon) {
PolygonType polygonType = convertToPolygonType((Polygon) geometry, srsName);
geometryPropertyType.setAbstractGeometry(convertPolygonTypeToJAXB(polygonType));
} else if (geometry instanceof MultiPoint) {
MultiPointType multiPointType = convertToMultiPointType((MultiPoint) geometry, srsName);
geometryPropertyType.setAbstractGeometry(convertMultiPointTypeToJAXB(multiPointType));
} else if (geometry instanceof MultiLineString) {
MultiCurveType multiCurveType = convertToMultiLineStringType((MultiLineString) geometry, srsName);
geometryPropertyType.setAbstractGeometry(convertMultiCurveTypeToJAXB(multiCurveType));
} else if (geometry instanceof MultiPolygon) {
MultiSurfaceType multiSurfaceType = convertToMultiSurfaceType((MultiPolygon) geometry, srsName);
geometryPropertyType.setAbstractGeometry(convertMultiSurfaceTypeToJAXB(multiSurfaceType));
} else if (geometry instanceof GeometryCollection) {
MultiGeometryType multiGeometryType = convertToMultiGeometryType((GeometryCollection) geometry, srsName);
geometryPropertyType.setAbstractGeometry(convertMultiGeometryTypeToJAXB(multiGeometryType));
} else {
throw new IllegalArgumentException();
}
return geometryPropertyType;
}
use of com.vividsolutions.jts.geom.Point in project ddf by codice.
the class TwitterFilterVisitor method visit.
/**
* Contains filter maps to a Polygon or BBox Spatial search criteria.
*/
@Override
public Object visit(Contains filter, Object data) {
LOGGER.trace("ENTERING: Contains filter");
if (currentNest == null || NestedTypes.AND.equals(currentNest)) {
// The geometric point is wrapped in a <Literal> element, so have to
// get geometry expression as literal and then evaluate it to get
// the geometry.
// Example:
// <ogc:Literal>org.geotools.geometry.jts.spatialschema.geometry.primitive.SurfaceImpl@64a7c45e</ogc:Literal>
Literal literalWrapper = (Literal) filter.getExpression2();
Object geometryExpression = literalWrapper.getValue();
if (geometryExpression instanceof SurfaceImpl) {
SurfaceImpl polygon = (SurfaceImpl) literalWrapper.evaluate(null);
Point point = polygon.getJTSGeometry().getCentroid();
longitude = point.getX();
latitude = point.getY();
radius = point.getBoundary().getLength() * 10;
hasSpatial = true;
filters.add(filter);
} else if (geometryExpression instanceof Polygon) {
Polygon polygon = (Polygon) geometryExpression;
Point centroid = polygon.getCentroid();
longitude = centroid.getX();
latitude = centroid.getY();
radius = polygon.getBoundary().getLength() * 10;
hasSpatial = true;
filters.add(filter);
} else {
LOGGER.warn("Only POLYGON geometry WKT for Contains filter is supported");
}
} else {
LOGGER.warn(ONLY_AND_MSG);
}
LOGGER.trace("EXITING: Contains filter");
return super.visit(filter, data);
}
use of com.vividsolutions.jts.geom.Point in project ddf by codice.
the class TwitterFilterVisitor method visit.
/**
* DWithin filter maps to a Point/Radius distance Spatial search criteria.
*/
@Override
public Object visit(DWithin filter, Object data) {
LOGGER.trace("ENTERING: DWithin filter");
if (currentNest == null || NestedTypes.AND.equals(currentNest)) {
// The geometric point is wrapped in a <Literal> element, so have to
// get geometry expression as literal and then evaluate it to get
// the geometry.
// Example:
// <ogc:Literal>org.geotools.geometry.jts.spatialschema.geometry.primitive.PointImpl@dc33f184</ogc:Literal>
Literal literalWrapper = (Literal) filter.getExpression2();
// Luckily we know what type the geometry expression should be, so
// we
// can cast it
Point point = (Point) literalWrapper.evaluate(null);
Coordinate coords = point.getCentroid().getCoordinate();
double distance = filter.getDistance();
LOGGER.debug("point: coords[0] = {}, coords[1] = {}", coords.x, coords.y);
LOGGER.debug("radius = {}", distance);
longitude = coords.x;
latitude = coords.y;
radius = distance / 1000;
hasSpatial = true;
filters.add(filter);
} else {
LOGGER.warn(ONLY_AND_MSG);
}
LOGGER.trace("EXITING: DWithin filter");
return super.visit(filter, data);
}
Aggregations