Package com.luciad.format.mgcp
Class TLcdMGCPModelDecoder
java.lang.Object
com.luciad.format.mgcp.TLcdMGCPModelDecoder
- All Implemented Interfaces:
ILcdModelDecoder,ILcdStatusSource
@LcdService(service=ILcdModelDecoder.class,
priority=20000)
public final class TLcdMGCPModelDecoder
extends Object
implements ILcdModelDecoder, ILcdStatusSource
This model decoder decodes MGCP. MGCP is a multinational program to
collect geospatial data worldwide.
MGCP data is vector data describing features in a 1x1 degree cell, exchanged using the ESRI Shapefile specification.
Each Shapefile (+ according database file) contains features of a single type and geometry. There is an overall
metadata file (*.xml) linking all shp files for the cell, but also describing general things like the character
encoding used for labels.
We also support a .zip file containing both the metadata file (*.xml) and the shapefiles. Note that for large datasets
we advise to unzip the data first even though .zip files are supported.
Input
| File | Required | Entry point | Description |
|---|---|---|---|
| *.zip | x | x | A .zip file containing both the metadata file (*.xml) and the shapefiles. |
| *.xml | x | x | An xml-file with top level MGCP_Cell tag, containing references to SHP files according to the MGCP Data Packaging (TRD4 v4.5 20190208) specs. |
| *.shp | x | The SHP-files, referenced by the xml, containing shapes for a single MGCP feature. |
Supported transfer protocols
- This model decoder supports only direct file access.
Model structure
- This model decoder creates a model of type
TLcd2DBoundsIndexedModelListwith a delegate model for each shp file.
Model descriptor
- All models returned by this model decoder have a
ILcdDataModelDescriptor. - The type name of the model descriptor is "MGCP".
Model reference
- This model decoder retrieves its model references from the xml-file.
Model elements
- This model decoder creates a model containing
ILcdDataObjects. - Domain objects can have different data types, each based on the data type of the delegate shp file.
Sample code
ILcdModelDecoder decoder = new TLcdMGCPModelDecoder();
ILcdModel model = decoder.decode("file.xml");
Thread safety
- The decoding of models is thread-safe, as long as no properties are changed during the decoding.
- The decoded models are thread-safe for read access.
Supported versions and specifications
- MGCP 2.0.1 - specifications
- Since:
- 2020.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final StringThe model descriptor type for MGCP data, 'MGCP'. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddStatusListener(ILcdStatusListener aListener) Registers the given listener so it will receive status events from this source.booleancanDecodeSource(String aSourceName) Checks whether this model decoder can decode the specified data source.Creates a new model from the given data source.decodeModelMetadata(String aSourceName) Decodes metadata for the specified data source.Returns a short, displayable name for the format that is decoded by thisILcdModelDecoder.voidremoveStatusListener(ILcdStatusListener aListener) Removes the specified listener so it is no longer notified.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.luciad.model.ILcdModelDecoder
canDecodeSource, decodeModelMetadata, decodeSource, discoverDataSources
-
Field Details
-
TYPE_NAME
The model descriptor type for MGCP data, 'MGCP'.- See Also:
-
DEFAULT_EXTENSION
- See Also:
-
-
Constructor Details
-
TLcdMGCPModelDecoder
public TLcdMGCPModelDecoder()
-
-
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.
-
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:
-
decode
Description copied from interface:ILcdModelDecoderCreates a new model from the given data source.- Specified by:
decodein interfaceILcdModelDecoder- Parameters:
aSourceName- the data source to be decoded; typically a file name or a URL.- 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 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: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:
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:
-
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.
-