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
TLcd2DBoundsIndexedModelList
with 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
Modifier and TypeFieldDescriptionstatic final String
static final String
The model descriptor type for MGCP data, 'MGCP'. -
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
(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
.void
removeStatusListener
(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, wait
Methods 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: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
.
-
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:
-
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.
-