Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

...

FeatureCollection Add

With the FeatureCollection.add method being removed, you will need to use an explicit instance that supports adding content.

BEFORE:

 

Code Block
SimpleFeatureCollection features = FeatureCollections.newCollection();

for( SimpleFeature feature : list ){
   features.add( feature );
}

 

AFTER:

Code Block
DefaultFeatureCollection features = new DefaultFeatureCollection();
for( SimpleFeature feature : list ){
   features.add( feature );
}

ALTERNATE (will throw exception if FeatureColleciton does not implement java.util.Collection )

Code Block
Collection<SimpleFeature> collection = DataUtilities.collectionCast( featureCollection );
collection.addAll( list );

ALTERNATE DETAIL:

Code Block
SimpleFeatureCollection features = FeatureCollections.newCollection();
if( features instanceof Collection ){
    Collection<SimpleFeature> collection = (Collection) features;
    collection.addAll( list );
}
else {
    throw new IllegalStateException("FeatureCollections configured with immutbale implementation");
}

 

FeatureCollection Iterator

The deprecated FeatureCollection.iterator() method is no longer available, please use FeatureCollection.features() as shown below.

BEFORE:

Code Block
Iterator i=featureCollection.iterator();
try {
    while( i.hasNext(); ){
       SimpleFeature feature = i.next();
       ...
    }
}
finally {
    featureCollection.close( i );
}

AFTER:

Code Block
FeatureIterator i=featureCollection.features();
try {
     while( i.hasNext(); ){
         SimpleFeature feature = i.next();
         ...
     }
}
finally {
     i.close();
}

JAVA7 (using try-with-resource):

Code Block
try ( FeatureIterator i=featureCollection.features()){
    while( i.hasNext() ){
         SimpleFeature feature = i.next();
         ...
    }
}

 

...