Hello all

I would like to propose the following modifications to the Shapefile reader:

 * Rename as ShapefileStore for consistency with NetcdfStore.
 * Declare ShapefileStore as a subclass of DataStore:
     o Implement the getMetadata() method using the information
       currently stored in fields like version, xmin, xmax, etc.
 * Turn public fields into private fields instead.
 * Add a getEnvelope(Query) method which returns the (xmin, ymin, etc.)
   values.
     o The Query argument would be an empty class for now, but still
       defined as a placeholder for future developments.
 * Add a getFeatures(Query) method which returns a FeatureCollection
   (extends Collection<Feature>).


To explain more about the last point: the intend is to be able to read large set of Features without loading all of them in memory. So instead than storing all Features in a HashMap, we would allow implementations to return a collection backed by an iterator instantiating the Features on the fly. Such Iterator is the same idea than java.sql.ResultSet.

Using a method instead than direct to a public field has two purposes:

 * Allows to specify a filter or other query aspects.
 * Allows to returns an Autocloseable collection for implementations
   that perform their I/O operations on the fly.


So instead of iterating on features like below:

   for (Feature f : shapefile.FeatureMap.values()) {
        // ... do some stuff ...
   }


We would do:

   try (FeatureCollection features = shapefile.getFeatures(myQuery)) {
        for (Feature f : features) {
            // ... do some stuff ...
        }
   }


What do peoples think?

    Martin

Reply via email to