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.ProviderNested classes/interfaces inherited from interface org.apache.sis.storage.WritableGridCoverageResource
WritableGridCoverageResource.CommonOption, WritableGridCoverageResource.Option -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final StringThe line separator for writing the ASCII file.private ChannelDataOutputThe output if this store is write-only, ornullif this store is read/write.Fields inherited from class org.apache.sis.internal.storage.esri.AsciiGridStore
CELLSIZE, CELLSIZES, NODATA_VALUE, XLLCENTER, XLLCORNER, YLLCENTER, YLLCORNERFields 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
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) booleancanReadOrWrite(boolean write) Returns whether this store can read or write.voidclose()Closes this data store and releases any underlying resources.private static doubledistanceFromIntegers(org.opengis.referencing.operation.MathTransform gridToCRS) Returns an estimation of how close the "CRS to grid" transform is to integer values.private static SequenceTypegetAffineCoefficients(Map<String, Object> header, GridGeometry gg, WritableResourceSupport h) Gets the coefficients of the affine transform.private static voidwrite(CharSequence text, ChannelDataOutput out) Writes the given text to the output.voidwrite(GridCoverage coverage, WritableGridCoverageResource.Option... options) Writes a new coverage in the data store for this resource.private voidwriteHeader(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, setCoverageMethods inherited from class org.apache.sis.internal.storage.esri.RasterStore
createCoverage, createMetadata, getComponentFiles, 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.DataSet
getEnvelopeMethods inherited from interface org.apache.sis.storage.GridCoverageResource
getGridGeometry, getLoadingStrategy, getResolutions, getSampleDimensions, read, setLoadingStrategy, subsetMethods 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, ornullif this store is read/write. This is set tonullwhen 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 thisDataStoreinstance, ornullif 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:
canReadOrWritein classAsciiGridStore- Parameters:
write-falsefor testing read capability, ortruefor 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 theTRUNCATEorUPDATEoption is specified.- Specified by:
writein 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:
closein interfaceAutoCloseable- Overrides:
closein classAsciiGridStore- Throws:
DataStoreException- if an error occurred while closing this data store.- See Also:
-