Class TLcdMIFModelDecoder
- All Implemented Interfaces:
ILcdInputStreamFactoryCapable
,ILcdModelDecoder
ILcdModelDecoder
decodes MIF (MapInfo Interchange Format) files.
Input files
File | Required | Entry point | Description |
---|---|---|---|
*.mif | x | x | MapInfo file containing the vector data |
*.mid | Database file containing the feature attributes of the shapes |
The model reference is obtained using a TLcdMIFModelReferenceParser
.
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 MIF file.
- A model returned by this decoder may be either a simple
ILcdModel
or aILcd2DBoundsIndexedModel
, depending on theuseIndexedModel
property.
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 MIF elements are currently supported:
MIF element name | Decoded object |
---|---|
POINT |
|
LINE | containing
|
PLINE | containing
|
REGION | containing
|
ARC | containing
|
TEXT | containing
|
RECT | containing
|
ROUNDRECT | containing
|
ELLIPSE | containing
|
MULTIPOINT | containing
|
COLLECTION | containing ,
, and
|
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.
Useful settings
- The model can be spatially indexed or not, depending on the
useIndexedModel
property. The default istrue
. - Features can be read from the corresponding MID files, depending on the
readWithFeatures
property. The default istrue
. When no MID file is available the model descriptor will return 0 as the number of features.
Sample code
ILcdModelDecoder decoder = new TLcdMIFModelDecoder();
ILcdModel model = decoder.decode( "vector.mif" );
Thread safety
- The decoding of models is not thread-safe.
- The decoded models are thread-safe for read access.
Supported versions and specifications
- See Also:
-
Constructor Summary
ConstructorDescriptionCreates a model decoder to decode MIF files.TLcdMIFModelDecoder
(int aRatioPoint) Creates a model decoder to decode MIF files.TLcdMIFModelDecoder
(String aDataModelName) Constructs a new MIF model decoder with a fixedTLcdDataModel
. -
Method Summary
Modifier and TypeMethodDescriptionboolean
canDecodeSource
(String aSourceName) Checks whether this model decoder can decode the specified data source.Creates a new model from the given data source.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 theILcdInputStreamFactory
to collect data as input for model creation.boolean
Indicates whether an indexed model should be produced.boolean
Deprecated.This method has been deprecated.boolean
Returns whether the decoder returns shapes containing TLcdXYFloatPoints instead of the normal TLcdXYPoints.boolean
Returns whether the decode will read the object's features or not.void
Reads a column description by reading its name and type.static void
setClassTraceOn
(boolean aClassTraceOn) Deprecated.This method has been deprecated.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) SetsaInputStreamFactory
asILcdInputStreamFactory
on thisTLcdMIFModelDecoder
.void
setTraceOn
(boolean aTraceOn) Deprecated.This method has been deprecated.void
setUseFloatPoint
(boolean aUseFloatPoint) Sets whether the decoder should return shapes containing TLcdXYFloatPoints instead of the normal TLcdXYPoints.void
setUseIndexedModel
(boolean aUseIndexedModel) When this property istrue
(default), this decoder will create aTLcd2DBoundsIndexedModel
when decoding a MIF File; otherwise it will create aTLcdVectorModel
.void
setWithFeatures
(boolean aReadWithFeatures) Sets whether the features of the objects should be read or not.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
-
TLcdMIFModelDecoder
public TLcdMIFModelDecoder()Creates a model decoder to decode MIF files. -
TLcdMIFModelDecoder
public TLcdMIFModelDecoder(int aRatioPoint) Creates a model decoder to decode MIF files.- Parameters:
aRatioPoint
- the ratio of the number of points to read (e.g. 3 if you only want to read 1 in 3 points).
-
TLcdMIFModelDecoder
Constructs a new MIF 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
-
setClassTraceOn
public static void setClassTraceOn(boolean aClassTraceOn) Deprecated.This method has been deprecated. It is recommended to use the standard Java logging framework directly.Enables tracing for all instances of this class. If the argument istrue
then all log messages are recorded, otherwise only the informative, warning and error messages are recorded.- Parameters:
aClassTraceOn
- if true then all log messages are recorded, otherwise only the informative, warning and error messages are recorded.
-
setTraceOn
public void setTraceOn(boolean aTraceOn) Deprecated.This method has been deprecated. It is recommended to use the standard Java logging framework directly.Enables tracing for this class instance. Calling this method with eithertrue
orfalse
as argument automatically turns off tracing for all other class instances for whichsetTraceOn
has not been called. If the argument isfalse
then only the informative, warning and error log messages are recorded.- Parameters:
aTraceOn
- if true then all log messages are recorded for this instance. If false, then only the informative, warning and error log messages are recorded.
-
isTraceOn
public boolean isTraceOn()Deprecated.This method has been deprecated. It is recommended to use the standard Java logging framework directly.Returnstrue
if tracing is enabled for this class.- Returns:
- true if tracing is enabled for this class, false otherwise.
-
setWithFeatures
public void setWithFeatures(boolean aReadWithFeatures) Sets whether the features of the objects should be read or not.- Parameters:
aReadWithFeatures
- boolean indicating whether the features of the objects should be read or not.
-
isWithFeatures
public boolean isWithFeatures()Returns whether the decode will read the object's features or not.- Returns:
- whether the decode will read the object's features or not.
-
setUseFloatPoint
public void setUseFloatPoint(boolean aUseFloatPoint) Sets whether the decoder should return shapes containing TLcdXYFloatPoints instead of the normal TLcdXYPoints.- Parameters:
aUseFloatPoint
- boolean to indicate 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
SetsaInputStreamFactory
asILcdInputStreamFactory
on thisTLcdMIFModelDecoder
.aInputStreamFactory
is then used for retrievingInputStream
objects when decoding a mif file, and its corresponding mid file.To use the default way of creating an
InputStream
leave this property unset or set it tonull
.This can be used to define a specific way of transferring data from the source to this
TLcdMIFModelDecoder
, e.g., in an encrypted way.- Specified by:
setInputStreamFactory
in interfaceILcdInputStreamFactoryCapable
- Parameters:
aInputStreamFactory
- an ILcdInputStreamFactory object specifying the input stream factory value.- See Also:
-
getInputStreamFactory
Returns theILcdInputStreamFactory
to collect data as input for model creation.- Specified by:
getInputStreamFactory
in interfaceILcdInputStreamFactoryCapable
- Returns:
- the current
ILcdInputStreamFactory
set on thisTLcdMIFModelDecoder
- See Also:
-
setUseIndexedModel
public void setUseIndexedModel(boolean aUseIndexedModel) When this property istrue
(default), this decoder will create aTLcd2DBoundsIndexedModel
when decoding a MIF File; otherwise it will create aTLcdVectorModel
. Note: when the decoded model is empty a TLcdVectorModel will still be returned.- Parameters:
aUseIndexedModel
- true to make this object use indexed model.- See Also:
-
getUseIndexedModel
public boolean getUseIndexedModel()Indicates whether an indexed model should be produced.- Returns:
- whether to produce an indexed model.
- 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.- 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.- 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
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:
-
readColumns
Reads a column description by reading its name and type.- Throws:
IOException
- when a column could not be read.
-