Hello,

I am trying to copy the data from the SDE server to the local shapefiles.
The problem is: it does not store the geometry.

I know that the problem lies in naming the geometry field. In my SDE server
the geometry field is named 'SHAPE' while geotools always looks up for
'the_geom'.
For me it looks like a bug in geotools, but I might be wrong of course.

I use geotools 12.1 with Java 8.

Here is my method that creates the shapefile datastore based on the source
datastore definition.

private ShapefileDataStore createShapefileDataStore(File shapefileWorkspace,
SimpleFeatureType sourceFeatureType) throws IOException {
        // the following file is not created, it is used here to get the
proper URL for the workspace factory
        String shapefileName = sourceFeatureType.getName().getLocalPart();
        shapefileName = shapefileName.toUpperCase();
        File newFile = new File(shapefileWorkspace, shapefileName + ".shp");

        ShapefileDataStoreFactory dataStoreFactory = new
ShapefileDataStoreFactory();
        Map<String, Serializable> params = new HashMap<String,
Serializable>();
        params.put(ShapefileDataStoreFactory.URLP.key,
newFile.toURI().toURL());
        params.put(ShapefileDataStoreFactory.CREATE_SPATIAL_INDEX.key,
Boolean.FALSE);
        params.put(ShapefileDataStoreFactory.DBFCHARSET.key,
CHARACTER_ENCODING);
        
        ShapefileDataStore newDataStore = (ShapefileDataStore)
dataStoreFactory.createNewDataStore(params);
        newDataStore.createSchema(sourceFeatureType);*//HERE IS THE PROBLEM*
        
        return newDataStore;
    }

The problem lies where I put the comment. The sourceFeatureType looks like
this:
SimpleFeatureTypeImpl KIER_LINES identified extends
Feature(NRW:NRW,IS_REAL:IS_REAL,SHAPE:SHAPE)

while the schema after the indicated line in newDataStore looks like this:
SimpleFeatureTypeImpl KIER_LINES identified extends
lineFeature(the_geom:MultiLineString,NRW:NRW,IS_REAL:IS_REAL)

This causes, that when the features are copied from the source to the
destination, the shape is ignored because the featureWriter looks for the
field 'the_geom' instead of 'SHAPE' and thus setting null as geometry.
This is done in the file ContentFeatureStore.java at line 278 (at least for
geotools 12.1 stable release).

I would be grateful for any help here 



--
View this message in context: 
http://osgeo-org.1560.x6.nabble.com/Exporting-data-to-SHP-ignores-the-geometry-tp5185002.html
Sent from the geotools-gt2-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to