Package com.luciad.format.raster
Class TLcdDEMModelDecoder
java.lang.Object
com.luciad.format.raster.TLcdDEMModelDecoder
- All Implemented Interfaces:
ILcdInputStreamFactoryCapable
,ILcdModelDecoder
@LcdService(service=ILcdModelDecoder.class,
priority=20000)
public class TLcdDEMModelDecoder
extends Object
implements ILcdModelDecoder, ILcdInputStreamFactoryCapable
This model decoder decodes elevation rasters in the DEM format (USGS Digital
Elevation Model).
Input files
File | Required | Entry point | Description |
---|---|---|---|
*.dem | x | x | DEM file containing the elevation raster |
Supported file transfer protocols
- This model decoder supports all transfer protocols that are supported by
the
inputStreamFactory
of this decoder.
Model structure
- This model decoder creates a model per DEM file.
- All models returned by this model decoder implement
ILcd2DBoundsIndexedModel
.
Model descriptor
- All models returned by this model decoder have a
TLcdDEMModelDescriptor
. - The type name of the model descriptor is the display name of this decoder.
Model reference
- All models returned by this model decoder have an
ILcdGeodeticReference
(for geodetic systems) or anILcdGridReference
(for UTM systems) as a model reference. - The geodetic datum of this reference is a geoid datum NGVD27, NAVD88, or
EGM96, or, if
supportGeoidDatums
is set tofalse
, a less accurate ellipsoidal datum WGS72, WGS84, NAD27 or NAD83.
Model elements
- Each decoded model contains one object: an
ALcdImage
(andILcdRaster
) instance. - The decoded elevation data is always point-sampled. This is however only
exposed via the
ALcdImage
interface. Legacy rasters are assumed to be area-sampled.
Useful settings
- The property
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.
Sample code
TLcdDEMModelDecoder decoder = new TLcdDEMModelDecoder();
ILcdColorModelFactory factory = new TLcdDTEDColorModelFactory();
ColorModel colorModel = factory.createColorModel();
decoder.setColorModel(colorModel);
ILcdModel model = decoder.decode("elevations.dem");
Performance tips
- Since DEM rasters only provide a single level of detail, precomputing
and storing multiple levels of detail may speed up visualization and
some computations. For instance, the
TLcdGeoTIFFModelEncoder
can create compressed multilevel GeoTIFF files that can replace the original DEM files.
Thread safety
- The decoding of models is thread-safe, as long as no properties are changed during the decoding.
- The decoded models and elements are thread-safe for read access, on the condition that a thread-safe buffer is used.
Supported versions and specifications
- Standards for Digital Elevation Models, US Department of the Interior, US Geological Survey, National Mapping Division, August 1997
Known limitations
- Only geographic and UTM reference systems are supported. State plane reference systems are not supported.
- Only the following datums are supported: horizontal datums NAD27, WGS72, WGS84, and NAD83, and vertical datums NVGD29, NAVD88, and EGM96. The following datums are not supported: old Hawaii and Puerto Rico.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionCreates a new TLcdDEMModelDecoder, with a globally shared buffer for caching tiles.TLcdDEMModelDecoder
(ILcdBuffer aBuffer) Creates a new TLcdDEMModelDecoder. -
Method Summary
Modifier and TypeMethodDescriptionboolean
canDecodeSource
(String aString) Checks whether this model decoder can decode the specified data source.Creates a new model from the given data source.Returns the color model that is attached to decoded rasters.Returns a short, displayable name for the format that is decoded by thisILcdModelDecoder
.Returns the input stream factory that is used for creating input streams given source names.boolean
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 ellipsoid datums (like NAD83).Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.luciad.model.ILcdModelDecoder
canDecodeSource, decodeModelMetadata, decodeModelMetadata, decodeSource, discoverDataSources
-
Field Details
-
DEFAULT_DISPLAY_NAME
- See Also:
-
DEFAULT_EXTENSION
- See Also:
-
-
Constructor Details
-
TLcdDEMModelDecoder
public TLcdDEMModelDecoder()Creates a new TLcdDEMModelDecoder, with a globally shared buffer for caching tiles.- See Also:
-
TLcdDEMModelDecoder
Creates a new TLcdDEMModelDecoder.- Parameters:
aBuffer
- the buffer in which decoded raster tiles will be cached.
-
-
Method Details
-
setInputStreamFactory
Sets the input stream factory that will be used for creating input streams given source names.- Specified by:
setInputStreamFactory
in interfaceILcdInputStreamFactoryCapable
- Parameters:
aInputStreamFactory
- the input stream factory to be used.
-
getInputStreamFactory
Returns the input stream factory that is used for creating input streams given source names.- Specified by:
getInputStreamFactory
in interfaceILcdInputStreamFactoryCapable
- Returns:
- the input stream factory that is used.
-
setColorModel
Sets the color model that will be attached to decoded rasters.- Parameters:
aColorModel
- a 16-bit IndexColorModel.
-
getColorModel
Returns the color model that is attached to decoded rasters. -
setSupportGeoidDatums
public void setSupportGeoidDatums(boolean aSupportGeoidDatums) Specifies whether the geodetic datums of the decoded model references may be geoid datums (like NAVD88), instead of the ellipsoid datums (like NAD83). Geoids vary smoothly between -110m and +90m around the ellipsoid. Geoid datums are more accurate for elevation data, but they require more memory and more processing time when they are being used in transformation calculations. -
isSupportGeoidDatums
public boolean isSupportGeoidDatums()Returns whether the geodetic datums of the decoded model references may be geoid datums. Geoid support is enabled by default, unless otherwise configured by the system propertycom.luciad.geodesy.geoidSupport.LEGACY
. -
getDisplayName
Description copied from interface:ILcdModelDecoder
Returns a short, displayable name for the format that is decoded by thisILcdModelDecoder
.- Specified by:
getDisplayName
in interfaceILcdModelDecoder
- Returns:
- the displayable name of this
ILcdModelDecoder
.
-
canDecodeSource
Description copied from interface:ILcdModelDecoder
Checks whether this model decoder can decode the specified data source. It is acceptable for this method to returntrue
for a source name whiledecode
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.
- Specified by:
canDecodeSource
in interfaceILcdModelDecoder
- Parameters:
aString
- the data source to be verified; typically a file name or a URL.- Returns:
true
if file name aString has extension (ends with) "dem".- See Also:
-
decode
Description copied from interface:ILcdModelDecoder
Creates a new model from the given data source.- Specified by:
decode
in interfaceILcdModelDecoder
- Parameters:
aSourceName
- the data source to be decoded; typically a file name or a URL.- Returns:
- A model containing the decoded data. While
null
is allowed, implementors are advised to throw an error instead. - Throws:
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); } }
- See Also:
-