Class TLcdE57ModelDecoder
- All Implemented Interfaces:
ILcdModelDecoder,ILcdStatusSource
.e57) files.
An E57 file can contain both point cloud data and panoramic imagery. This model decoder can decode both kinds of data from an E57 file.
Both kinds of data have to decoded in separate models, by first discovering the ILcdDataSource of a E57 file, using the discoverDataSources(String) method.
Each ILcdDataSource discovered by this method can be decoded using the decodeSource(ILcdDataSource) method.
According to the E57 specification, panoramic data can be represented in different projections. These are the Visual Projection, the Pinhole Projection, the Spherical Projection, the Cylindrical Projection or they can have no projection.
This model decoder only supports images represented in the Pinhole and Spherical projections. If the decodeSource(ILcdDataSource) method is called on an E57 file containing images in any other projection an UnsupportedOperationException will be thrown.
Input Files
| File | Required | Entry point | Description |
|---|---|---|---|
| *.e57 | X | X | The main E57 file |
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
- EPSG references (
<filename>.epsg): seeTLcdEPSGModelReferenceDecoderfor more info. - WKT references (
<filename>.prj): seeTLcdWKTModelReferenceDecoderfor more info. - Luciad encoded model references (
<filename>.ref): seeTLcdModelReferenceDecoderfor more info.
null.
Supported file transfer protocols
- This decoder uses random access files to decode objects. The source data needs to be accessible as a file.
Model structure
- The decoded models implement
ILcdBounded(which returns the extent of the data). - The decoded models do not support spatial queries.
Model descriptor
Models returned by this model decoder either have aTLcdE57ModelDescriptor when calling decodeSource(ILcdDataSource)
with a ILcdE57PointCloudDataSource or a ILcdPanoramaModelDescriptor when calling decodeSource(ILcdDataSource) with a ILcdE57PanoramaDataSource.
Model reference
The E57 model is not georeferenced, meaning that an external georeference is needed to properly decode this type of file within geospatial context.- If set, the model reference decoder is used.
- If the model reference decoder does not find a reference, the default model reference is used.
Model reference decoder priority
A model reference decoder priority for TLcdE57ModelDecoder can be set to change the order in which an ILcdModelReference is decoded by setting
the system property com.luciad.format.e57.TLcdE57ModelDecoder.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 (.e57). 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 (.e57). |
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 (.e57) 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.e57.TLcdE57ModelDecoder.referenceDecoderPriority to EXTERNAL_FIRST.
|
|
Model elements
- When calling
decodeSource(ILcdDataSource)with aILcdE57PointCloudDataSource:- The elements in the model can only be used for visualization with a
TLspPlotLayerBuilder. - The points themselves are lazily loaded when accessed by a painter. As such, the bulk of the work is not done in the
decodeSource(ILcdDataSource)method, but later.
- The elements in the model can only be used for visualization with a
- When calling
decodeSource(ILcdDataSource)with aILcdE57PanoramaDataSource:- The elements in the model implement
ILcdPanorama.
- The elements in the model implement
Updating the model
- Models are read-only and cannot be changed.
Sample code
Decode file
TLcdE57ModelDecoder e57Decoder = new TLcdE57ModelDecoder();
ILcdModel e57Model = e57Decoder.decode("file.e57");
Decode data sources
TLcdE57ModelDecoder e57Decoder = new TLcdE57ModelDecoder();
List<? extends ILcdDataSource> dataSources = e57Decoder.discoverDataSources("file.e57");
ILcdE57PointCloudDataSource pointCloudSource = dataSources.stream()
.filter(dataSource -> dataSource instanceof ILcdE57PointCloudDataSource)
.map(dataSource -> (ILcdE57PointCloudDataSource) dataSources)
.findAny()
.orElse(null);
if (pointCloudSource != null) {
ILcdModel pointCloudModel = e57Decoder.decodeSource(pointCloudSource);
}
ILcdE57PanoramaDataSource panoramaSource = dataSources.stream()
.filter(dataSource -> dataSource instanceof ILcdE57PanoramaDataSource)
.map(dataSource -> (ILcdE57PanoramaDataSource) dataSources)
.findAny()
.orElse(null);
if (panoramaSource != null) {
ILcdModel panoramaModel = e57Decoder.decodeSource(panoramaSource);
}
Thread safety
- Use
TLcdLockUtil#readLock(Object)when accessing elements in the model.
- Since:
- 2018.1
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddStatusListener(ILcdStatusListener aListener) Registers the given listener so it will receive status events from this source.booleancanDecodeSource(ILcdDataSource aDataSource) Checks whether this model decoder can decode the data source(s), identified by the passedILcdDataSource.booleancanDecodeSource(String aSourceName) Checks whether this model decoder can decode the specified data source.Decodes a E57 file.decodeModelMetadata(ILcdDataSource aDataSource) Decodes metadata for the specified data source.decodeModelMetadata(String aSourceName) Decodes the model metadata of a E57 file.decodeSource(ILcdDataSource aDataSource) Creates a new model from the given data source.List<? extends ILcdDataSource> discoverDataSources(String aPath) RetrievesILcdDataSourceinstances for E57 file.Returns the default model reference that is assigned to decoded models whose files don't specify model references.Returns a short, displayable name for the format that is decoded by thisILcdModelDecoder.longReturns the maximum number of points that is kept in the model after decoding.Returns the model reference decoder that is used for files that don't specify model references.Returns the filter used to omit points during decoding.voidremoveStatusListener(ILcdStatusListener aListener) Removes the specified listener so it is no longer notified.voidsetDefaultModelReference(ILcdModelReference aDefaultModelReference) Sets the default model reference to be assigned to decoded models whose files don't specify model references.voidsetMaxNumberOfPoints(long aMaxNumberOfPoints) Sets the maximum number of points kept during decoding.voidsetModelReferenceDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder) Sets the model reference decoder that will be used for files that don't specify model references.voidsetPointFilter(ILcdFilter<ILcdDataObject> aPointFilter) Sets the filter used to omit points during decoding.
-
Constructor Details
-
TLcdE57ModelDecoder
public TLcdE57ModelDecoder()
-
-
Method Details
-
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.
-
setModelReferenceDecoder
Sets the model reference decoder that will be used for files that don't specify model references.- Parameters:
aModelReferenceDecoder- the model reference decoder.
-
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:
-
setDefaultModelReference
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
Returns the default model reference that is assigned to decoded models whose files don't specify model references. -
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.- Parameters:
aMaxNumberOfPoints- the maximum number of points kept during decoding.- See Also:
-
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
Sets the filter used to omit points during decoding. When this filter returns
false, the given point 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 benull.- See Also:
-
addStatusListener
Description copied from interface:ILcdStatusSourceRegisters the given listener so it will receive status events from this source.
In case you need to register a listener which keeps a reference to an object with a shorter life-time than this status source, you can use a
ALcdWeakStatusListenerinstance as status listener.- Specified by:
addStatusListenerin interfaceILcdStatusSource- Parameters:
aListener- The listener to be notified when the status has changed.
-
removeStatusListener
Description copied from interface:ILcdStatusSourceRemoves the specified listener so it is no longer notified.- Specified by:
removeStatusListenerin interfaceILcdStatusSource- Parameters:
aListener- The listener to remove.
-
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:
aSourceName- 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:
-
canDecodeSource
Description copied from interface:ILcdModelDecoderChecks whether this model decoder can decode the data source(s), identified by the passed
ILcdDataSource.For performance reasons, we strongly recommend that this will only be a simple test. For example: check the instance class of
aDataSource, or check the file extension if it is aTLcdDataSource.The default implementation of this method will check if the given
ILcdDataSourceis aTLcdDataSource. If not, this method returns false. Otherwise, it delegates the source to theILcdModelDecoder.canDecodeSource(String)method.- Specified by:
canDecodeSourcein interfaceILcdModelDecoder- Parameters:
aDataSource- theILcdModelSourceto be verified.- Returns:
trueif this decoder can likely decode the data specified byaDataSource,falseotherwise.- See Also:
-
decodeModelMetadata
Decodes the model metadata of a E57 file. An E57 file can contain point cloud data, or panoramic images, or both. If the passed E57 file contains point cloud data (whether or not panoramic images are present), calling this method is equivalent to callingdecodeModelMetadata(ILcdDataSource)with aILcdE57PointCloudDataSourcedescribing the given file. If the passed E57 file contains only panoramic imagery (and no point cloud data), calling this method is equivalent to callingdecodeModelMetadata(ILcdDataSource)with aILcdE57PanoramaDataSourcedescribing the given file. If the passed file contains neither point cloud data nor panoramic imagery, anIOExceptionwill be thrown- Specified by:
decodeModelMetadatain interfaceILcdModelDecoder- Parameters:
aSourceName- the data source to be decoded; typically a file name or a URL.- Returns:
- a
TLcdModelMetadatainstance containing the model metadata of either a point cloud model or a panoramic model - Throws:
IOException- If the given file contains no point cloud data or panoramic imagery or if anotherIOExceptionoccurs.- See Also:
-
decodeModelMetadata
Description copied from interface:ILcdModelDecoderDecodes metadata for the specified data source. By default, this decodes the model and returns the model metadata found on that model. Implementations can override this method to speed up the retrieval.- Specified by:
decodeModelMetadatain interfaceILcdModelDecoder- Parameters:
aDataSource- the data source to 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:
-
decode
Decodes a E57 file. If the passed E57 file contains point cloud date and/or panoramic imagery, calling this method is equivalent to callingdecodeSource(ILcdDataSource)with aILcdE57PointCloudDataSourcedescribing the given file. If If the passed E57 file contains only panoramic imagery (and no point cloud data), calling this method is equivalent to callingdecodeSource(ILcdDataSource)with aILcdE57PanoramaDataSourcedescribing the given file. If the passed file contains neither point cloud data nor panoramic imagery, anIOExceptionwill be thrown- Specified by:
decodein interfaceILcdModelDecoder- Parameters:
aSourceName- the data source to be decoded; typically a file name or a URL.- Returns:
- an
ILcdModelcontaining either point cloud data or panoramic imagery data. - Throws:
IOException- If the given file contains no point cloud data or panoramic imagery or if anotherIOExceptionoccurs.- See Also:
-
decodeSource
Description copied from interface:ILcdModelDecoderCreates a new model from the given data source.
By default, this method:
- Throws a
NullPointerExceptionwhen anulldata source is passed. - Delegates to the
ILcdModelDecoder.decode(String)method when aTLcdDataSourceis passed. - Throws an IOException in other case.
- Specified by:
decodeSourcein interfaceILcdModelDecoder- Parameters:
aDataSource- theILcdDataSourceto be decoded.- 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 decodeSource(ILcdDataSource aDataSource) throws IOException { try { // Perform decoding ... } catch (RuntimeException e) { throw new IOException(e); } }- See Also:
- Throws a
-
discoverDataSources
RetrievesILcdDataSourceinstances for E57 file. The returnedILcdDataSourcewill either be suitable to decode point cloud data or panoramic imagery from the given E57 file. The returned list will contain at most twoILcdDataSource. If the given E57 file contains point cloud data, the returned list will contain aILcdE57PointCloudDataSource. ThisILcdE57PointCloudDataSourcecan be used to decode point cloud data from the E57 file by passing it to thedecodeSource(ILcdDataSource)method. If the given E57 file contains panoramic imagery, the returned list will contain aILcdE57PanoramaDataSource. ThisILcdE57PanoramaDataSourcecan be used to decode point cloud data from the E57 file by passing it to thedecodeSource(ILcdDataSource)method.- Specified by:
discoverDataSourcesin interfaceILcdModelDecoder- Parameters:
aPath- A path to the data source to be decoded; typically a file path or a URL.- Returns:
- If this model decoder returns
trueforILcdModelDecoder.canDecodeSource(String), it will return a list containing at least a singleILcdDataSource. - Throws:
IOException- If this model decoder returnsfalseforILcdModelDecoder.canDecodeSource(String)or if any exceptions caused by IO problems or invalid data occur.
-