use of com.vividsolutions.jts.geom.Point in project ddf by codice.
the class SolrFilterDelegate method nearestNeighbor.
@Override
public SolrQuery nearestNeighbor(String propertyName, String wkt) {
Geometry geo = getGeometry(wkt);
if (geo != null) {
Point pnt;
if (isPoint(geo)) {
pnt = (Point) geo;
} else {
pnt = geo.getCentroid();
}
SolrQuery query = null;
if (null != pnt) {
String nearestNeighborQuery = geoPointToCircleQuery(propertyName, NEAREST_NEIGHBOR_DISTANCE_LIMIT, pnt);
updateDistanceSort(propertyName, pnt);
query = new SolrQuery(nearestNeighborQuery);
}
return query;
} else {
throw new UnsupportedOperationException("Unable to read given WKT: " + wkt);
}
}
use of com.vividsolutions.jts.geom.Point in project ddf by codice.
the class SolrFilterDelegate method dwithin.
@Override
public SolrQuery dwithin(String propertyName, String wkt, double distance) {
Geometry geo = getGeometry(wkt);
if (geo != null) {
double distanceInDegrees = metersToDegrees(distance);
if (isPoint(geo)) {
Point pnt = (Point) geo;
String pointRadiusQuery = geoPointToCircleQuery(propertyName, distanceInDegrees, pnt);
updateDistanceSort(propertyName, pnt);
return new SolrQuery(pointRadiusQuery);
} else {
Geometry bufferGeo = geo.buffer(distanceInDegrees, QUADRANT_SEGMENTS);
String bufferWkt = WKT_WRITER.write(bufferGeo);
return operationToQuery(INTERSECTS_OPERATION, propertyName, bufferWkt);
}
} else {
throw new UnsupportedOperationException("Unable to read given WKT: " + wkt);
}
}
use of com.vividsolutions.jts.geom.Point in project ddf by codice.
the class Wfs20JTStoGML321Converter method convertToMultiPointType.
public static MultiPointType convertToMultiPointType(MultiPoint multiPoint, String srsName) {
MultiPointType multiPointType = GML320_OBJECT_FACTORY.createMultiPointType();
for (int i = 0; i < multiPoint.getNumGeometries(); i++) {
Point point = (Point) multiPoint.getGeometryN(i);
PointPropertyType pointPropertyType = GML320_OBJECT_FACTORY.createPointPropertyType();
pointPropertyType.setPoint(convertToPointType(point, srsName));
multiPointType.getPointMember().add(pointPropertyType);
}
multiPointType.setSrsName(srsName);
return multiPointType;
}
use of com.vividsolutions.jts.geom.Point in project ddf by codice.
the class TwitterFilterVisitor method visit.
/**
* Intersects filter maps to a Polygon or BBox Spatial search criteria.
*/
@Override
public Object visit(Intersects filter, Object data) {
LOGGER.trace("ENTERING: Intersects 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 Intersects filter is supported");
}
} else {
LOGGER.warn(ONLY_AND_MSG);
}
LOGGER.trace("EXITING: Intersects filter");
return super.visit(filter, data);
}
use of com.vividsolutions.jts.geom.Point in project ddf by codice.
the class KMLTransformerImpl method createKmlGeo.
private Geometry createKmlGeo(com.vividsolutions.jts.geom.Geometry geo) throws CatalogTransformerException {
Geometry kmlGeo = null;
if (Point.class.getSimpleName().equals(geo.getGeometryType())) {
Point jtsPoint = (Point) geo;
kmlGeo = KmlFactory.createPoint().addToCoordinates(jtsPoint.getX(), jtsPoint.getY());
} else if (LineString.class.getSimpleName().equals(geo.getGeometryType())) {
LineString jtsLS = (LineString) geo;
de.micromata.opengis.kml.v_2_2_0.LineString kmlLS = KmlFactory.createLineString();
List<Coordinate> kmlCoords = kmlLS.createAndSetCoordinates();
for (com.vividsolutions.jts.geom.Coordinate coord : jtsLS.getCoordinates()) {
kmlCoords.add(new Coordinate(coord.x, coord.y));
}
kmlGeo = kmlLS;
} else if (Polygon.class.getSimpleName().equals(geo.getGeometryType())) {
Polygon jtsPoly = (Polygon) geo;
de.micromata.opengis.kml.v_2_2_0.Polygon kmlPoly = KmlFactory.createPolygon();
List<Coordinate> kmlCoords = kmlPoly.createAndSetOuterBoundaryIs().createAndSetLinearRing().createAndSetCoordinates();
for (com.vividsolutions.jts.geom.Coordinate coord : jtsPoly.getCoordinates()) {
kmlCoords.add(new Coordinate(coord.x, coord.y));
}
kmlGeo = kmlPoly;
} else if (geo instanceof GeometryCollection) {
List<Geometry> geos = new ArrayList<Geometry>();
for (int xx = 0; xx < geo.getNumGeometries(); xx++) {
geos.add(createKmlGeo(geo.getGeometryN(xx)));
}
kmlGeo = KmlFactory.createMultiGeometry().withGeometry(geos);
} else {
throw new CatalogTransformerException("Unknown / Unsupported Geometry Type '" + geo.getGeometryType() + "'. Unale to preform KML Transform.");
}
return kmlGeo;
}
Aggregations