All Implemented Interfaces:
AutoCloseable, ResourceOnFileSystem, StoreResource, DataSet, FeatureSet, Resource, Localized
Direct Known Subclasses:
WritableStore

public class Store extends StaxDataStore implements FeatureSet
A data store backed by GPX files. This store does not cache the feature instances. Any new request for features will re-read from the file.
Since:
0.8
Version:
1.3
  • Field Details

    • version

      Version version
      Version of the GPX file, or null if unknown.
    • metadata

      private org.opengis.metadata.Metadata metadata
      The metadata, or null if not yet parsed.
    • reader

      private Reader reader
      If a reader has been created for parsing the metadata and has not yet been used for iterating over the features, that reader. Otherwise null. Used for continuing XML parsing after metadata header instead of closing and reopening the file.
    • types

      final Types types
      The FeatureType for routes, tracks, way points, etc. Currently always Types.DEFAULT, but we use a field for keeping Reader and Writer ready to handle profiles or extensions.
  • Constructor Details

  • Method Details

    • getFormat

      final org.opengis.metadata.distribution.Format getFormat()
      Returns a more complete description of the GPX format. The format will be part of the metadata returned by getMetadata().
      See Also:
    • getVersion

      public Version getVersion() throws DataStoreException
      Returns the GPX file version.
      Returns:
      the GPX file version, or null if none.
      Throws:
      DataStoreException - if an error occurred while reading the metadata.
    • setVersion

      public void setVersion(Version version) throws DataStoreException
      Sets the version of the file to write.
      Parameters:
      version - the target GPX file format.
      Throws:
      DataStoreException - if an error occurred while setting the format.
    • getMetadata

      public org.opengis.metadata.Metadata getMetadata() throws DataStoreException
      Returns information about the dataset as a whole.
      Specified by:
      getMetadata in interface Resource
      Specified by:
      getMetadata in class DataStore
      Returns:
      information about the dataset, or null if none.
      Throws:
      DataStoreException - if an error occurred while reading the metadata.
      See Also:
    • getEnvelope

      public Optional<org.opengis.geometry.Envelope> getEnvelope() throws DataStoreException
      Returns the spatiotemporal envelope of this resource.
      Specified by:
      getEnvelope in interface DataSet
      Returns:
      the spatiotemporal resource extent.
      Throws:
      DataStoreException - if an error occurred while reading or computing the envelope.
    • getType

      public DefaultFeatureType getType()
      Returns the base type of all GPX types.
      Specified by:
      getType in interface FeatureSet
      Returns:
      base type of all GPX types.
    • getFeatureType

      @Deprecated public DefaultFeatureType getFeatureType(String name) throws IllegalNameException
      Deprecated.
      We are not sure yet if we will keep this method. Decision is pending acquisition of more experience with the API proposed by FeatureSet.
      Returns the feature type for the given name. The name argument should be the result of calling GenericName.toString() on the name of one of the feature types in this data store.
      Parameters:
      name - the name or alias of the feature type to get.
      Returns:
      the feature type of the given name or alias (never null).
      Throws:
      IllegalNameException - if the given name was not found or is ambiguous.
    • features

      public final Stream<AbstractFeature> features(boolean parallel) throws DataStoreException
      Returns the stream of features. This store does not cache the features. Any new iteration over features will re-read from the file. The XML file is kept open until the feature stream is closed; callers should not modify the file while an iteration is in progress.
      Specified by:
      features in interface FeatureSet
      Parameters:
      parallel - ignored in current implementation.
      Returns:
      a stream over all features in the XML file.
      Throws:
      DataStoreException - if an error occurred while creating the feature stream.
    • closeReader

      final void closeReader() throws Exception
      Closes only the reader, without closing this store. This method may be invoked before write operation.
      Throws:
      Exception
    • close

      public void close() throws DataStoreException
      Closes this data store and releases any underlying resources.
      Specified by:
      close in interface AutoCloseable
      Overrides:
      close in class StaxDataStore
      Throws:
      DataStoreException - if an error occurred while closing this data store.
      See Also: