Is the type MultiPolygon not supported?
Which type do I have to use in order to store a 'multi part polygon' in a
shapefile?
Regards,
Andreas
2014/1/17 Andrea Aime <andrea.a...@geo-solutions.it>
> On Fri, Jan 17, 2014 at 9:56 AM, Andreas Bergmann
> <bergmann...@gmail.com>wrote:
>
>> 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.
>>
>
> A shapefile can only contain a single type of geometry, so you have to
> specify which one you're going to use,
> either point, line or polygon. "Geometry" implies you can store any type
> of geometry in the column, something
> that a spatial database can do, but a shapefile cannot.
>
> Cheers
> Andrea
>
> --
> == Our support, Your Success! Visit http://opensdi.geo-solutions.it for
> more information ==
>
> Ing. Andrea Aime
> @geowolf
> Technical Lead
>
> GeoSolutions S.A.S.
> Via Poggio alle Viti 1187
> 55054 Massarosa (LU)
> Italy
> phone: +39 0584 962313
> fax: +39 0584 1660272
> mob: +39 339 8844549
>
> http://www.geo-solutions.it
> http://twitter.com/geosolutions_it
>
> -------------------------------------------------------
>
------------------------------------------------------------------------------
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