I'm running into some trouble writing features I get from a wfs server 
to a local shapefile.

I've read through the csv2shp and the query lab example pages.

I have a collection of features from:

   FeatureCollection<SimpleFeatureType, SimpleFeature> features = 
dataStore.getFeatureSource( dataStore.getTypeNames()[0] ).getFeatures( 
query );

I build a ShapefileDataStore and createSchema using the schema I get 
from the dataStore.getSchema( dataStore.getTypeNames()[0] )

when I add my FeatureCollection to the ShapefileDataStore I get an 
IndexOutOfBoundsException.

org.geotools.data.DataSourceException: Could not create MapunitPoly out 
of provided feature: 459154
     at 
org.geotools.data.AbstractFeatureStore.addFeatures(AbstractFeatureStore.java:266)
     at WFSExample4.writeToShpFile(WFSExample4.java:206)
     at WFSExample4.dataAccess(WFSExample4.java:172)
     at WFSExample4.main(WFSExample4.java:73)
Caused by: java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
     at java.util.ArrayList.RangeCheck(Unknown Source)
     at java.util.ArrayList.get(Unknown Source)
     at 
org.geotools.feature.simple.SimpleFeatureImpl.setAttributes(SimpleFeatureImpl.java:203)
     at 
org.geotools.data.AbstractFeatureStore.addFeatures(AbstractFeatureStore.java:264)
     ... 3 more


I've found that if I iterate through the FeatureCollection and call 
getType on one of the individual features and then use that to set the 
schema on the ShapefileDataStore
that I can then store the features.  I've verified that they do indeed 
go out to disk and the shapes look right but all the attribute names are 
null and the additional attributes aren't present.

Why doesn't the schema in the individual features match the schema 
reported from the wfs dataStore?

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to