Class RawRasterStore
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.esri.RasterStore
org.apache.sis.internal.storage.esri.RawRasterStore
- All Implemented Interfaces:
AutoCloseable,ResourceOnFileSystem,StoreResource,DataSet,GridCoverageResource,Resource,Localized
Data store implementation for BIL, BIP, and BSQ raster files.
Sample values are provided in a raw binary files, without compression.
Information about image layout is provided in a separated text files.
- Since:
- 1.2
- Version:
- 1.3
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.sis.internal.storage.PRJDataStore
PRJDataStore.AuxiliaryContent, PRJDataStore.Provider -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final StringNumber of bytes to skip between band.private static final StringKeyword for the number of bytes per band per row.private static final StringKeyword for the byte order: I = Intel; M = Motorola.private static final org.opengis.referencing.datum.PixelInCellThe "cell center" versus "cell corner" interpretation of translation coefficients.private ChannelDataInputThe object to use for reading data, ornullif the channel has been closed.private static final StringKeyword for the sample model: BIL, BIP or BSQ.private static final StringKeyword for the number of bands.private static final StringKeyword for the number of bits per sample: 1, 4, 8, 16, 32.private static final StringKeyword for the value to replace by NaN.private static final StringKeyword for the type of integers (signed or unsigned).private RawRasterReaderHelper method for reading a rectangular region from the input stream.private static final StringKeyword for the offset in the stream of the first byte to read.private static final StringKeyword for the total number of bytes in a row.private static final StringKeyword for the x-axis coordinate of the center of the upper left pixel.private static final StringKeyword for the y-axis coordinate of the center of the upper left pixel.(package private) static final StringKeyword for the pixel size in the x-axis dimension.(package private) static final StringKeyword for the pixel size in the y-axis dimension.Fields inherited from class org.apache.sis.internal.storage.esri.RasterStore
CLR, metadata, NCOLS, nodataValue, NROWS, STXFields inherited from class org.apache.sis.internal.storage.PRJDataStore
crs, encoding, PRJFields inherited from class org.apache.sis.internal.storage.URIDataStore
location -
Constructor Summary
ConstructorsConstructorDescriptionRawRasterStore(RawRasterStoreProvider provider, StorageConnector connector) Creates a new raw raster store from the given file or URL. -
Method Summary
Modifier and TypeMethodDescriptionprivate StringReturns an error message saying that the file cannot be read.voidclose()Closes this data store and releases any underlying resources.private Errorserrors()Returns localized resources for warnings an error messages.Path[]Returns the URIDataStore.location as aPathcomponent together with auxiliary files.Returns the valid extent of grid coordinates together with the conversion from those grid coordinates to real world coordinates.org.opengis.metadata.MetadataReturns the metadata associated to the raw binary file.Returns the ranges of sample values.private voidignoredProperty(String keyword, int value) Sends a warning if a property was specified in the header file but has been ignored by this data store.private intReturns the index ofvaluein thealternativesarray, or -1 if not found.private DataStoreContentExceptionmissingProperty(PRJDataStore.AuxiliaryContent header, String keyword) Returns the exception to throw for a missing property in the header file.private intparseStrictlyPositive(String keyword, String value) Parses the given string as a strictly positive integer.read(GridGeometry domain, int... ranges) Loads the data.private voidReads the"*.hdr"and"*.prj"files.Methods inherited from class org.apache.sis.internal.storage.esri.RasterStore
createCoverage, createMetadata, loadBandDescriptionsMethods 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.GridCoverageResource
getLoadingStrategy, getResolutions, setLoadingStrategy, subsetMethods inherited from interface org.apache.sis.storage.Resource
addListener, getIdentifier, removeListener
-
Field Details
-
NBANDS
Keyword for the number of bands. Default value is 1.- See Also:
-
NBITS
Keyword for the number of bits per sample: 1, 4, 8, 16, 32. Default value is 8.- See Also:
-
PIXELTYPE
Keyword for the type of integers (signed or unsigned). Value can beSIGNEDINTfor signed integers. Default value is unsigned integers.- See Also:
-
BYTEORDER
Keyword for the byte order: I = Intel; M = Motorola. Default value is the byte order of host machine.- See Also:
-
LAYOUT
Keyword for the sample model: BIL, BIP or BSQ. Default value isRawRasterLayout.BIL.- See Also:
-
SKIPBYTES
Keyword for the offset in the stream of the first byte to read. Default value is 0.- See Also:
-
BANDROWBYTES
Keyword for the number of bytes per band per row. This is used only withRawRasterLayout.BIL. Default value is (NCOLS x NBITS) / 8 rounded up.- See Also:
-
TOTALROWBYTES
Keyword for the total number of bytes in a row. Default value depends on the layout:RawRasterLayout.BIL: (NBANDS x BANDROWBYTES)RawRasterLayout.BIP: (BANDS x NCOLS x NBITS) / 8 rounded up
- See Also:
-
BANDGAPBYTES
Number of bytes to skip between band. This is used only withRawRasterLayout.BSQ. Default value is 0. -
ULXMAP
Keyword for the x-axis coordinate of the center of the upper left pixel. Default value is 0.- See Also:
-
ULYMAP
Keyword for the y-axis coordinate of the center of the upper left pixel. Default value is NROWS - 1.- See Also:
-
XDIM
Keyword for the pixel size in the x-axis dimension. Default value is 1.- See Also:
-
YDIM
Keyword for the pixel size in the y-axis dimension. Default value is 1.- See Also:
-
NODATA
Keyword for the value to replace by NaN. This is not documented in the ESRI specification but used in practice.- See Also:
-
CELL_ANCHOR
private static final org.opengis.referencing.datum.PixelInCell CELL_ANCHORThe "cell center" versus "cell corner" interpretation of translation coefficients. The ESRI specification said that the coefficients map to pixel center. -
input
The object to use for reading data, ornullif the channel has been closed. -
reader
Helper method for reading a rectangular region from the input stream. This is created when the header is parsed, because its depends on the type of data. A non-null value is used as a sentinel value meaning that the header has been read.
-
-
Constructor Details
-
RawRasterStore
RawRasterStore(RawRasterStoreProvider provider, StorageConnector connector) throws DataStoreException Creates a new raw raster store from the given file or URL.- Parameters:
provider- the factory that created thisDataStoreinstance, ornullif unspecified.connector- information about the storage (file, URL, etc).- Throws:
DataStoreException- if an error occurred while closing unused streams.
-
-
Method Details
-
getComponentFiles
Returns the URIDataStore.location as aPathcomponent together with auxiliary files.- Specified by:
getComponentFilesin interfaceResourceOnFileSystem- Overrides:
getComponentFilesin classRasterStore- Returns:
- the main file and auxiliary files as paths, or an empty array if unknown.
- Throws:
DataStoreException- if the URI cannot be converted to aPath.
-
getMetadata
Returns the metadata associated to the raw binary file.- Specified by:
getMetadatain interfaceResource- Specified by:
getMetadatain classDataStore- Returns:
- the metadata associated to the raw binary.
- Throws:
DataStoreException- if an error occurred during the parsing process.- See Also:
-
getGridGeometry
Returns the valid extent of grid coordinates together with the conversion from those grid coordinates to real world coordinates.- Returns:
- extent of grid coordinates together with their mapping to "real world" coordinates.
- Throws:
DataStoreException- if an error occurred while reading definitions from the underlying data store.- See Also:
-
getSampleDimensions
Returns the ranges of sample values.- Specified by:
getSampleDimensionsin interfaceGridCoverageResource- Overrides:
getSampleDimensionsin classRasterStore- Returns:
- ranges of sample values.
- Throws:
DataStoreException- if an error occurred while reading definitions from the underlying data store.- See Also:
-
errors
Returns localized resources for warnings an error messages. -
missingProperty
private DataStoreContentException missingProperty(PRJDataStore.AuxiliaryContent header, String keyword) Returns the exception to throw for a missing property in the header file.- Parameters:
header- the header to parse.keyword- the missing keyword.- Returns:
- the exception to throw.
-
ignoredProperty
Sends a warning if a property was specified in the header file but has been ignored by this data store.- Parameters:
keyword- keyword of the potentially ignored property.value- the specified value, or 0 if it is the default value.
-
indexOf
Returns the index ofvaluein thealternativesarray, or -1 if not found. The comparison ignore cases. If the value is not found in the array, a warning message is emitted.- Parameters:
keyword- the keyword (used in case a warning message is emitted).value- the value to search.alternatives- valid values.- Returns:
- index of
valuein thealternativesarray, or -1 if not found.
-
parseStrictlyPositive
Parses the given string as a strictly positive integer.- Parameters:
keyword- the keyword (used in case a warning message is emitted).value- the value to parse as an unsigned integer.- Returns:
- the parsed value, guaranteed greater than zero.
- Throws:
DataStoreContentException
-
readHeader
Reads the"*.hdr"and"*.prj"files. After a successful return,readeris guaranteed non-null.Note: we don't do this initialization in the constructor for giving a chance for users to register listeners first.
- Throws:
IOException- if the auxiliary file cannot be found or read.DataStoreException- if the auxiliary file cannot be parsed.RasterFormatException- if the number of bits or the signed/unsigned property is invalid.ArithmeticException- if image size of pixel/line/band stride is too large.IllegalArgumentException- ifSampleModelconstructor rejects some argument values.
-
read
Loads the data.- Parameters:
domain- desired grid extent and resolution, ornullfor reading the whole domain.ranges- indices of bands to load.- Returns:
- the grid coverage for the specified domain.
- Throws:
DataStoreException- if an error occurred while reading the grid coverage data.
-
canNotRead
Returns an error message saying that the file cannot be read. -
close
Closes this data store and releases any underlying resources.- Specified by:
closein interfaceAutoCloseable- Overrides:
closein classRasterStore- Throws:
DataStoreException- if an error occurred while closing this data store.- See Also:
-