migrate shapefile to shapefile ng - STEMLab/geotools GitHub Wiki
-
Contact: AndreaAime
-
Tracker: GEOT-4444
-
Tagline: Clean up shapefile store implementation
Description
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
Status
This proposal is open for discussion and voting.
Current voting status:
- Andrea Aime +1
- Ben Caradoc-Davies +1
- Christian Mueller +1
- Ian Turton +1
- Justin Deoliveira +1
- Jody Garnett +1
- Simone Giannecchini +1
Tasks
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
-
:white_check_mark: Rename gt-shapefile plugin as shapefile-old in unsupported land
-
:white_check_mark: Move shapefile-ng to plugins/shapefile
-
:white_check_mark: Transition any direct use of ShapefileDataStore to use of factory (done)
-
Fix up the user guide upgrade instructions using BEFORE / AFTER examples as shown below\
-
Initial pull request https://github.com/geotools/geotools/pull/176
API Changes
Using ShapefileDataStore directly
BEFORE:
ShapefileDataStore store = new ShapefileDataStore(url, new URI("theNamespace"), /*memoryMapped*/ true);
store.setStringCharset(...);
store.setDbfTimeZone(...);
AFTER:
ShapefileDataStore store = new ShapefileDataStore(url);
store.setNamespace(new URI("theNamespace"));
store.setMemoryMapped(true);
store.setCharset(...);
store.setTimeZone(...);