Class WorldFileStore
java.lang.Object
org.apache.sis.storage.DataStore
org.apache.sis.internal.storage.URIDataStore
org.apache.sis.internal.storage.PRJDataStore
org.apache.sis.internal.storage.image.WorldFileStore
- All Implemented Interfaces:
AutoCloseable,ResourceOnFileSystem,StoreResource,Resource,Localized
A data store which creates grid coverages from Image I/O readers using World File convention.
Georeferencing is defined by two auxiliary files having the same name than the image file but different suffixes:
- A text file containing the coefficients of the affine transform mapping pixel coordinates to geodesic coordinates.
The reader expects one coefficient per line, in the same order than the order expected by the
AffineTransform(double[])constructor, which is scaleX, shearY, shearX, scaleY, translateX, translateY. The reader looks for a file having the following suffixes, in preference order:- The first letter of the image file extension, followed by the last letter of
the image file extension, followed by
'w'. Example:"tfw"for"tiff"images, and"jgw"for"jpeg"images. - The extension of the image file with a
'w'appended. - The
"wld"extension.
- The first letter of the image file extension, followed by the last letter of
the image file extension, followed by
- A text file containing the Coordinate Reference System (CRS) definition
in Well Known Text (WKT) syntax.
The reader looks for a file having the
".prj"extension.
Type of input objects
TheStorageConnector input should be an instance of the following types:
Path, File, URL or URI.
Other types such as ImageInputStream are also accepted but in those cases the auxiliary files cannot be read.
For any input of unknown type, this data store first checks if an ImageReader accepts the input type directly.
If none is found, this data store tries to create an input stream
from the input object.
The storage input object may also be an ImageReader instance ready for use
(i.e. with its input set to a non-null value).
In that case, this data store will use the given image reader as-is.
The image reader will be disposed
and its input closed (if AutoCloseable) when this data store is closed.
Handling of multi-image files
Because some image formats can store an arbitrary number of images, this data store is considered as an aggregate with one resource per image. All image should have the same size and all resources will share the sameGridGeometry.
However, this base class does not implement the Aggregate interface directly in order to
give a chance to subclasses to implement GridCoverageResource directly when the format
is known to support only one image per file.- Since:
- 1.2
- Version:
- 1.3
- Author:
- Martin Desruisseaux (Geomatys)
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.sis.internal.storage.PRJDataStore
PRJDataStore.AuxiliaryContent, PRJDataStore.Provider -
Field Summary
Fields inherited from class org.apache.sis.internal.storage.PRJDataStore
crs, encoding, PRJFields inherited from class org.apache.sis.internal.storage.URIDataStore
location -
Constructor Summary
ConstructorsConstructorDescriptionWorldFileStore(WorldFileStoreProvider provider, StorageConnector connector) Creates a new store from the given file, URL or stream. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this data store and releases any underlying resources.Collection<? extends GridCoverageResource> Returns all images in this store.Path[]Returns paths to the main file together with auxiliary files.String[]getImageFormat(boolean asMimeType) Returns the Image I/O format names or MIME types of the image read by this data store.org.opengis.metadata.MetadataReturns information about the data store as a whole.Methods inherited from class org.apache.sis.internal.storage.PRJDataStore
deleteAuxiliaryFile, getOpenParameters, listComponentFiles, readAuxiliaryFile, readPRJ, writeAuxiliaryFile, writePRJMethods inherited from class org.apache.sis.internal.storage.URIDataStore
addTitleOrIdentifier, getIdentifier, getOriginator, getSpecifiedPath, location, parametersMethods inherited from class org.apache.sis.storage.DataStore
addListener, findResource, getDisplayName, getLocale, getNativeMetadata, getProvider, removeListener, setLocale, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.sis.storage.Resource
addListener, removeListener
-
Constructor Details
-
WorldFileStore
public WorldFileStore(WorldFileStoreProvider provider, StorageConnector connector) throws DataStoreException, IOException Creates a new store from the given file, URL or stream.- Parameters:
provider- the factory that created thisDataStoreinstance, ornullif unspecified.connector- information about the storage (URL, stream, etc).- Throws:
DataStoreException- if an error occurred while opening the stream.IOException- if an error occurred while creating the image reader instance.
-
-
Method Details
-
getImageFormat
Returns the Image I/O format names or MIME types of the image read by this data store. More than one names may be returned if the format has aliases or if the MIME type has legacy types (e.g. official"image/png"and legacy"image/x-png").- Parameters:
asMimeType-truefor MIME types, orfalsefor format names.- Returns:
- the requested names, or an empty array if none or unknown.
-
getComponentFiles
Returns paths to the main file together with auxiliary files.- Specified by:
getComponentFilesin interfaceResourceOnFileSystem- Overrides:
getComponentFilesin classPRJDataStore- Returns:
- paths to the main file and auxiliary files, or an empty array if unknown.
- Throws:
DataStoreException- if the URI cannot be converted to aPath.
-
getMetadata
Returns information about the data store as a whole.- Specified by:
getMetadatain interfaceResource- Specified by:
getMetadatain classDataStore- Returns:
- information about resources in the data store. Should not be
null. - Throws:
DataStoreException- if an error occurred while reading the metadata.- See Also:
-
components
Returns all images in this store. Note that fetching the size of the list is a potentially costly operation.- Returns:
- list of images in this store.
- Throws:
DataStoreException
-
close
Closes this data store and releases any underlying resources.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein classDataStore- Throws:
DataStoreException- if an error occurred while closing this data store.- See Also:
-