Class TLcdLASModelDecoder

java.lang.Object
com.luciad.format.las.TLcdLASModelDecoder
All Implemented Interfaces:
ILcdInputStreamFactoryCapable, ILcdModelDecoder, ILcdStatusSource

A model decoder that decodes LASer (.las) and LASzip files (.laz).

This decoder supports versions 1.0, 1.1, 1.2, 1.3 and 1.4 for the LASer format. For the LASzip format, versions 1.0, 1.1, 1.2 and 1.3 are supported, version 1.4 is not currently supported. Only LASzip files with points compressed into chunks of points using arithmetic encoding are supported. For more information, see the LASzip specification.

Input Files

FileRequiredEntry pointDescription
*.lasXXThe LASer file
*.lazXXThe LASzip file

The model reference is obtained from an ILcdModelReferenceDecoder. The default reference decoder set on this model decoder is based on all model reference decoders annotated with the LcdService annotation, and can handle

If this fails, the decoder's default model reference is returned. Unless set by the user, the default model reference is null.

Supported file transfer protocols

  • This model decoder supports all transfer protocols that are supported by the inputStreamFactory of this decoder.

Model structure

  • The decoded models implement ILcdBounded (which returns the extent of the data).
  • The decoded models do not support spatial queries.

Model descriptor

All models returned by this model decoder have a TLcdLASModelDescriptor.

The model descriptor contains various properties available in the .las header, as well as the variable-length records.

Model reference

  • All models returned by this model decoder usually have a ILcdGridReference or ILcdGeodeticReference.
  • The reference is decoded from the .las file variable-length record.
  • If the file does not contain a reference, the model reference decoder is used.
  • If the model reference decoder does not find a reference, the default model reference is used.

By default, this model decoder loads up to 1000000L points of the file, spread over the whole range of points. This way, you still see a lower-resolution version of the data that is otherwise too large to load.

You can increase or decrease the maximum number of points to load using setMaxNumberOfPoints(long).

Model reference decoder priority

A model reference decoder priority for TLcdLASModelDecoder can be set to change the order in which an ILcdModelReference is decoded by setting the system property com.luciad.format.las.TLcdLASModelDecoder.referenceDecoderPriority to one of these priority values.

Priority Explanation
EMBEDDED_FIRST The model reference decoding is first attempted from the reference information embedded in the data file (.las/.laz). If that fails, the model reference decoding is tried from external reference source files such as WKT (.prj), REF (.ref) and EPSG (*.epsg).
EXTERNAL_FIRST The model reference decoding is first attempted from external reference source files such as WKT (.prj), REF (.ref) and EPSG (*.epsg). If that fails, the model reference decoding is tried from the reference information embedded in the data file (.las/.laz).
By default, the priority is set to use EMBEDDED_FIRST.
This configuration can be useful in scenarios where the model reference embedded in the data file (.las/.laz) might be incorrect or incomplete. You can fix it by placing an external reference file next to the data file, and setting the system property com.luciad.format.las.TLcdLASModelDecoder.referenceDecoderPriority to EXTERNAL_FIRST.

Model elements

  • The elements in the model can only be used for visualization with a TLspLIDARLayerBuilder.
  • The points themselves are lazily loaded when accessed by a painter. As such, the bulk of the work is not done in the decode() method, but later.

Updating the model

  • Models are read-only and cannot be changed.

Sample code


 ILcdModelDecoder decoder = new TLcdLASModelDecoder();
 ILcdModel model = decoder.decode( "data.las" );
 

Thread safety

Supported versions

This model decoder supports:
  • LAS format (.las): version 1.0, 1.1, 1.2, 1.3 and 1.4
  • LASzip format (.laz): version 1.0, 1.1, 1.2 and 1.3
Since:
2014.0
  • Constructor Details

  • Method Details

    • 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 currently used for creating input streams given source names.
      Specified by:
      getInputStreamFactory in interface ILcdInputStreamFactoryCapable
      Returns:
      the input stream factory that is currently used.
    • addStatusListener

      public void addStatusListener(ILcdStatusListener aStatusListener)
      Registers the given listener so it will receive status events from this model decoder.

      Note that the model produced by this model decoder is lazy-loading: most of the decoding work is done when the model is accessed, not during the decode(java.lang.String) itself.

      The status listeners will therefor receive the status events not only during the decode(java.lang.String) itself, but also later when the model is accessed, after the decode has finished.

      You can expect the following event flow multiple times:

      1. START_BUSY
      2. PROGRESS with a progress values between 0 and 1
      3. END_BUSY

      Specified by:
      addStatusListener in interface ILcdStatusSource
      Parameters:
      aStatusListener - The listener to be notified when the status has changed.
    • removeStatusListener

      public void removeStatusListener(ILcdStatusListener aStatusListener)
      Description copied from interface: ILcdStatusSource
      Removes the specified listener so it is no longer notified.
      Specified by:
      removeStatusListener in interface ILcdStatusSource
      Parameters:
      aStatusListener - The listener to remove.
    • setModelReferenceDecoder

      public void setModelReferenceDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder)
      Sets the model reference decoder that will be used for files that don't specify model references.
      Parameters:
      aModelReferenceDecoder - the model reference decoder.
    • getModelReferenceDecoder

      public ILcdModelReferenceDecoder getModelReferenceDecoder()
      Returns the model reference decoder that is used for files that don't specify model references. The default value supports WKT (*.prj), REF (*.ref), and EPSG (*.epsg).
      Returns:
      the model reference decoder used by this decoder
      See Also:
    • isPerformBoundsAndRangeScan

      public boolean isPerformBoundsAndRangeScan()
      Returns whether or not to perform a (fast) data scan when decoding a dataset. This fixes incorrect bounds and allows querying the data range of every property using TLcdLASModelDescriptor.getPropertyRange(com.luciad.datamodel.TLcdDataProperty). The default value of this property is true.
      Returns:
      aPerformBoundsAndRangeScan if true, point data is scanned when opening a dataset
      Since:
      2018.0
    • setPerformBoundsAndRangeScan

      public void setPerformBoundsAndRangeScan(boolean aPerformBoundsAndRangeScan)
      Sets whether or not to perform a (fast) data scan when decoding a dataset. This fixes incorrect bounds, incorrect little-endian vs. big-endian color encoding and allows querying the data range of every property using TLcdLASModelDescriptor.getPropertyRange(com.luciad.datamodel.TLcdDataProperty). Disabling this functionality speeds up model decoding, but property ranges cannot be queried.
      Parameters:
      aPerformBoundsAndRangeScan - if true, point data is scanned when opening a dataset. If false, the bounds of the headers are used and no property range will be available.
      Since:
      2018.0
    • setDefaultModelReference

      public void setDefaultModelReference(ILcdModelReference aDefaultModelReference)
      Sets the default model reference to be assigned to decoded models whose files don't specify model references.
      Parameters:
      aDefaultModelReference - the default model reference.
    • getDefaultModelReference

      public ILcdModelReference getDefaultModelReference()
      Returns the default model reference that is assigned to decoded models whose files don't specify model references.
    • setSupportGeoidDatums

      public void setSupportGeoidDatums(boolean aSupportGeoidDatums)

      Specifies whether the geodetic datums of the decoded model references may be geoid datums (like EGM96), instead of the default ellipsoid datums (like WGS84). A geoid typically varies 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.

      true by default.

      Parameters:
      aSupportGeoidDatums - true to support geoid datums
      See Also:
    • isSupportGeoidDatums

      public boolean isSupportGeoidDatums()
      Returns whether the geodetic datums of the decoded model references may be geoid datums.
      Returns:
      whether the geodetic datums of the decoded model references may be geoid datums.
      See Also:
    • getMaxNumberOfPoints

      public long getMaxNumberOfPoints()
      Returns the maximum number of points that is kept in the model after decoding.
      Returns:
      the maximum number of points that is kept in the model after decoding.
      See Also:
    • setMaxNumberOfPoints

      public void setMaxNumberOfPoints(long aMaxNumberOfPoints)

      Sets the maximum number of points kept during decoding.

      The points that are kept will be spread over the whole range of points, so that you still see a lower-resolution version of the data. See also performance note in TLspLIDARLayerBuilder.

      The default is 1000000L.

      Use Long.MAX_VALUE to make sure that all points are always kept during decoding.

      Parameters:
      aMaxNumberOfPoints - the maximum number of points kept during decoding.
      See Also:
    • getPointFilter

      public ILcdFilter<ILcdDataObject> getPointFilter()
      Returns the filter used to omit points during decoding.
      Returns:
      the filter used to omit points during decoding, can be null.
      See Also:
    • setPointFilter

      public void setPointFilter(ILcdFilter<ILcdDataObject> aPointFilter)

      Sets the filter used to omit points during decoding. When this filter returns false, the given points is not added to the decoded model. Note that implementations of this filter should not hold on to the points as they may become invalid afterwards.

      It is possible that points are already filtered because a max number of points is set on this model decoder. In that case, the given filter is applied on the remaining points.

      Parameters:
      aPointFilter - the filter used to omit domain objects during decoding. Can be null.
      See Also:
    • 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 aSourceName)
      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:
      aSourceName - 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:
    • decodeModelMetadata

      public TLcdModelMetadata decodeModelMetadata(String aSourceName) throws IOException
      Decodes metadata for the specified data source. This method reads the bounds from the file header and does not read the points data to check if these bounds are correct.
      Specified by:
      decodeModelMetadata in interface ILcdModelDecoder
      Parameters:
      aSourceName - the data source for which the model metadata will be decoded.
      Returns:
      the model metadata for the data source, never null.
      Throws:
      IOException - if the metadata cannot be decoded for some reason.
      See Also: