Upgrade to 2.2

Upgrade to 2.3

Upgrade to 2.4

The following is needed when upgrading to 2.3:

Transition to FeatureCollection

FeatureResults was deprecated for the 2.1 release, and it is passing out
of existence for 2.3. All methods were deprecated and their
replacements documented.

Before (GeoTools 2.1 Code)

public example(FeatureSource featureSource) throws IOException ){
    FeatureResults results = featureSource.getFeatures();
    int count = results.getCount();
    FeatureCollection collection = results.collection();

    FeatureReader reader = results.reader();
    try {
         while( reader.hasNext() ){
             Feature feature = reader.next();             
         }
    }
    finally {
        reader.close();
    }
}

Quick Alternative (GeoTools 2.3 Code)

    FeatureCollection results = featureSource.getFeatures();
    int count = results.size();
    FeatureCollection collection = results;

    FeatureIterator reader = results.features();
    try {
         while( reader.hasNext() ){
             Feature feature = reader.next();             
         }
    }
    finally {
        reader.close();
    }
}
  1. Search and replace:
  2. Transition to:

You may need to remove IOException handling code.

Recommended Alternative (GeoTools 2.x Code)

You can also transition directly to use of java.util.Iterator; this will put you in better standing for the transition to GeoAPI FeatureCollection.

    Iterator reader = results.iterator();
    try {
         while( reader.hasNext() ){
             Feature feature = (Feature) reader.next();             
         }
    }
    finally {
        results.close( reader );
    }
}
  1. Transition to Iterator

Transition to GridCoverageRenderer

It seems we did not meet our guidlines here and the GridCoveargeAPI has been moved and completly changed!

BEFORE (GeoTools 2.2 code)

import org.geotools.renderer.lite.GridCoverageRenderer;
...
GridCoverageRenderer renderer = new GridCoverageRenderer(gc, crs);

renderer.paint(graphics);

AFTER (GeoTools 2.3 code)

import org.geotools.renderer.lite.gridcoverage2d.GridCoverageRenderer;
...
GridCoverageRenderer renderer = new GridCoverageRenderer( viewportCRS, imageAreaBBox, paintArea );

StyleFactory factory = CommonFactoryFinder.getStyleFactory(null);
RasterSymbolizer rasterSymbolizer = factory.createRasterSymbolizer();
                  
renderer.paint( destination, gc, rasterSymbolizer );