@LcdService(service=ILcdModelEncoder.class, priority=20000) public class TLcdSHPModelEncoder extends Object implements ILcdModelEncoder, ILcdOutputStreamFactoryCapable
ILcdModelEncoder
creates SHP (ESRI Shapefile) files from
an ILcdModel
following the ESRI Shapefile Technical Description.
Only ILcdModel
containing one shape type will be fully encoded, as
the technical specification prescribes that all shapes in a SHP file are required
to be of the same shape type.
The TLcdSHPModelEncoder
supports the following shape types:
TLcdSHPPointM
as PointM
TLcdSHPPointZ
as PointZ
ILcdPoint
as:
export3D
property is true
export3D
property is false
ILcdPolyline
as:
export3D
property is true
export3D
property is false
but the shape implements ILcdSHPMeasureList
ILcdPolygon
as:
export3D
property is true
export3D
property is false
but the shape implements ILcdSHPMeasureList
ILcdShapeList
as
TLcdSHPPointZ
or the export3D
property is true
TLcdSHPPointM
ILcdPoint
TLcdSHPPointZ
or the export3D
property is true
ILcdSHPMeasureList
and
ILcdPolyline
ILcdPolyline
TLcdSHPPointZ
or the export3D
property is true
ILcdPolygon
ILcdSHPMeasureList
and
ILcdPolyline
ILcdSHPMeasureList
and
ILcdPolygon
Since all ILcdShape implementations are essentially three dimensional, the property export3D defines whether shapes should be exported as two dimensional or as three dimensional data. The default value of the property is false, two dimensional export, for backwards compatibility.
When a ILcdShapeList
is encoded, all shapes in the shape list are assumed to be
of the same type, the type of the first shape in the shape list.
By default the accompanying shx file is written and the accompanying dbf file is written for a
ILcdModel
with a ILcdFeaturedDescriptor
or a ILcdDataModelDescriptor
containing a single model element type that only has simple properties. Both can be turned off by
setting the properties WithIndexFile and WithDBF. If the DBF file could not be encoded completely,
a warning message is put on the log. No exception will be thrown.
Features are encoded according to their type:
toString
method.
TLcdWKTModelReferenceEncoder
for writing the model
reference as a ".prj" file.Constructor and Description |
---|
TLcdSHPModelEncoder() |
Modifier and Type | Method and Description |
---|---|
boolean |
canExport(ILcdModel aModel,
String aDestination)
Checks whether a
ILcdModel can be exported to a SHP file. |
boolean |
canSave(ILcdModel aModel)
Returns whether this model encoder can save the specified model to the location it originally came from.
|
void |
export(ILcdModel aModel,
String aDestination)
Exports a
ILcdModel to a destination file. |
String |
getDisplayName()
Returns the display name for this encoder.
|
ILcdModelReferenceEncoder |
getModelReferenceEncoder()
Returns the
ILcdModelReferenceEncoder used by this TLcdSHPModelEncoder . |
ILcdOutputStreamFactory |
getOutputStreamFactory()
Returns the
ILcdOutputStreamFactory used to create output. |
boolean |
isExport3D()
Indicates whether shapes will be exported as 3D shapes.
|
boolean |
isTraceOn()
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
boolean |
isTrimStringPropertyValues()
Indicates whether or not string values are trimmed when encoding DBF files.
|
boolean |
isWithDBF()
Returns true if a DBF file will also be written next to the .shp file.
|
boolean |
isWithIndexFile()
Returns whether an index file (.shx) should be written next to the .shp file.
|
void |
save(ILcdModel aModel)
Saves the model to the location where it originally came from.
|
void |
setCharacterSet(String aCharacterSet)
Sets the character set to encode DBF files.
|
static void |
setClassTraceOn(boolean aClassTraceOn)
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
void |
setExport3D(boolean aExport3D)
Sets whether the polylines and polygons should be exported as 3D shapes.
|
void |
setModelReferenceEncoder(ILcdModelReferenceEncoder aModelReferenceEncoder)
Sets the
ILcdModelReferenceEncoder to be used by this TLcdSHPModelEncoder . |
void |
setOutputStreamFactory(ILcdOutputStreamFactory aOutputStreamFactory)
Sets
aOutputStreamFactory as
ILcdOutputStreamFactory on this
TLcdSHPModelDecoder . |
void |
setTraceOn(boolean aTraceOn)
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
void |
setTrimStringPropertyValues(boolean aTrimStringPropertyValues)
Specifies whether or not leading and trailing whitespace should be removed
from string properties while encoding DBF files.
|
void |
setWithDBF(boolean aBoolean)
Sets whether to produce a DBF file next to the .shp file.
|
void |
setWithIndexFile(boolean aWithIndexFile)
Sets whether an index file (.shx) should be written next to the .shp file.
|
protected void |
write2DBounds(ILcdBounds aBounds,
TLcdDataOutputStream aDOS)
Encodes a
ILcdBounds to the output stream
following the ESRI SHP file technical specification. |
protected void |
write2DPoint(ILcdPoint aPoint,
TLcdDataOutputStream aDOS)
Encodes a
ILcdPoint as a Point to the output stream
following the ESRI SHP file technical specification. |
protected void |
write2DPointM(TLcdSHPPointM aPointM,
TLcdDataOutputStream aDOS)
Encodes a
TLcdSHPPointM as a PointM to the output stream
following the ESRI SHP file technical specification. |
protected void |
write2DPointZ(TLcdSHPPointZ aPointZ,
TLcdDataOutputStream aDOS)
Encodes a
TLcdSHPPointM as a PointZ to the output stream
following the ESRI SHP file technical specification. |
protected void |
write2DPolygon(ILcdShapeList aShapeList,
TLcdDataOutputStream aDOS)
Encodes a
ILcdShapeList containing ILcdPointList as a set of
Polygons to the output stream following the ESRI SHP file technical specification. |
protected void |
write2DPolygonM(ILcdShapeList aShapeList,
TLcdDataOutputStream aDOS)
Encodes a
ILcdShapeList containing ILcdPolygon as a set of
PolygonM's to the output stream following the ESRI SHP file technical specification. |
protected void |
write2DPolyline(ILcdShapeList aShapeList,
TLcdDataOutputStream aDOS)
Encodes a
ILcdShapeList containing ILcdPolyline as a set of
Polylines to the output stream following the ESRI SHP file technical specification. |
protected void |
write2DPolylineM(ILcdShapeList aShapeList,
TLcdDataOutputStream aDOS)
Encodes a
ILcdShapeList containing ILcdPolyline as a set of
PolylineM's to the output stream following the ESRI SHP file technical specification. |
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 setWithDBF(boolean aBoolean)
aBoolean
- indicating whether a dbf file should be written next to the .shp file.isWithDBF()
public boolean isWithDBF()
public void setWithIndexFile(boolean aWithIndexFile)
aWithIndexFile
- indicating whether an index file (.shx) should be written next to the .shp file.isWithIndexFile()
public boolean isWithIndexFile()
setWithIndexFile(boolean)
public void setOutputStreamFactory(ILcdOutputStreamFactory aOutputStreamFactory)
aOutputStreamFactory
as
ILcdOutputStreamFactory
on this
TLcdSHPModelDecoder
.
aOutputStreamFactory
is then used for retrieving
OutputStream
objects when encoding a shp file.
In future versions, it could also be used to save its accompanying ref file.
To use the default way of creating an OutputStream
leave this property unset or set it to null
.
This can be used to define a specific way of transferring
data from this TLcdSHPModelEncoder
to the destination,
e.g., in an encrypted way.
setOutputStreamFactory
in interface ILcdOutputStreamFactoryCapable
aOutputStreamFactory
- the ILcdOutputStreamFactory
to use to create output.ILcdOutputStreamFactory
,
getOutputStreamFactory()
public ILcdOutputStreamFactory getOutputStreamFactory()
ILcdOutputStreamFactory
used to create output.getOutputStreamFactory
in interface ILcdOutputStreamFactoryCapable
ILcdOutputStreamFactory
set on this
TLcdSHPModelEncoder
setOutputStreamFactory(com.luciad.io.ILcdOutputStreamFactory)
public void setTrimStringPropertyValues(boolean aTrimStringPropertyValues)
true
.aTrimStringPropertyValues
- whether or not string values in DBF files should be trimmedpublic boolean isTrimStringPropertyValues()
setTrimStringPropertyValues(boolean)
public ILcdModelReferenceEncoder getModelReferenceEncoder()
ILcdModelReferenceEncoder
used by this TLcdSHPModelEncoder
.ILcdModelReferenceEncoder
used by this TLcdSHPModelEncoder
.setModelReferenceEncoder(com.luciad.model.ILcdModelReferenceEncoder)
public void setModelReferenceEncoder(ILcdModelReferenceEncoder aModelReferenceEncoder)
ILcdModelReferenceEncoder
to be used by this TLcdSHPModelEncoder
.aModelReferenceEncoder
- the ILcdModelReferenceEncoder
to be used by this TLcdSHPModelEncoder
.getModelReferenceEncoder()
public void setCharacterSet(String aCharacterSet)
aCharacterSet
- the character set to encode DBF files. The supported character sets depend on the JVM implementation
and can be found at String.String(byte[], String)
.public boolean isExport3D()
public void setExport3D(boolean aExport3D)
Shape | Type |
---|---|
ILcdPolyline | PolylineZ |
ILcdPolygon | PolygonZ |
aExport3D
- true to have shapes exported as 3D shapes.public String getDisplayName()
getDisplayName
in interface ILcdModelEncoder
public boolean canExport(ILcdModel aModel, String aDestination)
ILcdModel
can be exported to a SHP file.canExport
in interface ILcdModelEncoder
aModel
- the model to be exportedaDestination
- the destination file to which the model is to be exported. No check
is performed whether the destination file can be written to.ILcdPoint
ILcdShapeList
containing a ILcdPolygon
as a first shape
ILcdShapeList
containing a ILcdPolyline
as a first shape
ILcdFeaturedDescriptor
or a ILcdDataModelDescriptor
.ILcdModelEncoder.export(com.luciad.model.ILcdModel, java.lang.String)
public void export(ILcdModel aModel, String aDestination) throws IllegalArgumentException, IOException
ILcdModel
to a destination file. Before calling this method, check if the model can be
exported to the destination with canExport(com.luciad.model.ILcdModel, String)
.export
in interface ILcdModelEncoder
aModel
- the ILcdModel
to export.aDestination
- the file to write toIllegalArgumentException
IOException
- when the destination file cannot be written to.public boolean canSave(ILcdModel aModel)
ILcdModelEncoder
canSave
in interface ILcdModelEncoder
aModel
- the model for which the check is to be performedILcdModelDescriptor
of the ILcdModel
is
an instance of the class TLcdSHPModelDescriptor
ILcdModelEncoder.save(com.luciad.model.ILcdModel)
public void save(ILcdModel aModel) throws IllegalArgumentException, IOException
ILcdModelEncoder
save
in interface ILcdModelEncoder
aModel
- the model to be savedIllegalArgumentException
IOException
- when the destination file cannot be written to.protected void write2DPolygon(ILcdShapeList aShapeList, TLcdDataOutputStream aDOS) throws IOException
ILcdShapeList
containing ILcdPointList
as a set of
Polygons to the output stream following the ESRI SHP file technical specification.aShapeList
- a ILcdShapeList
containing 1 or more ILcdPointList
objectsaDOS
- a output streamIOException
- for any I/O errorsprotected void write2DPolygonM(ILcdShapeList aShapeList, TLcdDataOutputStream aDOS) throws IOException
ILcdShapeList
containing ILcdPolygon
as a set of
PolygonM's to the output stream following the ESRI SHP file technical specification.
All ILcdPolygon
should also implement ILcdSHPMeasureList
aShapeList
- a ILcdShapeList
containing 1 or more ILcdPolygon
,
ILcdSHPMeasureList
objectsaDOS
- a output streamIOException
- for any I/O errorsprotected void write2DPolyline(ILcdShapeList aShapeList, TLcdDataOutputStream aDOS) throws IOException
ILcdShapeList
containing ILcdPolyline
as a set of
Polylines to the output stream following the ESRI SHP file technical specification.aShapeList
- a ILcdShapeList
containing 1 or more ILcdPolyline
objectsaDOS
- a output streamIOException
- for any I/O errorsprotected void write2DPolylineM(ILcdShapeList aShapeList, TLcdDataOutputStream aDOS) throws IOException
ILcdShapeList
containing ILcdPolyline
as a set of
PolylineM's to the output stream following the ESRI SHP file technical specification.
All ILcdPolyline
should also implement ILcdSHPMeasureList
aShapeList
- a ILcdShapeList
containing 1 or more ILcdPolyline
,
ILcdSHPMeasureList
objectsaDOS
- a output streamIOException
- for any I/O errorsprotected void write2DPoint(ILcdPoint aPoint, TLcdDataOutputStream aDOS) throws IOException
ILcdPoint
as a Point to the output stream
following the ESRI SHP file technical specification.aPoint
- the ILcdPoint
to be encodedaDOS
- the output stream to write toIOException
- for any I/O errorsprotected void write2DPointM(TLcdSHPPointM aPointM, TLcdDataOutputStream aDOS) throws IOException
TLcdSHPPointM
as a PointM to the output stream
following the ESRI SHP file technical specification.aPointM
- the ILcdPoint
to be encodedaDOS
- the output stream to write toIOException
- for any I/O errorsprotected void write2DPointZ(TLcdSHPPointZ aPointZ, TLcdDataOutputStream aDOS) throws IOException
TLcdSHPPointM
as a PointZ to the output stream
following the ESRI SHP file technical specification.aPointZ
- the ILcdPoint
to be encodedaDOS
- the output stream to write toIOException
- for any I/O errorsprotected void write2DBounds(ILcdBounds aBounds, TLcdDataOutputStream aDOS) throws IOException
ILcdBounds
to the output stream
following the ESRI SHP file technical specification.aBounds
- the ILcdPoint
to be encodedaDOS
- the output stream to write toIOException
- for any I/O errors