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 inputStreamFactory of this decoder.

Model structure

  • This model decoder creates a model per SwissDHMMatrix file.
  • All models returned by this model decoder implement ILcd2DBoundsIndexedModel.

Model descriptor

Model reference

Model elements

  • Each decoded model contains a single element that implements ILcdRaster.

Useful settings

  • The property colorModel allows 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 TLcdGeoTIFFModelEncoder can 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 Details

    • NORTH_WEST_CORNER

      public static final int NORTH_WEST_CORNER
      The sampling strategy that returns the North-West corner of each DHM sample cell.
      See Also:
    • SOUTH_WEST_CORNER

      public static final int SOUTH_WEST_CORNER
      The sampling strategy that returns the South-West corner of each DHM sample cell.
      See Also:
    • NORTH_EAST_CORNER

      public static final int NORTH_EAST_CORNER
      The sampling strategy that returns the North-East corner of each DHM sample cell.
      See Also:
    • SOUTH_EAST_CORNER

      public static final int SOUTH_EAST_CORNER
      The sampling strategy that returns the South-East corner of each DHM sample cell.
      See Also:
    • MINIMUM

      public static final int MINIMUM
      The sampling strategy that returns the minimum value of the corners of each DHM sample cell.
      See Also:
    • MAXIMUM

      public static final int MAXIMUM
      The sampling strategy that returns the maximum value of the corners of each DHM sample cell.
      See Also:
    • AVERAGE

      public static final int AVERAGE
      The sampling strategy that returns the average value of the corners of each DHM sample cell.
      See Also:
    • BILINEAR

      public static final int BILINEAR
      The sampling strategy that returns a bilinear interpolation of the values of the corners of each DHM sample cell.
      See Also:
    • DISPLAY_NAME

      public static final String DISPLAY_NAME
      See Also:
  • Constructor Details

    • TLcdSwissDHMMatrixModelDecoder

      public TLcdSwissDHMMatrixModelDecoder()
      Creates a new TLcdSwissDHMMatrixModelDecoder, with a globally shared buffer for caching tiles.
      See Also:
    • TLcdSwissDHMMatrixModelDecoder

      public TLcdSwissDHMMatrixModelDecoder(ILcdBuffer aBuffer)
      Creates a new TLcdSwissDHMMatrixModelDecoder with the given buffer.
      Parameters:
      aBuffer - The buffer to use for caching tiles.
    • TLcdSwissDHMMatrixModelDecoder

      public TLcdSwissDHMMatrixModelDecoder(ILcdBuffer aBuffer, ColorModel aColorModel)
      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

      public ILcdModelReference getModelReference()
      Returns the reference used for the decoded model.
      Returns:
      Reference used for the decoded model.
    • setColorModel

      public void setColorModel(ColorModel aColorModel)
      Set the color model to be used for the decoded rasters.
      Parameters:
      aColorModel - color model to be used for the decoded rasters.
    • getColorModel

      public ColorModel 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

      public void setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
      Sets the input stream factory that will be used for creating input streams given source names.
      Specified by:
      setInputStreamFactory in interface ILcdInputStreamFactoryCapable
      Parameters:
      aInputStreamFactory - the input stream factory to be used.
    • getInputStreamFactory

      public ILcdInputStreamFactory getInputStreamFactory()
      Returns the input stream factory that is used for creating input streams given source names.
      Specified by:
      getInputStreamFactory in interface ILcdInputStreamFactoryCapable
      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 of NORTH_WEST_CORNER, SOUTH_WEST_CORNER, NORTH_EAST_CORNER, SOUTH_EAST_CORNER, MINIMUM, MAXIMUM, AVERAGE, or BILINEAR.
    • 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 is true.
    • getDisplayName

      public String getDisplayName()
      Description copied from interface: ILcdModelDecoder
      Returns a short, displayable name for the format that is decoded by this ILcdModelDecoder.
      Specified by:
      getDisplayName in interface ILcdModelDecoder
      Returns:
      the displayable name of this ILcdModelDecoder.
    • canDecodeSource

      public boolean canDecodeSource(String aSourceAsString)
      Description copied from interface: ILcdModelDecoder
      Checks whether this model decoder can decode the specified data source. It is acceptable for this method to return 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.

      Specified by:
      canDecodeSource in interface ILcdModelDecoder
      Parameters:
      aSourceAsString - the data source to be verified; typically a file name or a URL.
      Returns:
      true if this decoder can likely decode the data specified by the source name, false otherwise.
      See Also:
    • decode

      public ILcdModel decode(String aSourceName) throws IOException
      Description copied from interface: ILcdModelDecoder
      Creates a new model from the given data source.
      Specified by:
      decode in interface ILcdModelDecoder
      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:
    • createTile

      public ILcdTile createTile(String aSourceName, int aTileWidth, int aTileHeight)
      Decodes the given DHM file as an ILcdTile.
    • isClassTraceOn

      public static boolean isClassTraceOn()
      Deprecated.
      This method has been deprecated. It is recommended to use the standard Java logging framework directly.
      Returns true if 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 is true then 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.