Class TLcdBinzModelDecoder
- All Implemented Interfaces:
ILcdModelDecoder
,ILcdStatusSource
This model decoder decodes Binz files.
See the Data Formats: Binz documentation for more in-depth information on how to use
the decoder and the resulting decoded model.
You can load it directly into a LuciadLightspeed view, or create an OGC 3DTiles dataset using the
TLcdOGC3DTilesModelEncoder
.
LuciadFusion can pick this model up and expose it through an OGC 3DTiles service.
Input files
There are 3 different ways to open a Binz dataset:File | Required | Entry point | Description |
---|---|---|---|
*.binz | x | x | Binz archive file containing a description of the model, its materials and its meta-data. |
File | Required | Entry point | Description |
---|---|---|---|
tree0000.bin | x | x | Binz files and directories containing a description of the model, its materials and its meta-data.
These files contain the unpacked data of a .binz archive file. |
tree0000.idx.bin | |||
leaf (directory) | x | ||
meta (directory) | x |
File | Required | Entry point | Description |
---|---|---|---|
*.binz.index | x | x | A text file containing relative path names to binz datasets. All datasets will be combined into one ILcdModel. |
Supported file transfer protocols
This decoder only supports data sources that are regular files.
Model reference
Binz data does not contain geo-referencing information itself. This section describes what strategies this decoder uses to find a suitable reference for the data.
-
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 theLcdService
annotation. For example, you use a.prj
file with WKT information, or a.epgs
file with an EPSG code next to the input data. -
Alternatively, you can use a
.llh
file next to the input data with a single text line containing a longitude, latitude and height coordinate (defined in the default EPSG 4326 reference). This will then be used as a topocentric reference to position your model in the world. -
You can set a fallback model reference to be used when no reference information can be found
next to the input data: see
setDefaultModelReference(com.luciad.model.ILcdModelReference)
.decoder.setDefaultModelReference(fallbackModelReference);
If no geo-reference information can be found with any of these strategies, then the data will be loaded in its
original, non-georeferenced coordinate system.
Note: Data that is decoded in its original coordinate system, can not be visualized on a
geographical map. The dataset must be geo-located with an external tool, after conversion has been done.
This is equivalent to setting a TLcdCartesianReference
as fallback reference:
decoder.setDefaultModelReference(new TLcdCartesianReference(TLcdDistanceUnit.METRE_UNIT,
TLcdDistanceUnit.METRE_UNIT,
TLcdDistanceUnit.METRE_UNIT));
Model descriptor
- The type name of the model descriptor is "Binz".
Model structure
This decoder can create 2 different kind of models:
- The geometry model: this model contains the geometry. The display name has the suffix "[GEOMETRY]"
- The features model: this model contains the properties of the elements, together with their bounding box.
This model is a
TLcd2DBoundsIndexedModel
, its display name has the suffix "[FEATURES]"
With the TLcdBIMDataSource
data source, it's possible to specify the model type for the
decodeSource(ILcdDataSource)
and decodeModelMetadata(ILcdDataSource)
methods.
The geometry type is assumed for the decode(String)
and decodeModelMetadata(String)
methods.
The possibility to decode 2 different models is also reflected through the discoverDataSources(java.lang.String)
method:
it provides 2 ILcdDataSource
instances, one for the geometry model and one for the features model, that
can both be decoded using the decodeSource(ILcdDataSource)
} method.
Model elements
The objects in the model depend on the type of the model.
- The geometry model: this model contains elements that do not implement any public LuciadLightspeed
API. However, this model can be used as input for the
TLcdOGC3DTilesModelEncoder
- The features model: this model contains elements implementing the
ILcdDataObject
and theILcdExtrudedShape
interfaces. They are also annotated with aTLcdPrimaryKeyAnnotation
annotation so this model can for instance be used as input for theTLcdGeoJsonModelEncoder
or other encoders supportingILcdDataObject
s
Sample code
ILcdModelDecoder decoder = new TLcdBinzModelDecoder();
ILcdModel model = decoder.decode(sourceName);
Thread safety
- The decoding of models is thread-safe.
- The decoded models are thread-safe for read access.
- Since:
- 2020.0
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
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 passedILcdDataSource
.boolean
canDecodeSource
(String aSourceName) Checks whether this model decoder can decode the specified data source.Creates a new model from the given data source.decodeFeatures
(String aSourceName) Creates a model with a single domain object per Binz feature.decodeModelMetadata
(ILcdDataSource aDataSource) Decodes metadata for the specified data source.decodeModelMetadata
(String aSourceName) Decodes metadata for the specified data source.decodeSource
(ILcdDataSource aDataSource) Creates a new model from the given data source.List
<? extends ILcdDataSource> discoverDataSources
(String aPath) Retrieves a set of model-specificILcdDataSource
instances.Get the default model reference.Returns a short, displayable name for the format that is decoded by thisILcdModelDecoder
.void
removeStatusListener
(ILcdStatusListener aListener) Removes the specified listener so it is no longer notified.void
setDefaultModelReference
(ILcdModelReference aModelReference) Set the default model reference.
-
Field Details
-
TYPE_NAME
The type name for the decoded models.- See Also:
-
-
Constructor Details
-
TLcdBinzModelDecoder
public TLcdBinzModelDecoder()Create a newTLcdBinzModelDecoder
.
-
-
Method Details
-
getDisplayName
Description copied from interface:ILcdModelDecoder
Returns a short, displayable name for the format that is decoded by thisILcdModelDecoder
.- Specified by:
getDisplayName
in interfaceILcdModelDecoder
- Returns:
- the displayable name of this
ILcdModelDecoder
.
-
setDefaultModelReference
Set the default model reference. This is a fallback reference that will be used when no reference is found next to the input. If not changed, aTLcdCartesianReference
will be used as fallback: when no reference is found, the data will be loaded in its original non-georeferenced coordinate system. Note that you will not be able to visualize the data on a geographical map. If the default model reference is set tonull
, and no reference information can be found, the decode(java.lang.String) will fail. For more details, see the class javadoc.- Parameters:
aModelReference
- the model reference used as a default, ornull
if no custom default model reference should be set.
-
getDefaultModelReference
Get the default model reference.- Returns:
- the default model reference, or
null
if no default model reference is set. - See Also:
-
addStatusListener
Description copied from interface: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.- Specified by:
addStatusListener
in interfaceILcdStatusSource
- Parameters:
aListener
- The listener to be notified when the status has changed.
-
removeStatusListener
Description copied from interface:ILcdStatusSource
Removes the specified listener so it is no longer notified.- Specified by:
removeStatusListener
in interfaceILcdStatusSource
- Parameters:
aListener
- The listener to remove.
-
canDecodeSource
Description copied from interface:ILcdModelDecoder
Checks whether this model decoder can decode the specified data source. It is acceptable for this method to returntrue
for a source name whiledecode
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 interfaceILcdModelDecoder
- 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
Description copied from interface:ILcdModelDecoder
Creates a new model from the given data source.- Specified by:
decode
in interfaceILcdModelDecoder
- 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
Description copied from interface:ILcdModelDecoder
Decodes 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:
decodeModelMetadata
in interfaceILcdModelDecoder
- Parameters:
aSourceName
- the data source to be decoded; typically a file name or a URL.- Returns:
- the model metadata for the data source, never null.
- Throws:
IOException
- if the metadata cannot be decoded for some reason.- See Also:
-
decodeModelMetadata
Description copied from interface:ILcdModelDecoder
Decodes 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:
decodeModelMetadata
in 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:
-
canDecodeSource
Description copied from interface: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 aTLcdDataSource
.The default implementation of this method will check if the given
ILcdDataSource
is aTLcdDataSource
. If not, this method returns false. Otherwise, it delegates the source to theILcdModelDecoder.canDecodeSource(String)
method.- Specified by:
canDecodeSource
in interfaceILcdModelDecoder
- Parameters:
aDataSource
- theILcdModelSource
to be verified.- Returns:
true
if this decoder can likely decode the data specified byaDataSource
,false
otherwise.- See Also:
-
decodeSource
Description copied from interface:ILcdModelDecoder
Creates a new model from the given data source.
By default, this method:
- Throws a
NullPointerException
when anull
data source is passed. - Delegates to the
ILcdModelDecoder.decode(String)
method when aTLcdDataSource
is passed. - Throws an IOException in other case.
- Specified by:
decodeSource
in interfaceILcdModelDecoder
- Parameters:
aDataSource
- theILcdDataSource
to be decoded.- 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 decodeSource(ILcdDataSource aDataSource) throws IOException { try { // Perform decoding ... } catch (RuntimeException e) { throw new IOException(e); } }
- See Also:
- Throws a
-
discoverDataSources
Description copied from interface:ILcdModelDecoder
Retrieves a set of model-specific
ILcdDataSource
instances.By default, this method:
- returns a list containing at least a single
TLcdDataSource
that contains a reference to the supplied path, whenILcdModelDecoder.canDecodeSource(String)
returnstrue
for the supplied path. - throws an
IOException
whenILcdModelDecoder.canDecodeSource(String)
returnsfalse
for the supplied path.
ILcdDataSource
, for instance, if the path references a collection of data sources.An example where this is useful is for container formats, such as NetCDF. A NetCDF file can contain multiple measurement layers. This
ILcdModelDecoder.discoverDataSources(String)
method allows you to distinguish between them usingILcdDataSource
s, where each measurement layer can be referenced to and decoded separately usingILcdModelDecoder.decodeSource(ILcdDataSource)
- Specified by:
discoverDataSources
in 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
true
forILcdModelDecoder.canDecodeSource(String)
, it will return a list containing at least a singleILcdDataSource
. - Throws:
IOException
- If this model decoder returnsfalse
forILcdModelDecoder.canDecodeSource(String)
or if any exceptions caused by IO problems or invalid data occur.
- returns a list containing at least a single
-
decodeFeatures
Creates a model with a single domain object per Binz feature. The domain objects are aILcdDataObject
(containing metadata such as linkage, moniker, aabb) andILcdExtrudedShape
(expressing the bounds of the feature). The reference is always EPSG:4326, except if the input data is non-referenced, then the input reference is used. This model can be used to serve feature information over WFS, or encode toGeoJson
. If no feature index information (tree0000.idx.bin
) is available, this method fails withIllegalArgumentException
.- Parameters:
aSourceName
- The .binz file or tree0000.bin file or a combined .binz.zip file- Returns:
- A standard feature model containing data objects and shapes.
- Throws:
IOException
- If the data cannot be read.IllegalArgumentException
- If notree0000.idx.bin
is present.
-