Hi,
I get an exception when I try to create shapefiles with geometries loaded
from an Oracle Spatial database.
1) I fetch a geometry with hibernate spatial and use the type MultiPolygon
...
@Column(name="GEOM")
@Type(type = "org.hibernate.spatial.GeometryType")
public MultiPolygon getGeom() {
return this.Geom;
}
...
2) Then I try to store the geometry as a shapefile, I adapapted the example
Java code for this:
SimpleFeatureType schema = feature.getFeatureType();
CoordinateReferenceSystem dataCRS =
schema.getCoordinateReferenceSystem();
CoordinateReferenceSystem worldCRS = CRS.decode(epsg);
DataStoreFactorySpi factory = new ShapefileDataStoreFactory();
Map<String, Serializable> create = new HashMap<String,
Serializable>();
create.put("url", url);
create.put("create spatial index", Boolean.TRUE);
DataStore dataStore = factory.createNewDataStore(create);
SimpleFeatureType featureType =
SimpleFeatureTypeBuilder.retype(schema, worldCRS);
dataStore.createSchema(featureType);
Transaction transaction = new DefaultTransaction("Reproject");
FeatureWriter<SimpleFeatureType, SimpleFeature> writer
=
dataStore.getFeatureWriterAppend(featureType.getTypeName(), transaction);
try {
SimpleFeature copy = writer.next();
copy.setAttributes(feature.getAttributes());
Geometry geometry = (Geometry) feature.getDefaultGeometry();
Geometry outputGeometry = transformGeometry(geometry,
dataCRS, worldCRS, true);
copy.setDefaultGeometry(outputGeometry);
writer.write();
transaction.commit();
}
3) But I get an exception from the SimpleFeatureBuilder
org.geotools.data.DataSourceException: Cannot create a shape file whose
geometry type is class com.vividsolutions.jts.geom.Geometry
What can I do about this? I expected that com.vividsolutions.jts.geom.Geometry
should work.
Regards,
Andreas
------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today.
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users