Class WritableStore
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.AsciiGridStore
org.apache.sis.internal.storage.esri.WritableStore
- All Implemented Interfaces:
AutoCloseable
,ResourceOnFileSystem
,StoreResource
,DataSet
,GridCoverageResource
,Resource
,WritableGridCoverageResource
,Localized
An ASCII Grid store with writing capabilities.
- 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
Nested classes/interfaces inherited from interface org.apache.sis.storage.WritableGridCoverageResource
WritableGridCoverageResource.CommonOption, WritableGridCoverageResource.Option
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final String
The line separator for writing the ASCII file.private ChannelDataOutput
The output if this store is write-only, ornull
if this store is read/write.Fields inherited from class org.apache.sis.internal.storage.esri.AsciiGridStore
CELLSIZE, CELLSIZES, NODATA_VALUE, XLLCENTER, XLLCORNER, YLLCENTER, YLLCORNER
Fields inherited from class org.apache.sis.internal.storage.esri.RasterStore
CLR, metadata, NCOLS, nodataValue, NROWS, STX
Fields inherited from class org.apache.sis.internal.storage.PRJDataStore
crs, encoding, PRJ
Fields inherited from class org.apache.sis.internal.storage.URIDataStore
location
-
Constructor Summary
ConstructorsConstructorDescriptionWritableStore
(AsciiGridStoreProvider provider, StorageConnector connector) Creates a new ASCII Grid store from the given file, URL or stream. -
Method Summary
Modifier and TypeMethodDescription(package private) boolean
canReadOrWrite
(boolean write) Returns whether this store can read or write.void
close()
Closes this data store and releases any underlying resources.private static double
distanceFromIntegers
(org.opengis.referencing.operation.MathTransform gridToCRS) Returns an estimation of how close the "CRS to grid" transform is to integer values.private static SequenceType
getAffineCoefficients
(Map<String, Object> header, GridGeometry gg, WritableResourceSupport h) Gets the coefficients of the affine transform.private static void
write
(CharSequence text, ChannelDataOutput out) Writes the given text to the output.void
write
(GridCoverage coverage, WritableGridCoverageResource.Option... options) Writes a new coverage in the data store for this resource.private void
writeHeader
(Map<String, Object> header, ChannelDataOutput out) Writes the content of the given map as the header of ASCII Grid file.Methods inherited from class org.apache.sis.internal.storage.esri.AsciiGridStore
closeOnError, getGridGeometry, getMetadata, getSampleDimensions, input, read, setCoverage
Methods inherited from class org.apache.sis.internal.storage.esri.RasterStore
createCoverage, createMetadata, getComponentFiles, loadBandDescriptions
Methods inherited from class org.apache.sis.internal.storage.PRJDataStore
deleteAuxiliaryFile, getOpenParameters, listComponentFiles, readAuxiliaryFile, readPRJ, writeAuxiliaryFile, writePRJ
Methods inherited from class org.apache.sis.internal.storage.URIDataStore
addTitleOrIdentifier, getIdentifier, getOriginator, getSpecifiedPath, location, parameters
Methods inherited from class org.apache.sis.storage.DataStore
addListener, findResource, getDisplayName, getLocale, getNativeMetadata, getProvider, 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.DataSet
getEnvelope
Methods inherited from interface org.apache.sis.storage.GridCoverageResource
getGridGeometry, getLoadingStrategy, getResolutions, getSampleDimensions, read, setLoadingStrategy, subset
Methods inherited from interface org.apache.sis.storage.Resource
addListener, getIdentifier, getMetadata, removeListener
-
Field Details
-
lineSeparator
The line separator for writing the ASCII file. -
output
The output if this store is write-only, ornull
if this store is read/write. This is set tonull
when the store is closed.
-
-
Constructor Details
-
WritableStore
public WritableStore(AsciiGridStoreProvider provider, StorageConnector connector) throws DataStoreException Creates a new ASCII Grid store from the given file, URL or stream.- Parameters:
provider
- the factory that created thisDataStore
instance, ornull
if unspecified.connector
- information about the storage (URL, stream, etc).- Throws:
DataStoreException
- if an error occurred while opening the stream.
-
-
Method Details
-
canReadOrWrite
boolean canReadOrWrite(boolean write) Returns whether this store can read or write.- Overrides:
canReadOrWrite
in classAsciiGridStore
- Parameters:
write
-false
for testing read capability, ortrue
for testing write capability.
-
distanceFromIntegers
private static double distanceFromIntegers(org.opengis.referencing.operation.MathTransform gridToCRS) throws org.opengis.referencing.operation.TransformException Returns an estimation of how close the "CRS to grid" transform is to integer values. This is used for choosing whether to map pixel centers or pixel centers.- Throws:
org.opengis.referencing.operation.TransformException
-
getAffineCoefficients
private static SequenceType getAffineCoefficients(Map<String, Object> header, GridGeometry gg, WritableResourceSupport h) throws DataStoreExceptionGets the coefficients of the affine transform.- Parameters:
header
- the map where to put the affine transform coefficients.gg
- the grid geometry from which to get the affine transform.h
- set of helper methods.- Returns:
- the iteration order (e.g. from left to right, then top to bottom).
- Throws:
DataStoreException
- if the header cannot be written.
-
writeHeader
Writes the content of the given map as the header of ASCII Grid file.- Throws:
IOException
-
write
public void write(GridCoverage coverage, WritableGridCoverageResource.Option... options) throws DataStoreException Writes a new coverage in the data store for this resource. If a coverage already exists for this resource, then it will be overwritten only if theTRUNCATE
orUPDATE
option is specified.- Specified by:
write
in interfaceWritableGridCoverageResource
- Parameters:
coverage
- new data to write in the data store for this resource.options
- configuration of the write operation.- Throws:
DataStoreException
- if an error occurred while writing data in the underlying data store.
-
write
Writes the given text to the output. All characters must be US-ASCII (this is not verified).- Throws:
IOException
-
close
Closes this data store and releases any underlying resources.- Specified by:
close
in interfaceAutoCloseable
- Overrides:
close
in classAsciiGridStore
- Throws:
DataStoreException
- if an error occurred while closing this data store.- See Also:
-