Hi
I made a geojson2shape and shape2geojson java class translators...
They work for single Points, but for LineString and Polygons, the shape
file is created and I can see the geometries in ArcMap, but when I
translate the file back to geojson it seems that the class
org.geotools.data.shapefile.indexed.IndexedShapefileDataStore
reads the shp as Polygon but the geometryClass and geometryType created
are com.vividsolutions.jts.geom.MultiPolygon,
although when I create the SimpleFeatureType I create it as a
com.vividsolutions.jts.geom.Polygon.class
The shape file has 4 geometries, all Polygons but no MultiPolygons...
I read the shape file and identify the Geometry type with this code:
FeatureSource featureSource =
store.getFeatureSource();
FeatureCollection featColl =
featureSource.getFeatures();
FeatureType featType = featColl.getSchema();
//only used to define the CRS
FeatureIterator featIt = featColl.features();
while (featIt.hasNext()){
feature = featIt.next();
Collection collValues =
feature.getValue();
Iterator collIt =
collValues.iterator();
while
(collIt.hasNext()){
Object obj0
= collIt.next();
Attribute
attribute = (Attribute)obj0;
if
(attribute.getName().toString().trim().equals("the_geom")){
if (attribute.getValue() instanceof
XX...identifyGeometryTypeHere...XXX){
handleMyGeometryTypeXXX(attribute.getValue())
}
}
}
}
The attribute "the_geom" should have a value of Polygon but the value is
a MultiPolygon in this case...
It seems that ShapeFileDataStore wraps each Feature in a MultiPolygon
and adds the Polygon to it.
So, instead of reading 4 features, each one a Polygon, it reads 4
MultiPolygons, each one with a Polygon inside.
LineString has the same behaviour...
Can anybody confirm my version or tell me that the problem is with my
code instead?
Thanks,
Jose Lopes
------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit. See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users