Class DatumShiftGridLoader
java.lang.Object
org.apache.sis.internal.referencing.provider.DatumShiftGridLoader
- Direct Known Subclasses:
NADCON.Loader
,NTv2.Loader
Base class of datum shift grid loaders.
- Since:
- 0.7
- Version:
- 1.1
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) final ByteBuffer
The buffer to use for transferring data from the channel.private final ReadableByteChannel
The channel opened on the file.private static final AtomicBoolean
Whether the tip about the location of datum shift files has been logged.(package private) static final double
Conversion factor from degrees to seconds.(package private) final Path
The file to load, used for parameter declaration and if we have errors to report.(package private) static final double
Possible precision for offset values in seconds of angle. -
Constructor Summary
ConstructorsConstructorDescriptionDatumShiftGridLoader
(ReadableByteChannel channel, ByteBuffer buffer, Path file) Creates a new loader for the given channel and an existing buffer. -
Method Summary
Modifier and TypeMethodDescription(package private) static org.opengis.util.FactoryException
canNotLoad
(String format, Path file, Exception cause) Creates the exception to thrown when the provider failed to load the grid file.(package private) final void
ensureBufferContains
(int n) Makes sure that the buffer contains at least n remaining bytes.(package private) static void
Logs the given record.(package private) final void
skip
(int n) Skips exactly n bytes.(package private) static void
startLoading
(Class<?> caller, Object file) Logs a message about a grid which is about to be loaded.
-
Field Details
-
DEGREES_TO_SECONDS
static final double DEGREES_TO_SECONDSConversion factor from degrees to seconds.- See Also:
-
SECOND_PRECISION
static final double SECOND_PRECISIONPossible precision for offset values in seconds of angle. This value is used only as a hint when attempting to compress the grid in arrays ofshort
values. It does not hurt if this value is wrong, as it will only cause the grid to not be compressed.Some interesting values:
- 1E-4 is about 3 millimetres on Earth.
- 1E-6 matches the precision found in ASCII outputs of NADCON grids.
- 1E-7 is about 1 ULP of 1 second of angle.
- See Also:
-
file
The file to load, used for parameter declaration and if we have errors to report. -
channel
The channel opened on the file. -
buffer
The buffer to use for transferring data from the channel. -
datumDirectoryLogged
Whether the tip about the location of datum shift files has been logged. We log this tip only once, and only if we failed to load at least one grid.
-
-
Constructor Details
-
DatumShiftGridLoader
DatumShiftGridLoader(ReadableByteChannel channel, ByteBuffer buffer, Path file) throws IOException Creates a new loader for the given channel and an existing buffer.- Parameters:
channel
- where to read data from.buffer
- the buffer to use.file
- path to the longitude or latitude difference file. Used for parameter declaration and error reporting.- Throws:
IOException
-
-
Method Details
-
ensureBufferContains
Makes sure that the buffer contains at least n remaining bytes. It is caller's responsibility to ensure that the given number of bytes is not greater than the buffer capacity.- Parameters:
n
- the minimal number of bytes needed in the buffer.- Throws:
EOFException
- if the channel has reached the end of stream.IOException
- if another kind of error occurred while reading.
-
skip
Skips exactly n bytes.- Throws:
IOException
-
startLoading
Logs a message about a grid which is about to be loaded. -
log
Logs the given record.- Parameters:
caller
- the provider to logs as the source class. the source method will be set to"createMathTransform"
.record
- the record to log.
-
canNotLoad
Creates the exception to thrown when the provider failed to load the grid file.- Parameters:
format
- the format name (e.g. "NTv2" or "NADCON").file
- the grid file that the subclass tried to load.cause
- the cause of the failure to load the grid file.
-