Skip to content

Commit

Permalink
update code examples for FeatureStore addFeature
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/geotools/trunk@38823 e5c1c795-43da-0310-a71f-fac65c449510
  • Loading branch information
jive committed Jun 21, 2012
1 parent 7489fe7 commit c706fab
Showing 1 changed file with 8 additions and 21 deletions.
29 changes: 8 additions & 21 deletions docs/user/library/data/featuresource.rst
Expand Up @@ -157,25 +157,12 @@ some data types like WFS only allow you to edit when you have a Transaction.::
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:

Expand All @@ -201,8 +188,8 @@ Hints:

.. 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
Expand Down

0 comments on commit c706fab

Please sign in to comment.