use of org.geotoolkit.geometry.isoonjts.spatialschema.geometry.JTSGeometry in project geotoolkit by Geomatys.
the class JTSCurve method computeJTSPeer.
/**
* {@inheritDoc }
*/
@Override
protected org.locationtech.jts.geom.Geometry computeJTSPeer() {
// For each segment that comprises us, get the JTS peer.
int n = curveSegments.size();
ArrayList allCoords = new ArrayList();
for (int i = 0; i < n; i++) {
JTSGeometry g = (JTSGeometry) curveSegments.get(i);
org.locationtech.jts.geom.LineString jts = (org.locationtech.jts.geom.LineString) g.getJTSGeometry();
int m = jts.getNumPoints();
for (int j = 0; j < m; j++) {
allCoords.add(jts.getCoordinateN(j));
}
if (i != (n - 1))
allCoords.remove(allCoords.size() - 1);
}
org.locationtech.jts.geom.Coordinate[] coords = new org.locationtech.jts.geom.Coordinate[allCoords.size()];
allCoords.toArray(coords);
return JTSUtils.GEOMETRY_FACTORY.createLineString(coords);
}
use of org.geotoolkit.geometry.isoonjts.spatialschema.geometry.JTSGeometry in project geotoolkit by Geomatys.
the class JTSMultiPolygon method computeJTSPeer.
/**
* {@inheritDoc }
*/
@Override
protected org.locationtech.jts.geom.Geometry computeJTSPeer() {
List<org.locationtech.jts.geom.Geometry> childParts = new ArrayList<org.locationtech.jts.geom.Geometry>();
for (Polygon prim : elements) {
if (prim instanceof JTSGeometry) {
JTSGeometry jtsGeom = (JTSGeometry) prim;
childParts.add(jtsGeom.getJTSGeometry());
} else {
throw new IllegalStateException("Only JTSGeometries are allowed in the JTSMultiPolygon class.");
}
}
// we want a multi geometry event if there is only one geometry
if (childParts.size() == 1) {
org.locationtech.jts.geom.Geometry geom = childParts.get(0);
if (geom instanceof org.locationtech.jts.geom.Polygon) {
return JTSUtils.GEOMETRY_FACTORY.createMultiPolygon(new org.locationtech.jts.geom.Polygon[] { (org.locationtech.jts.geom.Polygon) geom });
}
}
return JTSUtils.GEOMETRY_FACTORY.buildGeometry(childParts);
}
use of org.geotoolkit.geometry.isoonjts.spatialschema.geometry.JTSGeometry in project geotoolkit by Geomatys.
the class JTSSurface method computeJTSPeer.
/**
* {@inheritDoc }
*/
@Override
protected org.locationtech.jts.geom.Geometry computeJTSPeer() {
if (patches.size() > 1) {
// throw new UnsupportedOperationException("This implementation does not support surfaces with multiple patches.");
final org.locationtech.jts.geom.Polygon[] polygons = new org.locationtech.jts.geom.Polygon[patches.size()];
for (int i = 0; i < patches.size(); i++) {
final JTSGeometry jtsGeometry = (JTSGeometry) patches.get(i);
polygons[i] = (org.locationtech.jts.geom.Polygon) jtsGeometry.getJTSGeometry();
}
return JTSUtils.GEOMETRY_FACTORY.createMultiPolygon(polygons);
}
return ((JTSGeometry) patches.get(0)).getJTSGeometry();
}
Aggregations