Class Store
java.lang.Object
org.apache.sis.storage.DataStore
org.apache.sis.internal.storage.URIDataStore
org.apache.sis.internal.storage.xml.stream.StaxDataStore
org.apache.sis.internal.storage.gpx.Store
- All Implemented Interfaces:
AutoCloseable
,ResourceOnFileSystem
,StoreResource
,DataSet
,FeatureSet
,Resource
,Localized
- Direct Known Subclasses:
WritableStore
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
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.sis.internal.storage.URIDataStore
URIDataStore.Provider
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate org.opengis.metadata.Metadata
The metadata, ornull
if not yet parsed.private Reader
If a reader has been created for parsing the metadata and has not yet been used for iterating over the features, that reader.(package private) final Types
TheFeatureType
for routes, tracks, way points, etc.(package private) Version
Version of the GPX file, ornull
if unknown.Fields inherited from class org.apache.sis.internal.storage.xml.stream.StaxDataStore
encoding, locale, timezone
Fields inherited from class org.apache.sis.internal.storage.URIDataStore
location
-
Constructor Summary
ConstructorsConstructorDescriptionStore
(StoreProvider provider, StorageConnector connector) Creates a new GPX store from the given file, URL or stream object. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes this data store and releases any underlying resources.(package private) final void
Closes only the reader, without closing this store.final Stream
<AbstractFeature> features
(boolean parallel) Returns the stream of features.Optional
<org.opengis.geometry.Envelope> Returns the spatiotemporal envelope of this resource.getFeatureType
(String name) Deprecated.We are not sure yet if we will keep this method.(package private) final org.opengis.metadata.distribution.Format
Returns a more complete description of the GPX format.org.opengis.metadata.Metadata
Returns information about the dataset as a whole.getType()
Returns the base type of all GPX types.Returns the GPX file version.void
setVersion
(Version version) Sets the version of the file to write.Methods inherited from class org.apache.sis.internal.storage.xml.stream.StaxDataStore
getFormatName, getProvider
Methods inherited from class org.apache.sis.internal.storage.URIDataStore
addTitleOrIdentifier, getComponentFiles, getIdentifier, getOpenParameters, getOriginator, getSpecifiedPath, location, parameters
Methods inherited from class org.apache.sis.storage.DataStore
addListener, findResource, getDisplayName, getLocale, getNativeMetadata, removeListener, setLocale, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.sis.storage.FeatureSet
subset
Methods inherited from interface org.apache.sis.storage.Resource
addListener, getIdentifier, removeListener
-
Field Details
-
version
Version versionVersion of the GPX file, ornull
if unknown. -
metadata
private org.opengis.metadata.Metadata metadataThe metadata, ornull
if not yet parsed. -
reader
If a reader has been created for parsing the metadata and has not yet been used for iterating over the features, that reader. Otherwisenull
. Used for continuing XML parsing after metadata header instead of closing and reopening the file. -
types
TheFeatureType
for routes, tracks, way points, etc. Currently alwaysTypes.DEFAULT
, but we use a field for keepingReader
andWriter
ready to handle profiles or extensions.
-
-
Constructor Details
-
Store
Creates a new GPX store from the given file, URL or stream object. This constructor invokesStorageConnector.closeAllExcept(Object)
, keeping open only the needed resource.- Parameters:
provider
- the provider of this data store, ornull
if unspecified.connector
- information about the storage (URL, stream, etc).- Throws:
DataStoreException
- if an error occurred while opening the GPX file.
-
-
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 bygetMetadata()
.- See Also:
-
getVersion
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
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
Returns information about the dataset as a whole.- Specified by:
getMetadata
in interfaceResource
- Specified by:
getMetadata
in classDataStore
- Returns:
- information about the dataset, or
null
if none. - Throws:
DataStoreException
- if an error occurred while reading the metadata.- See Also:
-
getEnvelope
Returns the spatiotemporal envelope of this resource.- Specified by:
getEnvelope
in interfaceDataSet
- Returns:
- the spatiotemporal resource extent.
- Throws:
DataStoreException
- if an error occurred while reading or computing the envelope.
-
getType
Returns the base type of all GPX types.- Specified by:
getType
in interfaceFeatureSet
- Returns:
- base type of all GPX types.
-
getFeatureType
Deprecated.We are not sure yet if we will keep this method. Decision is pending acquisition of more experience with the API proposed byFeatureSet
.Returns the feature type for the given name. Thename
argument should be the result of callingGenericName.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
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 interfaceFeatureSet
- 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
Closes only the reader, without closing this store. This method may be invoked before write operation.- Throws:
Exception
-
close
Closes this data store and releases any underlying resources.- Specified by:
close
in interfaceAutoCloseable
- Overrides:
close
in classStaxDataStore
- Throws:
DataStoreException
- if an error occurred while closing this data store.- See Also:
-