use of com.vividsolutions.jts.io.ParseException in project ddf by codice.
the class WfsFilterDelegate method createGeometryOperand.
private JAXBElement<? extends AbstractGeometryType> createGeometryOperand(String wkt) {
String convertedWkt = wkt;
Geometry wktGeometry = null;
try {
wktGeometry = getGeometryFromWkt(convertedWkt);
} catch (ParseException e) {
throw new IllegalArgumentException("Unable to parse WKT Geometry [" + convertedWkt + "]", e);
}
if (wktGeometry instanceof Polygon) {
if (isGeometryOperandSupported(Wfs10Constants.POLYGON)) {
return createPolygon(convertedWkt);
} else {
throw new IllegalArgumentException("The Polygon operand is not supported.");
}
} else if (wktGeometry instanceof Point) {
if (isGeometryOperandSupported(Wfs10Constants.POINT)) {
return createPoint(convertedWkt);
} else {
throw new IllegalArgumentException("The Point operand is not supported.");
}
} else if (wktGeometry instanceof LineString) {
if (isGeometryOperandSupported(Wfs10Constants.LINESTRING)) {
return createLineString(wktGeometry);
} else {
throw new IllegalArgumentException("The LineString operand is not supported.");
}
} else if (wktGeometry instanceof MultiPoint) {
if (isGeometryOperandSupported(Wfs10Constants.MULTI_POINT)) {
return createMultiPoint(wktGeometry);
} else {
throw new IllegalArgumentException("The MultiPoint operand is not supported.");
}
} else if (wktGeometry instanceof MultiLineString) {
if (isGeometryOperandSupported(Wfs10Constants.MULTI_LINESTRING)) {
return createMultiLineString(wktGeometry);
} else {
throw new IllegalArgumentException("The MultiLineString operand is not supported.");
}
} else if (wktGeometry instanceof MultiPolygon) {
if (isGeometryOperandSupported(Wfs10Constants.MULTI_POLYGON)) {
return createMultiPolygon(wktGeometry);
} else {
throw new IllegalArgumentException("The MultiPolygon operand is not supported.");
}
} else if (wktGeometry instanceof GeometryCollection) {
if (isGeometryOperandSupported(Wfs10Constants.GEOMETRY_COLLECTION)) {
return createGeometryCollection(wktGeometry);
} else {
throw new IllegalArgumentException("The GeometryCollection operand is not supported.");
}
}
throw new IllegalArgumentException("Unable to create Geometry from WKT String");
}
use of com.vividsolutions.jts.io.ParseException in project ddf by codice.
the class WfsFilterDelegate method createEnvelopeFromWkt.
private Envelope createEnvelopeFromWkt(String wkt) {
Envelope envelope = null;
try {
Geometry geo = getGeometryFromWkt(wkt);
envelope = geo.getEnvelopeInternal();
} catch (ParseException e) {
throw new IllegalArgumentException("Unable to parse WKT String", e);
}
return envelope;
}
use of com.vividsolutions.jts.io.ParseException in project ddf by codice.
the class WfsFilterDelegate method bufferGeometry.
private String bufferGeometry(String wkt, double distance) {
LOGGER.debug("Buffering WKT {} by distance {} meter(s).", wkt, distance);
String bufferedWkt = null;
try {
Geometry geometry = getGeometryFromWkt(wkt);
double bufferInDegrees = metersToDegrees(distance);
LOGGER.debug("Buffering {} by {} degree(s).", geometry.getClass().getSimpleName(), bufferInDegrees);
Geometry bufferedGeometry = geometry.buffer(bufferInDegrees);
bufferedWkt = new WKTWriter().write(bufferedGeometry);
LOGGER.debug("Buffered WKT: {}.", bufferedWkt);
} catch (ParseException e) {
throw new IllegalArgumentException("Unable to parse WKT String", e);
}
return bufferedWkt;
}
use of com.vividsolutions.jts.io.ParseException in project ddf by codice.
the class WfsFilterDelegate method getCoordinatesFromWkt.
private Coordinate[] getCoordinatesFromWkt(String wkt) {
Coordinate[] coordinates = null;
try {
Geometry geo = getGeometryFromWkt(wkt);
coordinates = geo.getCoordinates();
} catch (ParseException e) {
throw new IllegalArgumentException("Unable to parse WKT String", e);
}
return coordinates;
}
use of com.vividsolutions.jts.io.ParseException in project GeoGig by boundlessgeo.
the class WriteTree2Test method feature.
private Node feature(ObjectDatabase db, String idPrefix, int index) {
final String id = idPrefix + "." + index;
final Feature feature;
try {
feature = super.feature(pointsType, id, id, index, point(index));
} catch (ParseException e) {
throw Throwables.propagate(e);
}
RevFeature revFeature = RevFeatureBuilder.build(feature);
db.put(revFeature);
Envelope bounds = (Envelope) feature.getBounds();
return Node.create(id, revFeature.getId(), ObjectId.NULL, TYPE.FEATURE, bounds);
}
Aggregations