Property Plugin

DataStore supporting the use of simple java property files for storing spatial data. This was originally based on a tutorial in the use of AbstractDataStore, but has now been migrated to use ContentDataStore. The old implementation has been moved to the unsupported module.

Reference

Maven:

<dependency>
   <groupId>org.geotools</groupId>
   <artifactId>gt-property</artifactId>
   <version>${geotools.version}</version>
 </dependency>

Example

The property datastore works with a custom format based on Java property files:

_=id:Integer,geom:Geometry,name:String
rd1=1|wkt|road one
rd2=2|wkt|road two

These examples use the file example.properties.

_=id:Integer,name:String,geom:Point
fid1=1|jody garnett|POINT(0 0)
fid2=2|brent|POINT(10 10)
fid3=3|dave|POINT(20 20)
fid4=4|justin deolivera|POINT(30 30)

Here is an example to parse the above file:

        Map<String, Serializable> params = new HashMap<>();
        params.put("directory", directory);
        DataStore datastore = DataStoreFinder.getDataStore(params);

        Query query = new Query("example");
        try (FeatureReader<SimpleFeatureType, SimpleFeature> reader =
                datastore.getFeatureReader(query, Transaction.AUTO_COMMIT)) {
            int count = 0;
            while (reader.hasNext()) {
                SimpleFeature feature = reader.next();
                System.out.println("feature " + count + ": " + feature.getID());
                count++;
            }
            System.out.println("read in " + count + " features");
        }