@LcdService(service=ILcdModelDecoder.class, priority=20000) public class TLcdE57ModelDecoder extends Object implements 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.
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
<filename>.epsg
): see TLcdEPSGModelReferenceDecoder
for more info.<filename>.prj
): see TLcdWKTModelReferenceDecoder
for more info.<filename>.ref
): see TLcdModelReferenceDecoder
for more info.null
.
ILcdBounded
(which returns the extent of the data).TLcdE57ModelDescriptor
when calling decodeSource(ILcdDataSource)
with a ILcdE57PointCloudDataSource
or a ILcdPanoramaModelDescriptor
when calling decodeSource(ILcdDataSource)
with a ILcdE57PanoramaDataSource
.
decodeSource(ILcdDataSource)
with a ILcdE57PointCloudDataSource
:
TLspPlotLayerBuilder
.decodeSource(ILcdDataSource)
method, but later.decodeSource(ILcdDataSource)
with a ILcdE57PanoramaDataSource
:
ILcdPanorama
. TLcdE57ModelDecoder e57Decoder = new TLcdE57ModelDecoder();
ILcdModel e57Model = e57Decoder.decode("file.e57");
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);
}
TLcdLockUtil#readLock(Object)
when accessing
elements in the model.Constructor and Description |
---|
TLcdE57ModelDecoder() |
Modifier and Type | Method and Description |
---|---|
void |
addStatusListener(ILcdStatusListener aListener)
Registers the given listener so it will receive status events from this source.
|
boolean |
canDecodeSource(ILcdDataSource aDataSource)
Checks whether this model decoder can decode the data source(s), identified by the passed
ILcdDataSource . |
boolean |
canDecodeSource(String aSourceName)
Checks whether this model decoder can decode the specified data source.
|
ILcdModel |
decode(String aSourceName)
Decodes a E57 file.
|
TLcdModelMetadata |
decodeModelMetadata(ILcdDataSource aDataSource)
Decodes metadata for the specified data source.
|
TLcdModelMetadata |
decodeModelMetadata(String aSourceName)
Decodes the model metadata of a E57 file.
|
ILcdModel |
decodeSource(ILcdDataSource aDataSource)
Creates a new model from the given data source.
|
List<? extends ILcdDataSource> |
discoverDataSources(String aPath)
Retrieves
ILcdDataSource instances for E57 file. |
ILcdModelReference |
getDefaultModelReference()
Returns the default model reference that is assigned to decoded models
whose files don't specify model references.
|
String |
getDisplayName()
Returns a short, displayable name for the format that is decoded by this
ILcdModelDecoder . |
long |
getMaxNumberOfPoints()
Returns the maximum number of points that is kept in the model after decoding.
|
ILcdModelReferenceDecoder |
getModelReferenceDecoder()
Returns the model reference decoder that is used for files that
don't specify model references.
|
ILcdFilter<ILcdDataObject> |
getPointFilter()
Returns the filter used to omit points during decoding.
|
void |
removeStatusListener(ILcdStatusListener aListener)
Removes the specified listener so it is no longer notified.
|
void |
setDefaultModelReference(ILcdModelReference aDefaultModelReference)
Sets the default model reference to be assigned to decoded models whose
files don't specify model references.
|
void |
setMaxNumberOfPoints(long aMaxNumberOfPoints)
Sets the maximum number of points kept during decoding.
|
void |
setModelReferenceDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder)
Sets the model reference decoder that will be used for files that don't specify model
references.
|
void |
setPointFilter(ILcdFilter<ILcdDataObject> aPointFilter)
Sets the filter used to omit points during decoding.
|
public String getDisplayName()
ILcdModelDecoder
ILcdModelDecoder
.getDisplayName
in interface ILcdModelDecoder
ILcdModelDecoder
.public void setModelReferenceDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder)
aModelReferenceDecoder
- the model reference decoder.public ILcdModelReferenceDecoder getModelReferenceDecoder()
setModelReferenceDecoder(ILcdModelReferenceDecoder)
public void setDefaultModelReference(ILcdModelReference aDefaultModelReference)
aDefaultModelReference
- the default model reference.public ILcdModelReference getDefaultModelReference()
public long getMaxNumberOfPoints()
setMaxNumberOfPoints(long)
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
.
aMaxNumberOfPoints
- the maximum number of points kept during decoding.getMaxNumberOfPoints()
public ILcdFilter<ILcdDataObject> getPointFilter()
null
.setPointFilter(com.luciad.util.ILcdFilter)
public void setPointFilter(ILcdFilter<ILcdDataObject> aPointFilter)
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.
aPointFilter
- the filter used to omit domain objects during decoding. Can be null
.getPointFilter()
public void addStatusListener(ILcdStatusListener aListener)
ILcdStatusSource
Registers 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 ALcdWeakStatusListener
instance as status listener.
addStatusListener
in interface ILcdStatusSource
aListener
- The listener to be notified when the status has changed.public void removeStatusListener(ILcdStatusListener aListener)
ILcdStatusSource
removeStatusListener
in interface ILcdStatusSource
aListener
- The listener to remove.public boolean canDecodeSource(String aSourceName)
ILcdModelDecoder
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.
canDecodeSource
in interface ILcdModelDecoder
aSourceName
- the data source to be verified; typically a file name or a URL.true
if this decoder can likely decode the data specified by the source name, false
otherwise.ILcdModelDecoder.decode(String)
,
ILcdModelDecoder.decodeModelMetadata(String)
public boolean canDecodeSource(ILcdDataSource aDataSource)
ILcdModelDecoder
Checks 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 a TLcdDataSource
.
The default implementation of this method will check if the given ILcdDataSource
is a
TLcdDataSource
. If not, this method returns false. Otherwise, it delegates
the source to the ILcdModelDecoder.canDecodeSource(String)
method.
canDecodeSource
in interface ILcdModelDecoder
aDataSource
- the ILcdModelSource
to be verified.true
if this decoder can likely decode the data specified by aDataSource
, false
otherwise.ILcdModelDecoder.decodeSource(ILcdDataSource)
,
ILcdModelDecoder.decodeModelMetadata(ILcdDataSource)
public TLcdModelMetadata decodeModelMetadata(String aSourceName) throws IOException
decodeModelMetadata(ILcdDataSource)
with a ILcdE57PointCloudDataSource
describing the given file.
If the passed E57 file contains only panoramic imagery (and no point cloud data),
calling this method is equivalent to calling decodeModelMetadata(ILcdDataSource)
with a ILcdE57PanoramaDataSource
describing the given file.
If the passed file contains neither point cloud data nor panoramic imagery, an IOException
will be throwndecodeModelMetadata
in interface ILcdModelDecoder
aSourceName
- the data source to be decoded; typically a file name or a URL.TLcdModelMetadata
instance containing the model metadata of either a point cloud model or a panoramic modelIOException
- If the given file contains no poibnt clud data or panoramic imagery or if another IOException
occurs.decodeSource(ILcdDataSource)
,
discoverDataSources(String)
public TLcdModelMetadata decodeModelMetadata(ILcdDataSource aDataSource) throws IOException
ILcdModelDecoder
decodeModelMetadata
in interface ILcdModelDecoder
aDataSource
- the data source to be decoded.IOException
- if the metadata cannot be decoded for some reason.ILcdModelDecoder.canDecodeSource(ILcdDataSource)
public ILcdModel decode(String aSourceName) throws IOException
decodeSource(ILcdDataSource)
with a ILcdE57PointCloudDataSource
describing the given file.
If If the passed E57 file contains only panoramic imagery (and no point cloud data),
calling this method is equivalent to calling decodeSource(ILcdDataSource)
with a ILcdE57PanoramaDataSource
describing the given file.
If the passed file contains neither point cloud data nor panoramic imagery, an IOException
will be throwndecode
in interface ILcdModelDecoder
aSourceName
- the data source to be decoded; typically a file name or a URL.ILcdModel
containing either point cloud data or panoramic imagery data.IOException
- If the given file contains no point cloud data or panoramic imagery or if another IOException
occurs.decodeSource(ILcdDataSource)
,
discoverDataSources(String)
public ILcdModel decodeSource(ILcdDataSource aDataSource) throws IOException
ILcdModelDecoder
Creates a new model from the given data source.
By default, this method:
NullPointerException
when a null
data source is passed.ILcdModelDecoder.decode(String)
method when a TLcdDataSource
is passed.decodeSource
in interface ILcdModelDecoder
aDataSource
- the ILcdDataSource
to be decoded.null
is allowed, implementors are advised to throw an error instead.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);
}
}
ILcdModelDecoder.canDecodeSource(ILcdDataSource)
public List<? extends ILcdDataSource> discoverDataSources(String aPath) throws IOException
ILcdDataSource
instances for E57 file. The returned ILcdDataSource
will either be suitable to decode point cloud data or panoramic imagery from the given E57 file.
The returned list will contain at most two ILcdDataSource
.
If the given E57 file contains point cloud data, the returned list will contain a ILcdE57PointCloudDataSource
.
This ILcdE57PointCloudDataSource
can be used to decode point cloud data from the E57 file by passing it to the decodeSource(ILcdDataSource)
method.
If the given E57 file contains panoramic imagery, the returned list will contain a ILcdE57PanoramaDataSource
.
This ILcdE57PanoramaDataSource
can be used to decode point cloud data from the E57 file by passing it to the decodeSource(ILcdDataSource)
method.discoverDataSources
in interface ILcdModelDecoder
aPath
- A path to the data source to be decoded; typically a file path or a URL.true
for ILcdModelDecoder.canDecodeSource(String)
, it will
return a list containing at least a single ILcdDataSource
.IOException
- If this model decoder returns false
for ILcdModelDecoder.canDecodeSource(String)
or if any exceptions caused by IO problems or invalid data occur.