getFeatureWriter method failing
-------------------------------

                 Key: GEOT-2619
                 URL: http://jira.codehaus.org/browse/GEOT-2619
             Project: GeoTools
          Issue Type: Bug
    Affects Versions: 2.5.4
         Environment: Using Windows Vista SP1/SP2 & 7RC. Java version 1.6.0_14.
            Reporter: Fabrice


Here is the problem : i'm working on a town generator. So using pre-existing 
data such as town shapes, river or roads, i must create realistic village maps. 
I'm working on the roads right now, and for most of the villages I'm working 
on, there are no data about the roads. So I have to create them myself. What I 
want to do is create new features and add them to my MapLayer, so that I can 
display them to see if there are good or not. But when I try to add new 
features to my layer, I get this error :

"
java.lang.UnsupportedOperationException: Schema creation not supported
   at 
org.geotools.data.AbstractDataStore.getFeatureWriter(AbstractDataStore.java:207)
   at 
org.geotools.data.TransactionStateDiff.applyDiff(TransactionStateDiff.java:197)
   at 
org.geotools.data.TransactionStateDiff.commit(TransactionStateDiff.java:151)
   at org.geotools.data.DefaultTransaction.commit(DefaultTransaction.java:182)
   at 
msi.sig.towngenerator.shapelab.ShapeTools.ajouterSurLayer(ShapeTools.java:193)
   at msi.sig.towngenerator.generator.Generator.genereRoutes(Generator.java:386)
   at msi.sig.towngenerator.generator.Generator.readCommune(Generator.java:189)
"

I don't really understanf what it means, since I think I've already checked if 
the layer was editable or not. Here is the code I run:

"
public static void ajouterSurLayer(Geometry geometry, MapLayer layer)
   {
       FeatureStore store;

         SimpleFeatureType featureType = (SimpleFeatureType) 
layer.getFeatureSource().getSchema();

                     Object[] values = new 
Object[featureType.getAttributeCount()];

           AttributeDescriptor geomAttribut = 
featureType.getGeometryDescriptor();
           List<AttributeDescriptor> attributes = 
featureType.getAttributeDescriptors();

                     for (int i = 0,  max = attributes.size(); i < max; i++) {
               AttributeDescriptor oneAttribut = attributes.get(i);

                             if (oneAttribut.equals(geomAttribut)) {
                   values[i] = geometry;
               } else {
                   values[i] = oneAttribut.getDefaultValue();
               }
           }

                     SimpleFeature myFeature = 
SimpleFeatureBuilder.build(featureType, values, null);

           FeatureCollection lstFeatures = FeatureCollections.newCollection();
           lstFeatures.add(myFeature);

             if (layer.getFeatureSource() instanceof FeatureStore) {
           store = (FeatureStore) layer.getFeatureSource();

           DefaultTransaction transaction = new DefaultTransaction();
           store.setTransaction(transaction);

                     try {
               store.addFeatures(lstFeatures);
               transaction.commit();                          } catch 
(Exception ex) {
               ex.printStackTrace();
               try {
                   store.getTransaction().rollback();
               } catch (IOException e) {
                   e.printStackTrace();
               }
           }finally{
               transaction.close();
           }
       }
   }
" 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to