We are importing a Multi-Polygon Shapefile with 3D coordinates into oracle spatial using JTS Geometry Suite, GeoTools (ShapefileDataStore) and Hibernate Spatial. In Oracle Spatial we want them to be stored in 2D.
The onyl (and very slow) approach I found is the following, using WKBWriter and WKBReader:
private static Geometry convert2D(Geometry geometry3D) {
// create a 2D WKBWriter
WKBWriter writer = new WKBWriter(2);
byte[] binary = writer.write(geometry3D);
WKBReader reader = new WKBReader(factory);
Geometry geometry2D= null;
try {
geometry2D= reader.read(binary);
} catch (ParseException e) {
log.error("error reading wkb", e);
}
return geometry2D;
}
Does anybody know a more efficient way to convert a geometry from 3D to 2D?