Class WritableStore

All Implemented Interfaces:
AutoCloseable, ResourceOnFileSystem, StoreResource, DataSet, GridCoverageResource, Resource, WritableGridCoverageResource, Localized

final class WritableStore extends AsciiGridStore implements WritableGridCoverageResource
An ASCII Grid store with writing capabilities.
Since:
1.2
Version:
1.3
  • Field Details

    • lineSeparator

      private final String lineSeparator
      The line separator for writing the ASCII file.
    • output

      private ChannelDataOutput output
      The output if this store is write-only, or null if this store is read/write. This is set to null 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 this DataStore instance, or null 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 class AsciiGridStore
      Parameters:
      write - false for testing read capability, or true 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 DataStoreException
      Gets 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

      private void writeHeader(Map<String,Object> header, ChannelDataOutput out) throws IOException
      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 the TRUNCATE or UPDATE option is specified.
      Specified by:
      write in interface WritableGridCoverageResource
      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

      private static void write(CharSequence text, ChannelDataOutput out) throws IOException
      Writes the given text to the output. All characters must be US-ASCII (this is not verified).
      Throws:
      IOException
    • close

      public void close() throws DataStoreException
      Closes this data store and releases any underlying resources.
      Specified by:
      close in interface AutoCloseable
      Overrides:
      close in class AsciiGridStore
      Throws:
      DataStoreException - if an error occurred while closing this data store.
      See Also: