Class TLcdMIFModelDecoder

java.lang.Object
com.luciad.format.mif.TLcdMIFModelDecoder
All Implemented Interfaces:
ILcdInputStreamFactoryCapable, ILcdModelDecoder

@LcdService(service=ILcdModelDecoder.class, priority=20000) public class TLcdMIFModelDecoder extends Object implements ILcdModelDecoder, ILcdInputStreamFactoryCapable
This 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 a ILcd2DBoundsIndexedModel, depending on the useIndexedModel 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 matching TLcdDataType, each with their own TLcdDataProperty.
  • The model descriptor also implements ILcdFeaturedDescriptor for backwards compatibility. This is the old version of ILcdDataModelDescriptor

Model elements

The following MIF elements are currently supported:

MIF element nameDecoded object
POINT TLcdMIFPoint
LINE TLcdMIFPLine containing ILcdPolyline
PLINE TLcdMIFPLine containing ILcdPolyline
REGION TLcdMIFRegion containing ILcdPolygon
ARC TLcdMIFPLine containing ILcdArc
TEXT TLcdMIFText containing ILcdText
RECT TLcdMIFRegion containing ILcdBounds
ROUNDRECT TLcdMIFRegion containing ILcdBounds
ELLIPSE TLcdMIFRegion containing ILcdEllipse
MULTIPOINT TLcdMIFMultipoint containing ILcdPolypoint
COLLECTION TLcdMIFCollection containing TLcdMIFRegion, TLcdMIFPLine, and TLcdMIFMultipoint

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 is true.
  • Features can be read from the corresponding MID files, depending on the readWithFeatures property. The default is true. 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 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

      public TLcdMIFModelDecoder(String aDataModelName)
      Constructs a new MIF model decoder with a fixed 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.

  • 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 is true 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 either 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.
      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.
      Returns true 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

      public void setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
      Sets 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.

      Specified by:
      setInputStreamFactory in interface ILcdInputStreamFactoryCapable
      Parameters:
      aInputStreamFactory - an ILcdInputStreamFactory object specifying the input stream factory value.
      See Also:
    • getInputStreamFactory

      public ILcdInputStreamFactory getInputStreamFactory()
      Returns the ILcdInputStreamFactory to collect data as input for model creation.
      Specified by:
      getInputStreamFactory in interface ILcdInputStreamFactoryCapable
      Returns:
      the current ILcdInputStreamFactory set on this TLcdMIFModelDecoder
      See Also:
    • setUseIndexedModel

      public 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. 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

      public String getDisplayName()
      Description copied from interface: ILcdModelDecoder
      Returns a short, displayable name for the format that is decoded by this ILcdModelDecoder.
      Specified by:
      getDisplayName in interface ILcdModelDecoder
      Returns:
      the displayable name of this ILcdModelDecoder.
    • canDecodeSource

      public boolean canDecodeSource(String aSourceName)
      Description copied from interface: ILcdModelDecoder
      Checks whether this model decoder can decode the specified data source. It is acceptable for this method to return 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.

      Specified by:
      canDecodeSource in interface ILcdModelDecoder
      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

      public ILcdModel decode(String aSourceName) throws IOException
      Description copied from interface: ILcdModelDecoder
      Creates a new model from the given data source.
      Specified by:
      decode in interface ILcdModelDecoder
      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

      public void readColumns() throws IOException
      Reads a column description by reading its name and type.
      Throws:
      IOException - when a column could not be read.