use of com.vividsolutions.jts.geom.LineString 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.LineString in project ddf by codice.
the class Wfs20JTStoGML321Converter method convertToPolygonType.
public static PolygonType convertToPolygonType(Polygon polygon, String srsName) {
PolygonType polygonType = GML320_OBJECT_FACTORY.createPolygonType();
//exterior
LineString lineString = polygon.getExteriorRing();
LinearRing linearRing = lineString.getFactory().createLinearRing(lineString.getCoordinateSequence());
RingType ringType = convertToRingType(linearRing, srsName);
JAXBElement<RingType> ringTypeJAXBElement = GML320_OBJECT_FACTORY.createRing(ringType);
AbstractRingPropertyType abstractRingPropertyType = GML320_OBJECT_FACTORY.createAbstractRingPropertyType();
abstractRingPropertyType.setAbstractRing(ringTypeJAXBElement);
polygonType.setExterior(abstractRingPropertyType);
//interiors
for (int i = 0; i < polygon.getNumInteriorRing(); i++) {
LineString interiorRingN = polygon.getInteriorRingN(i);
LinearRing linearRing1 = interiorRingN.getFactory().createLinearRing(interiorRingN.getCoordinateSequence());
RingType ringType1 = convertToRingType(linearRing1, srsName);
JAXBElement<RingType> ringTypeJAXBElement1 = GML320_OBJECT_FACTORY.createRing(ringType1);
AbstractRingPropertyType abstractRingPropertyType1 = GML320_OBJECT_FACTORY.createAbstractRingPropertyType();
abstractRingPropertyType1.setAbstractRing(ringTypeJAXBElement1);
polygonType.getInterior().add(abstractRingPropertyType1);
}
polygonType.setSrsName(srsName);
return polygonType;
}
use of com.vividsolutions.jts.geom.LineString 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.LineString in project ddf by codice.
the class TestWfs10JTStoGML200Converter method testGMLToLineStringType.
@Test
public void testGMLToLineStringType() throws JAXBException, SAXException, IOException, ParseException, NullPointerException {
LineString lineString = (LineString) getGeometryFromWkt(LINESTRING);
assertThat(lineString == null, is(Boolean.FALSE));
String lineStringGML = Wfs10JTStoGML200Converter.convertGeometryToGML(lineString);
LineStringType lineStringType = (LineStringType) Wfs10JTStoGML200Converter.convertGMLToGeometryType(lineStringGML, Wfs10Constants.LINESTRING);
assertThat(Wfs10Constants.LINESTRING.getLocalPart().equals(lineStringType.getJAXBElementName().getLocalPart()), is(Boolean.TRUE));
String coords = lineStringType.getCoordinates().getValue().replaceAll("\n", "").trim();
assertThat(coords.isEmpty(), is(Boolean.FALSE));
assertThat(LINESTRING_COORDS.equals(coords), is(Boolean.TRUE));
}
use of com.vividsolutions.jts.geom.LineString in project ddf by codice.
the class TestWfs10JTStoGML200Converter method testGeometryToLineStringGML.
@Test
public void testGeometryToLineStringGML() throws JAXBException, SAXException, IOException, ParseException, NullPointerException {
LineString lineString = (LineString) getGeometryFromWkt(LINESTRING);
assertThat(lineString == null, is(Boolean.FALSE));
String lineStringGML = Wfs10JTStoGML200Converter.convertGeometryToGML(lineString).replaceAll("\n", "").trim();
assertThat(StringUtils.isEmpty(lineStringGML), is(Boolean.FALSE));
Diff diff = XMLUnit.compareXML(lineStringGML, LINESTRING_GML);
assertTrue(XMLUNIT_SIMILAR, diff.similar());
assertTrue(XMLUNIT_IDENTICAL, diff.identical());
}
Aggregations