Hello:

I am just learning how to use GeoTools, and have been working with an 
example file someone sent me. The file had some runtime issues, so I've 
been rewriting it and in the process, found some documentation errors:

FeatureResults.collection() refers to a way to the following:

*public* FeatureCollection collection() *throws* IOException {
    FeatureCollection collection = FeatureCollections.newCollection()
    *for* (FeatureReader r = reader(); r.hasNext();) {
        collection.add( r.next() );
    }
    *return* collection;  }


This would not compile for me, and I found the following issues while 
researching it:

FeatureResults.reader() suggests using FeatureCollections.features() 
which doesn't exists. It should be FeatureCollection.features(), which 
returns a FeatureIterator, not a FeatureReader as referred to in the 
original example. With all this in mind, I rewrote the original example 
to be:

     public FeatureCollection myCollection() throws IOException {
         FeatureCollection collection = FeatureCollections.newCollection();
         FeatureIterator iterator = collection.features();
         while (iterator.hasNext()) {
             collection.add( iterator.next() );
         }
         return collection; 
     }

I believe this is correct, and will update files where necessary if you 
concur.

Best regards,

Amy Johnson


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to