Skip to end of metadata
Go to start of metadata

If the above information is a little overwhelming, don't worry. The following example should help illustrate how this can be accomplished.

Let's look at a simple demo app that allows the user to write a new shapefile from the result of filtering an input shapefile (based on ShapeReader class). This example uses the FeatureStore::addFeatures() method to add Features to a new Shapefile. The Features (in a FeatureReader) that are added to the new shapefile are obtained from a Filter on an existing shapefile.

  • creates a shapefile datastore from the URL and gets out the single feature type in this datastore;
  • here we assume the shapefile contains an attribute named "DI" and we would like to create a new shapefile only for those features that has DI between 100 and 200;
  • next, we will perform the query using the created Filter object;
  • additionally, we could use a Query object to limit the number of features the query returns;
  • finally, create a new ShapefileDataStore and write out the feature query results;

That's it! Hope you enjoy it.

Labels: