Friday, November 16, 2012

FeatureCollection cleanup

The FeatureCollection cleanup proposal is now complete. The first batch of work went into the GeoTools 8.0 release, this second phase removes several methods from FeatureCollection. These methods were not widely implemented, and as a result not adopted by client code.
Upgrade instructions are available: As part of this work Andrea provided an extensive review of the existing FeatureCollection implementations and a number of utility methods have been introduced to make working with features easier:
  • DataUtilities.visit( FeatureCollection, FeatureVisitor, ProgerssListener )
  • DataUtilities.bounds( FeatureCollection ) // Already existed
  • DataUtilities.bounds( FeatureIterator )
  • DataUtilities.count( FeatureCollection )
  • DataUtilities.count( FeatureIterator )
  • DataUtilities.close( Iterator )
  • DataUtilities.first( SimpleFeatureCollection ): SimpleFeature
  • DataUtilities.first( FeatureCollection ): F
  • DataUtilities.list( FeatureCollection ): List  // Already existed 
  • DataUtilities.list( FeatureCollection, int ): List
  • DataUtilities.iterator( FeatureIterator ): Iterator // also Closable 
  • DataUtilities.collectionCast( FeatureCollection ): Collection
For additional information, and an overview of the FeatureCollection implementations please review the detailed change proposal.
If you cannot make the transition today:
  • A milestone 9.0-M0 release has been deployed to maven. 
  • To switch your maven pom.xml over to 9.0-M0:
  • You can use this milestone release as a rest area until you have time to upgrade.
One of the joys of working on a large stable project such as GeoTools is the gradual change of pace, and the careful planning that goes into keeping projects working together:
  • The initial GeoTools 2.0 rewrite provided a clear FeatureResults API acting in a fashion similar to a JDBC ResultSet.
  • GeoTools 2.1 introduced FeatureCollection as a superclass of FeatureResults, bringing in the java.util.Collection methods being removed today. This was motivated by an amusing Bring Back FeatureCollection rant from our founder James MacGill - well we tried James and it was a bad idea.
  • The transition to Java 5 forced us to remove direct use of the java.util.Collection interface, however we kept the methods for backwards compatibility. It was too easy to introduce a resource leak with the Java 5 for-each syntax:
for( Feature feature : featureCollection ){
    System.out.println( feature.getID() );
  • With todays change GeoTools programs are ready for the Java 7 try-with-resource syntax as shown below:
try( FeatureIterator iter=featureCollection.features() ){
   while( iter.hasNext() ){
        Feature feature =;
        System.out.println( feature.getID() );


andrea chiu said...

Being Beautiful, doesn't make you smile, doesn't make you happy, doesn't make you nice. Being nice and happy and always smiling makes you beautiful.Thanks for sharing your article , you can also visit my site for more information. Have a good day!

Leslie Lim said...

Wow. Awesome article. Please do more articles like this in the future. Very informational and knowledgeable. I will expect more from you in the future. For now i will just bookmark your page and surely I'm gonna come back later to read more. Thank you to the writer!


Perfect Loan said...

Do you need a loan?
Do you need a loan to pay off your debt?
Do you have bad credit?
Do you need a loan construction or to invest?
Do u you need loan to start doing business?
are Granting you personal loan, Business loan, mortgage loan,
Construction loan, Debt loan, Student loan, Auto loan, e.t.c.
Loan at any currency are range from $5,000 ''min'' to $100,000.000 ''max'' @ 2% interest rate
If you are interested kindly send
response to: { }
*Full Name/Company Name:_________
*loan amount:_________
*Loan duration:_________
*Purpose of loan:_________
*Monthly Income:__________
*Next of kin :_________
*Email :_________
Best Regard

Post a Comment