@LcdService(service=ILcdModelDecoder.class, priority=20000) public class TLcdPOLModelDecoder extends Object implements ILcdModelDecoder, ILcdInputStreamFactoryCapable
This ILcdModelDecoder
allows to decode Polygon files produced by the TAAM
application of the Preston Group PTY Ltd.
The implementation decodes polygons as ILcdEditablePOLGeometry
objects.
Whether they are open or closed can be retrieved through the method ILcdPOLGeometry.isClosed()
.
All ILcdPOLGeometry
instances implement both the ILcdFeatured
and the ILcdDataObject
interface. The ILcdDataObject
interface
was implemented to support the new unified domain model across all LuciadLightspeed products. The ILcdFeatured
interface exists
for backwards compatibility.
The TLcdDataModel
used by all decoded models of this model decoder can
be retrieved by calling TLcdPOLDataTypes.getDataModel()
NOTE: the current implementation does not support grouping of elements as indicated with {} brackets in the POL files. Grouped objects are ignored. NOTE: the decoder stores the color index for every element in the model, though no mechanism is present to add a color table to the model to map the index to a color.
Modifier and Type | Field and Description |
---|---|
static String |
DISPLAY_NAME |
static String |
TYPE_NAME |
Constructor and Description |
---|
TLcdPOLModelDecoder() |
Modifier and Type | Method and Description |
---|---|
boolean |
canDecodeSource(String aSourceName)
Returns
true when the source ends with '.pol' (case insensitive) and when the file
starts with "%Gtool". |
protected Object |
createGeometry(boolean aClosed,
String aName,
String aType,
boolean aSetColorFlag,
int aColorIndex,
String aAltitudeUnit,
double aMinAltitude,
double aMaxAltitude,
ILcd2DEditablePointList aPointList)
Create an element for the model, based on the given parameters.
|
protected ILcdModelDescriptor |
createModelDescriptor(String aSourceName,
String aType,
String aModelDisplayName,
ILcdModel aModel,
ILcdPOLTypeTable aPOLTypeTable,
ILcdBounds aModelBounds) |
protected InputStream |
createSourceInputStream(String aSourceName)
Creates an input stream to retrieve the data at the given location.
|
ILcdModel |
decode(String aSourceName)
Creates a new model from the given data source.
|
String |
getDisplayName()
Returns the display name for this decoder (e.g. when displayed in a list of decoders).
|
ILcdInputStreamFactory |
getInputStreamFactory()
Returns the input stream factory that is used.
|
com.luciad.internal.format.pol.TLinPOLTypeTable |
getTypeTable() |
protected String |
makeModelDisplayName(String aSourceName)
Creates a display name for the model descriptor based on the data source name.
|
static void |
setClassTraceOn(boolean aClassTraceOn)
Deprecated.
This method has been deprecated. It is recommended to use the standard Java logging
framework directly.
|
void |
setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
Sets the input stream factory to be used.
|
void |
setTypeTable(com.luciad.internal.format.pol.TLinPOLTypeTable aTypeTable) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
canDecodeSource, decodeModelMetadata, decodeModelMetadata, decodeSource, discoverDataSources
public static final String TYPE_NAME
public static final String DISPLAY_NAME
public com.luciad.internal.format.pol.TLinPOLTypeTable getTypeTable()
public void setTypeTable(com.luciad.internal.format.pol.TLinPOLTypeTable aTypeTable)
public String getDisplayName()
getDisplayName
in interface ILcdModelDecoder
DISPLAY_NAME
public ILcdInputStreamFactory getInputStreamFactory()
ILcdInputStreamFactoryCapable
getInputStreamFactory
in interface ILcdInputStreamFactoryCapable
public void setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
ILcdInputStreamFactoryCapable
setInputStreamFactory
in interface ILcdInputStreamFactoryCapable
aInputStreamFactory
- the input stream factory to be used.public boolean canDecodeSource(String aSourceName)
true
when the source ends with '.pol' (case insensitive) and when the file
starts with "%Gtool".canDecodeSource
in interface ILcdModelDecoder
aSourceName
- a data source; typically a file name or a URL.true
when the source ends with '.pol' (case insensitive) and when the file
starts with "%Gtool", false
otherwise.ILcdModelDecoder.decode(String)
,
ILcdModelDecoder.decodeModelMetadata(String)
protected InputStream createSourceInputStream(String aSourceName) throws IOException
TLcdIOUtil
is
used.aSourceName
- the location to retrieve the data from.IOException
- when an I/O error occurs while retrieving the data.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 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.protected ILcdModelDescriptor createModelDescriptor(String aSourceName, String aType, String aModelDisplayName, ILcdModel aModel, ILcdPOLTypeTable aPOLTypeTable, ILcdBounds aModelBounds)
protected String makeModelDisplayName(String aSourceName)
aSourceName
- the location where the data was retrieved from.protected Object createGeometry(boolean aClosed, String aName, String aType, boolean aSetColorFlag, int aColorIndex, String aAltitudeUnit, double aMinAltitude, double aMaxAltitude, ILcd2DEditablePointList aPointList)
TLcdPOLGeometryFactory.createClosedGeometry(java.lang.String, java.lang.String, boolean, int, java.lang.String, double, double, com.luciad.shape.shape2D.ILcd2DEditablePointList)
or TLcdPOLGeometryFactory.createOpenGeometry(java.lang.String, java.lang.String, boolean, int, java.lang.String, double, double, com.luciad.shape.shape2D.ILcd2DEditablePointList)
depending on the value of aClosed.