private final Geometry cloneGeometryLCS(Geometry geom) { if (geom instanceof LineString) return cloneGeometryLCS( (LineString) geom); else if (geom instanceof Polygon) return cloneGeometryLCS( (Polygon) geom); else if (geom instanceof Point) return cloneGeometryLCS( (Point) geom); else return cloneGeometryLCS( (GeometryCollection) geom); }
/** * changes this to a new CSF -- more efficient than the JTS way * @param geom */ private final Geometry cloneGeometryLCS(Polygon geom) { LinearRing lr = (LinearRing) cloneGeometryLCS((LinearRing) geom.getExteriorRing()); LinearRing[] rings = new LinearRing[geom.getNumInteriorRing()]; for (int t=0;t<rings.length;t++) { rings[t] = (LinearRing) cloneGeometryLCS((LinearRing) geom.getInteriorRingN(t)); } return getGeometryFactory().createPolygon(lr,rings ); } private final Geometry cloneGeometryLCS(Point geom)
private final Geometry cloneGeometryLCS(GeometryCollection geom) { if (geom.getNumGeometries() == 0) { Geometry[] gs = new Geometry[0]; return getGeometryFactory().createGeometryCollection(gs); } ArrayList gs = new ArrayList(geom.getNumGeometries() ); int n =geom.getNumGeometries(); for (int t=0;t<n;t++) { gs.add(t, cloneGeometryLCS(geom.getGeometryN(t)) ); } return getGeometryFactory().buildGeometry(gs); }
else if (geom.getFactory().getCoordinateSequenceFactory() instanceof LiteCoordinateSequenceFactory) this.geometry = cloneGeometryLCS(geom); // optimized version else this.geometry = cloneGeometry(geom);