@LcdService(service=ILcdModelDecoder.class, priority=20000) public class TLcdMIFModelDecoder extends Object implements ILcdModelDecoder, ILcdInputStreamFactoryCapable
ILcdModelDecoder
decodes MIF (MapInfo Interchange Format) 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
.
inputStreamFactory
of this decoder.
ILcdModel
or a
ILcd2DBoundsIndexedModel
, depending on the useIndexedModel
property.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
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.
useIndexedModel
property. The default is true
.readWithFeatures
property. The default is true
.
When no MID file is available the model descriptor will return 0 as the number
of features.
ILcdModelDecoder decoder = new TLcdMIFModelDecoder();
ILcdModel model = decoder.decode( "vector.mif" );
TLcdMIFModelReferenceParser
Constructor and Description |
---|
TLcdMIFModelDecoder()
Creates 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 fixed
TLcdDataModel . |
Modifier and Type | Method and Description |
---|---|
boolean |
canDecodeSource(String aSourceName)
Checks whether this model decoder can decode the specified data source.
|
ILcdModel |
decode(String aSourceName)
Creates a new model from the given data source.
|
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
ILcdInputStreamFactory to collect data as input for
model creation. |
boolean |
getUseIndexedModel()
Indicates whether an indexed model should be produced.
|
boolean |
isTraceOn()
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
boolean |
isUseFloatPoint()
Returns whether the decoder returns shapes containing TLcdXYFloatPoints
instead of the normal TLcdXYPoints.
|
boolean |
isWithFeatures()
Returns whether the decode will read the object's features or not.
|
void |
readColumns()
Reads a column description by reading its name and type.
|
static void |
setClassTraceOn(boolean aClassTraceOn)
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
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
aInputStreamFactory as
ILcdInputStreamFactory on this
TLcdMIFModelDecoder . |
void |
setTraceOn(boolean aTraceOn)
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
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 is
true (default), this decoder will create a
TLcd2DBoundsIndexedModel when decoding a MIF File; otherwise it will create a
TLcdVectorModel . |
void |
setWithFeatures(boolean aReadWithFeatures)
Sets whether the features of the objects should be read or not.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
canDecodeSource, decodeModelMetadata, decodeModelMetadata, decodeSource, discoverDataSources
public TLcdMIFModelDecoder()
public TLcdMIFModelDecoder(int aRatioPoint)
aRatioPoint
- the ratio of the number of points to read (e.g. 3 if you only want to
read 1 in 3 points).public TLcdMIFModelDecoder(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 static void setClassTraceOn(boolean aClassTraceOn)
true
then all log messages are recorded, otherwise only
the informative, warning and error messages are recorded.aClassTraceOn
- if true then all log messages are recorded,
otherwise only the informative, warning and error messages are recorded.public void setTraceOn(boolean aTraceOn)
true
or false
as argument automatically turns
off tracing for all other class instances for which
setTraceOn
has not been called.
If the argument is false
then only the informative, warning
and error log messages are recorded.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.public boolean isTraceOn()
true
if tracing is enabled for this class.public void setWithFeatures(boolean aReadWithFeatures)
aReadWithFeatures
- boolean indicating whether the features
of the objects should be read or not.public boolean isWithFeatures()
public void setUseFloatPoint(boolean aUseFloatPoint)
aUseFloatPoint
- boolean to indicate whether the decoder should return
shapes containing TLcdXYFloatPoints instead of the normal TLcdXYPoints.public boolean isUseFloatPoint()
public void setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
aInputStreamFactory
as
ILcdInputStreamFactory
on this
TLcdMIFModelDecoder
.
aInputStreamFactory
is then used for retrieving
InputStream
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 to null
.
This can be used to define a specific way of transferring
data from the source to this TLcdMIFModelDecoder
,
e.g., in an encrypted way.
setInputStreamFactory
in interface ILcdInputStreamFactoryCapable
aInputStreamFactory
- an ILcdInputStreamFactory object specifying the input stream factory value.ILcdInputStreamFactory
,
getInputStreamFactory()
public ILcdInputStreamFactory getInputStreamFactory()
ILcdInputStreamFactory
to collect data as input for
model creation.getInputStreamFactory
in interface ILcdInputStreamFactoryCapable
ILcdInputStreamFactory
set on this
TLcdMIFModelDecoder
setInputStreamFactory(com.luciad.io.ILcdInputStreamFactory)
public void setUseIndexedModel(boolean aUseIndexedModel)
true
(default), this decoder will create a
TLcd2DBoundsIndexedModel
when decoding a MIF File; otherwise it will create a
TLcdVectorModel
.
Note: when the decoded model is empty a TLcdVectorModel will still be returned.aUseIndexedModel
- true to make this object use indexed model.getUseIndexedModel()
public boolean getUseIndexedModel()
setUseIndexedModel(boolean)
public void setFeatureIndexForDisplayName(int aFeatureIndexForDisplayName)
aFeatureIndexForDisplayName
- the index of the feature to use for the default display name.getFeatureIndexForDisplayName()
public int getFeatureIndexForDisplayName()
setFeatureIndexForDisplayName(int)
public String getDisplayName()
ILcdModelDecoder
ILcdModelDecoder
.getDisplayName
in interface ILcdModelDecoder
ILcdModelDecoder
.public boolean canDecodeSource(String aSourceName)
ILcdModelDecoder
true
for a source name while decode
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.
canDecodeSource
in interface ILcdModelDecoder
aSourceName
- the data source to be verified; typically a file name or a URL.true
if this decoder can likely decode the data specified by the source name, false
otherwise.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)
public void readColumns() throws IOException
IOException
- when a column could not be read.