From: <svn...@os...> - 2012-06-21 01:43:27
|
Author: jive Date: 2012-06-20 18:43:21 -0700 (Wed, 20 Jun 2012) New Revision: 38823 Modified: trunk/docs/user/library/data/featuresource.rst Log: update code examples for FeatureStore addFeature Modified: trunk/docs/user/library/data/featuresource.rst =================================================================== --- trunk/docs/user/library/data/featuresource.rst 2012-06-21 01:43:08 UTC (rev 38822) +++ trunk/docs/user/library/data/featuresource.rst 2012-06-21 01:43:21 UTC (rev 38823) @@ -157,26 +157,13 @@ Adding Data ''''''''''' -Adding features can be done in the following manner.:: - - Transaction transaction = new Transaction("Example1"); - SimpleFeatureStore store = (SimpleFeatureStore) dataStore.getFeatureSource( typeName ); - store.setTransaction( transaction ); - - SimpleFeatureType featureType = store.getFeatureType(); - - SimpleFeatureCollection collection = FeatureCollections.newInstance(); - collection.add( featureType.create( new Object[]{ geom1, "hello" } ) ); - collection.add( featureType.create( new Object[]{ geom2, "hello" } ) ); - - try { - store.addFeatures( collection ); - transaction.commit(); // actually writes out the features in one go - } - catch( Exception eek){ - transaction.rollback(); - } +Adding features can be done in the following manner.: +.. literalinclude:: /../src/main/java/org/geotools/data/SimpleFeatureStoreExamples.java + :language: java + :start-after: // addExample start + :end-before: // addExample end + Hints: * If addFeatures is really slow you probably forgot to use a Transaction! @@ -201,8 +188,8 @@ .. literalinclude:: /../src/main/java/org/geotools/data/SimpleFeatureStoreExamples.java :language: java - :start-after: // addExample start - :end-before: // addExample end + :start-after: // addFeatureIdExample start + :end-before: // addFeatureIdExample end FeatureID are assigned during the commit process. While we make an attempt to determine an appropriate ID prior to commit we ask that you wait until commit() is finished before |