GeoTools : Migrate shapefile to shapefile-ng






Clean up shapefile store implementation



The current shapefile datastore is based on AbstractDataStore, a base class that while not deprecated, is not favoured either for new implementation (the new reference being ContentDataStore). The current implementation is brittle and harder than it should be to maintain, and it's also based on two stores, the plain and indexed ones, that were never merged togheter, effectively duplicating the effort to maintain the code.

The current shapefile-ng module, in unsupported, is based on ContentDataStore instead, providing a set of advantages:

  • the base class is actively maintained and improved
  • cleaner implementation, with less classes, less duplication, better leveraging what the base library has to offer
  • tidied up set of constructors, smaller public interface, with behavior variants exposed as properties
  • cleaner package structure
  • several unused classes removed
  • unit tests migrated to JUnit 4
  • small performance improvements in the non indexed case (useful when reading from read only media or remote locations)
The change only affected the upper level, whilst the code reading shp/dbf/shx/fix/qix files has remained largely untouched.
Migration wise, there are a few cases depending on how much the client code is linked to the shapefile data store specific methods:
  • if the code creates the shapefile store by using either the factory or the DataStoreFinder no changes are needed, as the same parameters are exposed in the two stores
  • if the code manually creates the shapefile store using its constructors, changes will be required as the new code has a single constructor with the shapefile URL, and all other parameters are provided via setters instead
  • if the code uses methods specific to ShapefileDataStore some renames of the methods being called are in order


This proposal is open for discussion and voting.

Current voting status:


This section is used to make sure your proposal is complete (did you remember documentation?) and has enough paid or volunteer time lined up to be a success


no progress






lack mandate/funds/time


volunteer needed

  1. (tick) Rename gt-shapefile plugin as shapefile-old in unsupported land
  2. (tick) Move shapefile-ng to plugins/shapefile
  3. (tick) Transition any direct use of ShapefileDataStore to use of factory (done)
  4. Fix up the user guide upgrade instructions using BEFORE / AFTER examples as shown below
  5. Initial pull request

API Changes

Using ShapefileDataStore directly


ShapefileDataStore store = new ShapefileDataStore(url, new URI("theNamespace"), /*memoryMapped*/ true);



ShapefileDataStore store = new ShapefileDataStore(url);
store.setNamespace(new URI("theNamespace"));