Package com.luciad.format.swissdhm
Class TLcdSwissDHMMatrixModelDecoder
java.lang.Object
com.luciad.format.swissdhm.TLcdSwissDHMMatrixModelDecoder
- All Implemented Interfaces:
ILcdInputStreamFactoryCapable,ILcdModelDecoder
@LcdService(service=ILcdModelDecoder.class,
priority=20000)
public class TLcdSwissDHMMatrixModelDecoder
extends Object
implements ILcdModelDecoder, ILcdInputStreamFactoryCapable
This model decoder decodes elevation rasters in the SwissTopo Digital
Height Model format (DHM25). The MMBLT matrix format as well as the MMBL
matrix format are supported.
Input files
| File | Required | Entry point | Description |
|---|---|---|---|
| *.mlt | x | x | MMBLT file containing the elevation raster |
| *.mbl | x | MMBL file containing the elevation raster |
Supported file transfer protocols
- This model decoder supports all transfer protocols that are supported by
the
inputStreamFactoryof this decoder.
Model structure
- This model decoder creates a model per SwissDHMMatrix file.
- All models returned by this model decoder implement
ILcd2DBoundsIndexedModel.
Model descriptor
- All models returned by this model decoder have a
TLcdSwissDHMMatrixModelDescriptor. - The type name of the model descriptor is the display name of this decoder.
Model reference
- All models returned by this model decoder have a
TLcdSwissGridReference.
Model elements
- Each decoded model contains a single element that implements
ILcdRaster.
Useful settings
- The property
colorModelallows to override the default 16-bits index color that is attached to the decoded rasters, since DHM25 files don't contain any color information.
Sample code
TLcdSwissDHMMatrixModelDecoder decoder = new TLcdSwissDHMMatrixModelDecoder();
ILcdColorModelFactory factory = new TLcdDTEDColorModelFactory();
ColorModel colorModel = factory.createColorModel();
decoder.setColorModel(colorModel);
ILcdModel model = decoder.decode("elevations.SwissDHMMatrix");
Performance tips
- Since DHM25 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
TLcdGeoTIFFModelEncodercan create multilevel GeoTIFF files that can replace the original DHM25 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
Known limitations
- Elevations are always converted from decimeters to meters.
- Since:
- 3.3
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe sampling strategy that returns the average value of the corners of each DHM sample cell.static final intThe sampling strategy that returns a bilinear interpolation of the values of the corners of each DHM sample cell.static final Stringstatic final intThe sampling strategy that returns the maximum value of the corners of each DHM sample cell.static final intThe sampling strategy that returns the minimum value of the corners of each DHM sample cell.static final intThe sampling strategy that returns the North-East corner of each DHM sample cell.static final intThe sampling strategy that returns the North-West corner of each DHM sample cell.static final intThe sampling strategy that returns the South-East corner of each DHM sample cell.static final intThe sampling strategy that returns the South-West corner of each DHM sample cell. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new TLcdSwissDHMMatrixModelDecoder, with a globally shared buffer for caching tiles.TLcdSwissDHMMatrixModelDecoder(ILcdBuffer aBuffer) Creates a new TLcdSwissDHMMatrixModelDecoder with the given buffer.TLcdSwissDHMMatrixModelDecoder(ILcdBuffer aBuffer, ColorModel aColorModel) Creates a new TLcdSwissDHMMatrixModelDecoder with the given buffer and color model.TLcdSwissDHMMatrixModelDecoder(ILcdBuffer aBuffer, ColorModel aColorModel, int aDefaultValue) Creates a new TLcdSwissDHMMatrixModelDecoder. -
Method Summary
Modifier and TypeMethodDescriptionbooleancanDecodeSource(String aSourceAsString) Checks whether this model decoder can decode the specified data source.createTile(String aSourceName, int aTileWidth, int aTileHeight) Decodes the given DHM file as anILcdTile.Creates a new model from the given data source.Get the color model to be used for the decoded rasters.intReturns default raster value for pixels that cannot be resolved.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.Returns the reference used for the decoded model.intstatic booleanDeprecated.This method has been deprecated.booleanReturns whether the geodetic datums of the decoded GeoTIFF model references may be geoid datums.static voidsetClassTraceOn(boolean aClassTraceOn) Deprecated.This method has been deprecated.voidsetColorModel(ColorModel aColorModel) Set the color model to be used for the decoded rasters.voidsetDefaultValue(int aDefaultValue) Sets default raster value for pixels that cannot be resolved.voidsetInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory) Sets the input stream factory that will be used for creating input streams given source names.voidsetSampleStrategy(int aSampleStrategy) Sets the sampling strategy for retrieving elevation values.voidsetSupportGeoidDatums(boolean aSupportGeoidDatums) Specifies whether the geodetic datums of the decoded model references may be geoid datums, instead of the default ellipsoid datums.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.luciad.model.ILcdModelDecoder
canDecodeSource, decodeModelMetadata, decodeModelMetadata, decodeSource, discoverDataSources
-
Field Details
-
NORTH_WEST_CORNER
public static final int NORTH_WEST_CORNERThe sampling strategy that returns the North-West corner of each DHM sample cell.- See Also:
-
SOUTH_WEST_CORNER
public static final int SOUTH_WEST_CORNERThe sampling strategy that returns the South-West corner of each DHM sample cell.- See Also:
-
NORTH_EAST_CORNER
public static final int NORTH_EAST_CORNERThe sampling strategy that returns the North-East corner of each DHM sample cell.- See Also:
-
SOUTH_EAST_CORNER
public static final int SOUTH_EAST_CORNERThe sampling strategy that returns the South-East corner of each DHM sample cell.- See Also:
-
MINIMUM
public static final int MINIMUMThe sampling strategy that returns the minimum value of the corners of each DHM sample cell.- See Also:
-
MAXIMUM
public static final int MAXIMUMThe sampling strategy that returns the maximum value of the corners of each DHM sample cell.- See Also:
-
AVERAGE
public static final int AVERAGEThe sampling strategy that returns the average value of the corners of each DHM sample cell.- See Also:
-
BILINEAR
public static final int BILINEARThe sampling strategy that returns a bilinear interpolation of the values of the corners of each DHM sample cell.- See Also:
-
DISPLAY_NAME
- See Also:
-
-
Constructor Details
-
TLcdSwissDHMMatrixModelDecoder
public TLcdSwissDHMMatrixModelDecoder()Creates a new TLcdSwissDHMMatrixModelDecoder, with a globally shared buffer for caching tiles.- See Also:
-
TLcdSwissDHMMatrixModelDecoder
Creates a new TLcdSwissDHMMatrixModelDecoder with the given buffer.- Parameters:
aBuffer- The buffer to use for caching tiles.
-
TLcdSwissDHMMatrixModelDecoder
Creates a new TLcdSwissDHMMatrixModelDecoder with the given buffer and color model.- Parameters:
aBuffer- The buffer to use for caching tiles.aColorModel- ColorModel to set on the created rasters.
-
TLcdSwissDHMMatrixModelDecoder
public TLcdSwissDHMMatrixModelDecoder(ILcdBuffer aBuffer, ColorModel aColorModel, int aDefaultValue) Creates a new TLcdSwissDHMMatrixModelDecoder.- Parameters:
aBuffer- Buffer to use for caching tiles.aColorModel- ColorModel to set on the created rasters.aDefaultValue- Default pixel value.
-
-
Method Details
-
getModelReference
Returns the reference used for the decoded model.- Returns:
- Reference used for the decoded model.
-
setColorModel
Set the color model to be used for the decoded rasters.- Parameters:
aColorModel- color model to be used for the decoded rasters.
-
getColorModel
Get the color model to be used for the decoded rasters.- Returns:
- color model to be used for the decoded rasters.
-
setDefaultValue
public void setDefaultValue(int aDefaultValue) Sets default raster value for pixels that cannot be resolved.- Parameters:
aDefaultValue- Default raster value for pixels that cannot be resolved.
-
getDefaultValue
public int getDefaultValue()Returns default raster value for pixels that cannot be resolved.- Returns:
- Default raster value for pixels that cannot be resolved.
-
setInputStreamFactory
Sets the input stream factory that will be used for creating input streams given source names.- Specified by:
setInputStreamFactoryin 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:
getInputStreamFactoryin interfaceILcdInputStreamFactoryCapable- Returns:
- the input stream factory that is used.
-
setSampleStrategy
public void setSampleStrategy(int aSampleStrategy) Sets the sampling strategy for retrieving elevation values.- Parameters:
aSampleStrategy- one ofNORTH_WEST_CORNER,SOUTH_WEST_CORNER,NORTH_EAST_CORNER,SOUTH_EAST_CORNER,MINIMUM,MAXIMUM,AVERAGE, orBILINEAR.
-
getSampleStrategy
public int getSampleStrategy() -
setSupportGeoidDatums
public void setSupportGeoidDatums(boolean aSupportGeoidDatums) Specifies whether the geodetic datums of the decoded model references may be geoid datums, instead of the default ellipsoid datums. 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. The ellipsoid of the Swiss grid system of 1903 is generally a sufficiently accurate approximation, only deviating from the geoid by a few decimeters on average. -
isSupportGeoidDatums
public boolean isSupportGeoidDatums()Returns whether the geodetic datums of the decoded GeoTIFF model references may be geoid datums. The default value istrue. -
getDisplayName
Description copied from interface:ILcdModelDecoderReturns a short, displayable name for the format that is decoded by thisILcdModelDecoder.- Specified by:
getDisplayNamein interfaceILcdModelDecoder- Returns:
- the displayable name of this
ILcdModelDecoder.
-
canDecodeSource
Description copied from interface:ILcdModelDecoderChecks whether this model decoder can decode the specified data source. It is acceptable for this method to returntruefor a source name whiledecodethrows 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:
canDecodeSourcein interfaceILcdModelDecoder- Parameters:
aSourceAsString- the data source to be verified; typically a file name or a URL.- Returns:
trueif this decoder can likely decode the data specified by the source name,falseotherwise.- See Also:
-
decode
Description copied from interface:ILcdModelDecoderCreates a new model from the given data source.- Specified by:
decodein interfaceILcdModelDecoder- Parameters:
aSourceName- the data source to be decoded; typically a file name or a URL.- Returns:
- A model containing the decoded data. While
nullis 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:
-
createTile
Decodes the given DHM file as anILcdTile. -
isClassTraceOn
public static boolean isClassTraceOn()Deprecated.This method has been deprecated. It is recommended to use the standard Java logging framework directly.Returnstrueif tracing is enabled for this class.- Returns:
- true if tracing is enabled for this class, false otherwise.
-
setClassTraceOn
public static void setClassTraceOn(boolean aClassTraceOn) Deprecated.This method has been deprecated. It is recommended to use the standard Java logging framework directly.Enables tracing for all instances of this class. If the argument istruethen all log messages are recorded, otherwise only the informative, warning and error messages are recorded.- Parameters:
aClassTraceOn- if true then all log messages are recorded, otherwise only the informative, warning and error messages are recorded.
-