@LcdService(service=ILcdModelDecoder.class, priority=20000) public class TLcdDEMModelDecoder extends Object implements ILcdModelDecoder, ILcdInputStreamFactoryCapable
File | Required | Entry point | Description |
---|---|---|---|
*.dem | x | x | DEM file containing the elevation raster |
inputStreamFactory
of this decoder.ILcd2DBoundsIndexedModel
.TLcdDEMModelDescriptor
.ILcdGeodeticReference
(for geodetic systems) or an
ILcdGridReference
(for UTM systems) as a model reference.supportGeoidDatums
is set to
true
, a more accurate geoid datum NGVD27, NAVD88, or
EGM96.ALcdImage
(and ILcdRaster
) instance.ALcdImage
interface. Legacy rasters are assumed to
be area-sampled.colorModel
allows to override the default
16-bits index color that is attached to the decoded rasters, since
DEM files don't contain any color information.
TLcdDEMModelDecoder decoder = new TLcdDEMModelDecoder();
ILcdColorModelFactory factory = new TLcdDTEDColorModelFactory();
ColorModel colorModel = factory.createColorModel();
decoder.setColorModel(colorModel);
ILcdModel model = decoder.decode("elevations.dem");
TLcdGeoTIFFModelEncoder
can
create compressed multilevel GeoTIFF files that can replace the original
DEM files.Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_DISPLAY_NAME |
static String |
DEFAULT_EXTENSION |
Constructor and Description |
---|
TLcdDEMModelDecoder()
Creates a new TLcdDEMModelDecoder, with a globally shared
buffer for caching tiles.
|
TLcdDEMModelDecoder(ILcdBuffer aBuffer)
Creates a new TLcdDEMModelDecoder.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canDecodeSource(String aString)
Checks whether this model decoder can decode the specified data source.
|
ILcdModel |
decode(String aSourceName)
Creates a new model from the given data source.
|
ColorModel |
getColorModel()
Returns the color model that is attached to decoded rasters.
|
String |
getDisplayName()
Returns a short, displayable name for the format that is decoded by this
ILcdModelDecoder . |
ILcdInputStreamFactory |
getInputStreamFactory()
Returns the input stream factory that is used for creating input streams
given source names.
|
boolean |
isSupportGeoidDatums()
Returns whether the geodetic datums of the decoded model references may be
geoid datums.
|
void |
setColorModel(ColorModel aColorModel)
Sets the color model that will be attached to decoded rasters.
|
void |
setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
Sets the input stream factory that will be used for creating input streams
given source names.
|
void |
setSupportGeoidDatums(boolean aSupportGeoidDatums)
Specifies whether the geodetic datums of the decoded model references may
be geoid datums (like NAVD88), instead of the default
ellipsoid datums (like NAD83).
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
canDecodeSource, decodeModelMetadata, decodeModelMetadata, decodeSource, discoverDataSources
public static final String DEFAULT_DISPLAY_NAME
public static final String DEFAULT_EXTENSION
public TLcdDEMModelDecoder()
TLcdSharedBuffer.getBufferInstance()
public TLcdDEMModelDecoder(ILcdBuffer aBuffer)
aBuffer
- the buffer in which decoded raster tiles will be cached.public void setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
setInputStreamFactory
in interface ILcdInputStreamFactoryCapable
aInputStreamFactory
- the input stream factory to be used.public ILcdInputStreamFactory getInputStreamFactory()
getInputStreamFactory
in interface ILcdInputStreamFactoryCapable
public void setColorModel(ColorModel aColorModel)
aColorModel
- a 16-bit IndexColorModel.public ColorModel getColorModel()
public void setSupportGeoidDatums(boolean aSupportGeoidDatums)
public boolean isSupportGeoidDatums()
public String getDisplayName()
ILcdModelDecoder
ILcdModelDecoder
.getDisplayName
in interface ILcdModelDecoder
ILcdModelDecoder
.public boolean canDecodeSource(String aString)
ILcdModelDecoder
true
for a source name while decode
throws an exception for that same source name.
For performance reasons, we strongly recommend that this will only be a simple test. For example: check the file extension of a file, but not that the file exists or contains expected content.
canDecodeSource
in interface ILcdModelDecoder
aString
- the data source to be verified; typically a file name or a URL.true
if file name aString has extension (ends with) "dem".ILcdModelDecoder.decode(String)
,
ILcdModelDecoder.decodeModelMetadata(String)
public ILcdModel decode(String aSourceName) throws IOException
ILcdModelDecoder
decode
in interface ILcdModelDecoder
aSourceName
- the data source to be decoded; typically a file name or a URL.null
is allowed, implementors are advised to throw an error instead.IOException
- for any exceptions caused by IO problems or invalid data. Since decoding invalid data almost
always results in RunTimeExceptions (NullPointerException, IndexOutOfBoundsException,
IllegalArgumentException, ...) on unexpected places, implementations are advised to catch
RuntimeExceptions in their decode() method, and wrap them into an IOException, as illustrated
in the code snippet below.
public ILcdModel decode( String aSourceName ) throws IOException {
try (InputStream input = fInputStreamFactory.createInputStream(aSourceName)) {
// Perform decoding ...
} catch (RuntimeException e) {
throw new IOException(e);
}
}
InterruptedIOException
- When the thread on which this method is called is interrupted: it is recommended to stop the decoding
and throw an InterruptedIOException
.
This same exception can also be used if the decoder shows UI to the user, and the user cancels the decoding
through the UI.ILcdModelDecoder.canDecodeSource(String)