@LcdService(service=ILcdModelDecoder.class, priority=20000) public class TLcdMAPModelDecoder extends Object implements ILcdModelDecoder, ILcdInputStreamFactoryCapable
ILcdModelDecoder
decodes MAP (native binary MapInfo) 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 |
inputStreamFactory
of this decoder.
ILcd2DBoundsIndexedModel
.TLcdMIFModelDescriptor
.MIF
.ILcdDataModelDescriptor
. This means that the
model elements produced
by this model decoder have a matching TLcdDataType
, each with their own
TLcdDataProperty
.
ILcdFeaturedDescriptor
for backwards
compatibility. This
is the old version of ILcdDataModelDescriptor
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.
ILcdModelDecoder decoder = new TLcdMAPModelDecoder();
ILcdModel model = decoder.decode( "vector.map" );
TLcdMIFModelReferenceParser
Constructor and Description |
---|
TLcdMAPModelDecoder()
Constructs a new MAP model decoder.
|
TLcdMAPModelDecoder(String aDataModelName)
Constructs a new MAP model decoder with a fixed
TLcdDataModel . |
Modifier and Type | Method and Description |
---|---|
boolean |
canDecodeSource(String aSourceName)
Returns whether this decoder can handle data from this input.
|
ILcdModel |
decode(String aSourceName)
Creates a new model from the given data source.
|
String |
getCharacterSet() |
String |
getDefaultExtension()
Returns the default extension for MAP files: map .
|
String |
getDisplayName()
Returns a short, displayable name for the format that is decoded by this
ILcdModelDecoder . |
int |
getFeatureIndexForDisplayName()
Returns the index of the feature to be used for displaying the name of
objects in models created by this decoder.
|
ILcdInputStreamFactory |
getInputStreamFactory()
Returns the input stream factory used to handle data input.
|
boolean |
isUseFloatPoint()
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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
canDecodeSource, decodeModelMetadata, decodeModelMetadata, decodeSource, discoverDataSources
public TLcdMAPModelDecoder()
public TLcdMAPModelDecoder(String aDataModelName)
TLcdDataModel
.
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.public String getDefaultExtension()
public void setCharacterSet(String aCharacterSet)
aCharacterSet
- the character set to use to decode MAP files.
The supported character sets depend on the JVM implementation
and can be found at String.String(byte[], String)
.public String getCharacterSet()
public void setUseFloatPoint(boolean aUseFloatPoint)
aUseFloatPoint
- boolean indicating whether the decoder should return shapes
containing TLcdXYFloatPoints instead of the normal TLcdXYPoints.public boolean isUseFloatPoint()
public void setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
setInputStreamFactory
in interface ILcdInputStreamFactoryCapable
aInputStreamFactory
- the factory to handle the data input.getInputStreamFactory()
public ILcdInputStreamFactory getInputStreamFactory()
getInputStreamFactory
in interface ILcdInputStreamFactoryCapable
setInputStreamFactory(com.luciad.io.ILcdInputStreamFactory)
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.
aFeatureIndexForDisplayName
- the index of the feature to use for the
default display name.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.
setFeatureIndexForDisplayName(int)
public String getDisplayName()
ILcdModelDecoder
ILcdModelDecoder
.getDisplayName
in interface ILcdModelDecoder
ILcdModelDecoder
.public boolean canDecodeSource(String aSourceName)
canDecodeSource
in interface ILcdModelDecoder
aSourceName
- the name of the input to check.true
if the file extension is <defaultExtension> or
<defaultExtension>.gz, <code>false</code> otherwise (<defaultExtension> is the String
returned by getDefaultExtension).ILcdModelDecoder.decode(String)
,
ILcdModelDecoder.decodeModelMetadata(String)
public ILcdModel decode(String aSourceName) throws IOException
ILcdModelDecoder
decode
in interface ILcdModelDecoder
aSourceName
- the data source to be decoded; typically a file name or a URL.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 decode( String aSourceName ) throws IOException {
try (InputStream input = fInputStreamFactory.createInputStream(aSourceName)) {
// Perform decoding ...
} catch (RuntimeException e) {
throw new IOException(e);
}
}
InterruptedIOException
- When the thread on which this method is called is interrupted: it is recommended to stop the decoding
and throw an InterruptedIOException
.
This same exception can also be used if the decoder shows UI to the user, and the user cancels the decoding
through the UI.ILcdModelDecoder.canDecodeSource(String)