use of com.vividsolutions.jts.geom.LineString in project ddf by codice.
the class WfsFilterDelegate method createLineString.
private JAXBElement<LineStringType> createLineString(Geometry geometry) {
JAXBElement<LineStringType> jaxbElement = null;
try {
String gml = Wfs10JTStoGML200Converter.convertGeometryToGML(geometry);
LineStringType lineStringType = (LineStringType) Wfs10JTStoGML200Converter.convertGMLToGeometryType(gml, Wfs10Constants.LINESTRING);
jaxbElement = (JAXBElement<LineStringType>) Wfs10JTStoGML200Converter.convertGeometryTypeToJAXB(lineStringType);
} catch (JAXBException jbe) {
LOGGER.debug("Unable to create LineString with geometry: [{}]", geometry);
}
return jaxbElement;
}
use of com.vividsolutions.jts.geom.LineString 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.geom.LineString in project elasticsearch by elastic.
the class LineStringBuilder method build.
@Override
public Shape build() {
Coordinate[] coordinates = this.coordinates.toArray(new Coordinate[this.coordinates.size()]);
Geometry geometry;
if (wrapdateline) {
ArrayList<LineString> strings = decompose(FACTORY, coordinates, new ArrayList<LineString>());
if (strings.size() == 1) {
geometry = strings.get(0);
} else {
LineString[] linestrings = strings.toArray(new LineString[strings.size()]);
geometry = FACTORY.createMultiLineString(linestrings);
}
} else {
geometry = FACTORY.createLineString(coordinates);
}
return jtsGeometry(geometry);
}
use of com.vividsolutions.jts.geom.LineString in project elasticsearch by elastic.
the class MultiLineStringBuilder method build.
@Override
public Shape build() {
final Geometry geometry;
if (wrapdateline) {
ArrayList<LineString> parts = new ArrayList<>();
for (LineStringBuilder line : lines) {
LineStringBuilder.decompose(FACTORY, line.coordinates(false), parts);
}
if (parts.size() == 1) {
geometry = parts.get(0);
} else {
LineString[] lineStrings = parts.toArray(new LineString[parts.size()]);
geometry = FACTORY.createMultiLineString(lineStrings);
}
} else {
LineString[] lineStrings = new LineString[lines.size()];
Iterator<LineStringBuilder> iterator = lines.iterator();
for (int i = 0; iterator.hasNext(); i++) {
lineStrings[i] = FACTORY.createLineString(iterator.next().coordinates(false));
}
geometry = FACTORY.createMultiLineString(lineStrings);
}
return jtsGeometry(geometry);
}
use of com.vividsolutions.jts.geom.LineString in project elasticsearch by elastic.
the class ShapeBuilderTests method testNewPolygon.
public void testNewPolygon() {
Polygon polygon = ShapeBuilders.newPolygon(new CoordinatesBuilder().coordinate(-45, 30).coordinate(45, 30).coordinate(45, -30).coordinate(-45, -30).coordinate(-45, 30)).toPolygon();
LineString exterior = polygon.getExteriorRing();
assertEquals(exterior.getCoordinateN(0), new Coordinate(-45, 30));
assertEquals(exterior.getCoordinateN(1), new Coordinate(45, 30));
assertEquals(exterior.getCoordinateN(2), new Coordinate(45, -30));
assertEquals(exterior.getCoordinateN(3), new Coordinate(-45, -30));
}
Aggregations