I'm trying to use a WFS layer as a template to create a shapefile with no features, and add that file as a map layer.

That shapefile would later be used for storing features from the very same WFS source.

The problem I'm facing is that the shapefile is only created on disk when adding features, not when doing createSchema() to the associated DataStore.

I've tried the following. In this example, layer is a WFS layer, of type ILayer.

FileDataStoreFactorySpi factory = new IndexedShapefileDataStoreFactory();
       File file = new File("c:/test.shp");
       HashMap<String, URL> map = new HashMap<String, URL>();
       map.put(IndexedShapefileDataStoreFactory.URLP.key, file.toURL());
       DataStore myData = factory.createNewDataStore(map);
       FeatureSource featureSource = layer.getResource(FeatureSource.class,
               monitor);
       FeatureType ft = featureSource.getSchema();
       myData.createSchema(ft);
       FeatureStore store = (FeatureStore) ((ShapefileDataStore) myData)
               .getFeatureSource(); /* Return to caller, used later */

After this, when I start adding features to store, then the shapefile gets created.

That is contrary to what happens with the example at "Creating a new Shapefile" at http://docs.codehaus.org/display/GEOTDOC/Shapefile+Plugin , where after executing myData.createSchema( featureType ), SHP appears.

Is it the WFS featuresource that makes a difference here? Or am I overlooking something?

TIA,

Janne

_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel

Reply via email to