Class TLcdMAPModelDecoder
- All Implemented Interfaces:
ILcdInputStreamFactoryCapable
,ILcdModelDecoder
ILcdModelDecoder
decodes MAP (native binary MapInfo) files.
Input files
File | Required | Entry point | Description |
---|---|---|---|
*.map | x | x | MapInfo binary file containing the vector data |
*.tab | x |
File containing the names and data types of the attributes | |
*.dat | File containing the shape attributes |
Supported file transfer protocols
- This model decoder supports all transfer protocols that are supported by
the
inputStreamFactory
of this decoder.
Model structure
- This model decoder creates a model per MAP file.
- All models returned by this model decoder implement
ILcd2DBoundsIndexedModel
.
Model descriptor
- All models returned by this model decoder have a
TLcdMIFModelDescriptor
. - The type name of the model descriptor is
MIF
. - The model descriptor implements
ILcdDataModelDescriptor
. This means that the model elements produced by this model decoder have a matchingTLcdDataType
, each with their ownTLcdDataProperty
. - The model descriptor also implements
ILcdFeaturedDescriptor
for backwards compatibility. This is the old version ofILcdDataModelDescriptor
Model elements
The following MAP elements are currently supported:MAP element type | MAP element name | Decoded object |
---|---|---|
1, 2 | POINT |
|
4, 5 | LINE | containing
|
7, 8 | PLINE | containing
|
10, 11 | ARC | containing
|
13, 14 | REGION | containing
|
16, 17 | TEXT | containing
|
19, 20 | RECT | containing
|
22, 23 | ROUNDRECT | containing
|
25, 26 | ELLIPSE | containing
|
37, 38 | (MULTI) PLINE | containing
|
40, 41 | (TRUETYPE) POINT |
|
43, 44 | (CUSTOM) POINT |
|
46, 47 | (LARGE) REGION | containing
|
49, 50 | (LARGE, MULTI) PLINE | containing
|
52, 53 | (LARGE) MULTIPOINT | containing
|
55, 56 | COLLECTION | containing ,
|
All model elements implement the ILcdMIFShape
interface. This interface extends
both
the
ILcdFeatured
interface (for backwards compatibility reasons) as the
ILcdDataObject
interface. While both interfaces can be used to obtain the properties of a model element,
ILcdDataObject
is the preferred interface for interacting with model elements in a
generic way.
All elements in a model will have the TLcdMIFDataTypes.graphicalObjectType
TLcdDataType
as their data type.
Sample code
ILcdModelDecoder decoder = new TLcdMAPModelDecoder();
ILcdModel model = decoder.decode( "vector.map" );
Thread safety
- The decoding of models is not thread-safe.
- The decoded models are thread-safe for read access.
Supported versions and specifications
- The official MapInfo MAP format specifications are not available. The current implementation is based on information freely available on Internet. See for example the MapInfo Dataset Format page.
Known limitations
- Due to closed specifications, some shape types may or may not be correctly supported.
- See Also:
-
Constructor Summary
ConstructorDescriptionConstructs a new MAP model decoder.TLcdMAPModelDecoder
(String aDataModelName) Constructs a new MAP model decoder with a fixedTLcdDataModel
. -
Method Summary
Modifier and TypeMethodDescriptionboolean
canDecodeSource
(String aSourceName) Returns whether this decoder can handle data from this input.Creates a new model from the given data source.Returns the default extension for MAP files: map .Returns a short, displayable name for the format that is decoded by thisILcdModelDecoder
.int
Returns the index of the feature to be used for displaying the name of objects in models created by this decoder.Returns the input stream factory used to handle data input.boolean
Returns whether the decoder returns shapes containing TLcdXYFloatPoints instead of the normal TLcdXYPoints.void
setCharacterSet
(String aCharacterSet) Sets the character set to use.void
setFeatureIndexForDisplayName
(int aFeatureIndexForDisplayName) Sets the index of the feature to be used as default display name (e.g. the feature value to be used by the Object.toString() method).void
setInputStreamFactory
(ILcdInputStreamFactory aInputStreamFactory) Sets the input stream factory to handle data input.void
setUseFloatPoint
(boolean aUseFloatPoint) Sets whether the decoder should return shapes containing TLcdXYFloatPoints instead of the normal TLcdXYPoints.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, decodeModelMetadata, decodeSource, discoverDataSources
-
Constructor Details
-
TLcdMAPModelDecoder
public TLcdMAPModelDecoder()Constructs a new MAP model decoder. -
TLcdMAPModelDecoder
Constructs a new MAP model decoder with a fixedTLcdDataModel
. All files that are decoded with this decoder will use exactly the same data model. This data model will have the given name. It is the responsibility of the caller of this method to ensure that all files that are decoded have exactly the same structure. The result of decoding files with different structures with a fixed data model is unspecified.
-
-
Method Details
-
getDefaultExtension
Returns the default extension for MAP files: map .- Returns:
- "map".
-
setCharacterSet
Sets the character set to use.- Parameters:
aCharacterSet
- the character set to use to decode MAP files. The supported character sets depend on the JVM implementation and can be found atString(byte[], String)
.
-
getCharacterSet
-
setUseFloatPoint
public void setUseFloatPoint(boolean aUseFloatPoint) Sets whether the decoder should return shapes containing TLcdXYFloatPoints instead of the normal TLcdXYPoints.- Parameters:
aUseFloatPoint
- boolean indicating whether the decoder should return shapes containing TLcdXYFloatPoints instead of the normal TLcdXYPoints.
-
isUseFloatPoint
public boolean isUseFloatPoint()Returns whether the decoder returns shapes containing TLcdXYFloatPoints instead of the normal TLcdXYPoints.- Returns:
- whether the decoder returns shapes containing TLcdXYFloatPoints instead of the normal TLcdXYPoints.
-
setInputStreamFactory
Sets the input stream factory to handle data input.- Specified by:
setInputStreamFactory
in interfaceILcdInputStreamFactoryCapable
- Parameters:
aInputStreamFactory
- the factory to handle the data input.- See Also:
-
getInputStreamFactory
Returns the input stream factory used to handle data input.- Specified by:
getInputStreamFactory
in interfaceILcdInputStreamFactoryCapable
- Returns:
- the input stream factory used to handle data input.
- See Also:
-
setFeatureIndexForDisplayName
public void setFeatureIndexForDisplayName(int aFeatureIndexForDisplayName) Sets the index of the feature to be used as default display name (e.g. the feature value to be used by the Object.toString() method). This index refers to the feature ordering in the MID file to decode. The default value is 0.
Note that this method also works for the
ILcdDataObject
interface, where the index will match the index of the property for a data object.- Parameters:
aFeatureIndexForDisplayName
- the index of the feature to use for the default display name.- See Also:
-
getFeatureIndexForDisplayName
public int getFeatureIndexForDisplayName()Returns the index of the feature to be used for displaying the name of objects in models created by this decoder.
Note that this method also works for the
ILcdDataObject
interface, where the index will match the index of the property for a data object.- Returns:
- the index of the feature to be used for displaying the name of objects in models created by this decoder.
- See Also:
-
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
Returns whether this decoder can handle data from this input.- Specified by:
canDecodeSource
in interfaceILcdModelDecoder
- Parameters:
aSourceName
- the name of the input to check.- Returns:
true
if the file extension is <defaultExtension> or <defaultExtension>.gz, <code>false</code> otherwise (<defaultExtension> is the String returned by getDefaultExtension).- 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:
-