Class TLcdGeoPackageModelEncoder
- All Implemented Interfaces:
ILcdModelEncoder
,ILcdStatusSource
,Serializable
The export(com.luciad.model.ILcdModel, java.lang.String)
method exports the contents of a model to an OGC GeoPackage file.
- If the file does not exist, a new one is created.
- If the file already exists, the dataset is added to it.
- If the file exists, and already has the dataset, the existing dataset is replaced.
- If the file exists and
isDeleteExistingFile()
istrue
, the file is deleted first, and then re-created.
spatially
if necessary.
Encoding tiles (raster data)
This model encoder accepts models that containILcdRaster
, ILcdMultilevelRaster
or ILcdEarthTileSet
elements.
This includes models produced by almost all raster model decoders. Only the first element of a model
will be encoded. If the element is an ILcdEarthTileSet
containing multiple coverages only
one of those coverages will be encoded.
Both image and elevation data are supported by OGC GeoPackage.
Tiles are automatically generated. For image data you can override:
- The
image format
- The
image quality
- The
target reference
- The
number of levels
For elevation data you can override:
- The
elevation image format
- The
elevation image quality
- The
compression mode
- The
target reference
- The
number of levels
Area sampling is used as sampling mode for elevation data. |
Fusion elevation coverage export follows a code path that preserves the sampling mode, when the target reference is equal to the source reference. |
Encoding features (vector data)
Most models that contain features (vector data) can be encoded to OGC GeoPackage files. There are a few restrictions. If the restrictions are not met, an IOException is thrown:- The features must be
ILcdDataObject
orILcdFeatured
, the model descriptor must beILcdDataModelDescriptor
orILcdFeaturedDescriptor
. - The features must be
ILcdShape
objects that can be mapped to GeoPackage geometry types, see table below. - The data model can have only one data type.
- The data type can only have properties that can be directly mapped to GeoPackage column data types.
TLcdPrimaryKeyAnnotation
, that property is used as primary key.
Otherwise, a new column _id
is used which has auto-generated values.
ILcdShape
objects are mapped to GeoPackage geometry as follows:
FROMILcdShape | TOGeoPackage geometry |
---|---|
ILcdPoint | POINT |
ILcdPolypoint | MULTIPOINT |
ILcdPolyline | POLYLINE |
ILcdPolygon | POLYGON |
ILcdComplexPolygon | POLYGON |
ILcdCircularArcBy3Points or ILcdCompositeCurve containing
multiple ILcdCircularArcBy3Points instances | CIRCULARSTRING |
ILcdArc | LCDELLIPTICALARC |
ILcdCircle | LCDCIRCLE |
ILcdEllipse | LCDELLIPSE |
ILcdShapeList containing
multiple ILcdPoint instances | MULTIPOINT |
ILcdShapeList containing
multiple ILcdPolyline instances | MULTIPOLYLINE |
ITLcdCompositeCurve containing
multiple ILcdPolyline and ILcd2DEditableCircularArcBy3Points instances | COMPOUNDCURVE |
TLcdSurface where exterior ring and interior rings are
ILcdPolyline and ILcd2DEditableCircularArcBy3Points instances | CURVEPOLYGON |
ILcdShapeList containing
multiple ILcdPolygon instances | MULTIPOLYGON |
ILcdShapeList containing
multiple ILcdComplexPolygon instances | MULTIPOLYGON |
ILcdShapeList containing the following objects:
| MULTICURVE |
ILcdShapeList containing the following objects:
| MULTISURFACE |
ILcdShapeList containing one of the above (recursive) instances | GEOMETRYCOLLECTION |
Changing features in an existing file
If you want to add, remove or update elements in an existing OGC GeoPackage dataset in an existing file, rather than creating a new one, you should first create a model usingTLcdGeoPackageModelDecoder
.
You can then add, update or remove elements in the decoded model and make the changes persistent
with TLcdDatabaseModel.commit()
.
Alternatively, you can use save(com.luciad.model.ILcdModel)
.
Without committing or saving, any changes are present in the in-memory model only, not persisted in the database.
Supported versions
- OGC GeoPackage files, compliant with version 1.0.1 of the OGC GeoPackage specification.
- OGC GeoPackage files, compliant with version 1.1 of the OGC GeoPackage specification.
- OGC GeoPackage files, compliant with version 1.2.1 of the OGC GeoPackage specification.
- OGC GeoPackage files, compliant with version 1.3.0 of the OGC GeoPackage specification.
setExportVersion(ELcdGeoPackageSpecificationVersion)
.- Since:
- 2013.1
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Enumeration of the supported compression mode.static enum
Enumeration of the supported elevation compression formats. -
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addStatusListener
(ILcdStatusListener aListener) Registers the given listener so it will receive status events from this source.boolean
Returns whether this encoder can export the specified model to the specified destination.boolean
Returns whether this model encoder can save the specified model to the location it originally came from.void
Exports the specified model to the specified destination.Returns the bounds of the area to encode.Returns the reference the current area to encode is defined in.Returns the compression mode.float
Returns the current image compression quality setting.Returns a short, displayable name for the format thisILcdModelEncoder
encodes to.Returns the current elevation compression format.Returns the GeoPackage specification version configured for exporting models.Returns the current image compression format.int
Returns the maximum tile level.Returns the reference rasters will be encoded in.boolean
When the target file already exists it can either be removed first or the model can be added to the existing file.void
removeStatusListener
(ILcdStatusListener aListener) Removes the specified listener so it is no longer notified.void
Saves the model to the location where it originally came from.void
setAreaOfInterest
(ILcdBounds aAreaOfInterest, ILcdGeoReference aAreaOfInterestReference) Sets the bounds to encode.void
setCompressionMode
(TLcdGeoPackageModelEncoder.CompressionMode aCompressionMode) Sets the compression mode of the encoded images.void
setCompressionQuality
(float aCompressionQuality) Sets the image compression quality setting between 0.0 and 1.0.void
setDeleteExistingFile
(boolean aDeleteExistingFile) When the target file already exists it can either be removed first or the model can be added to the existing file.void
setElevationCompressionFormat
(TLcdGeoPackageModelEncoder.ElevationCompressionFormat aElevationCompressionFormat) Sets the format to use when compressing elevation data.void
setExportVersion
(ELcdGeoPackageSpecificationVersion aExportVersion) Sets the GeoPackage specification to use for exporting a model to a GeoPackage file.void
setImageCompressionFormat
(String aImageCompressionFormat) Sets the format to use when compressing imagery data.void
setMaximumTileLevel
(int aMaximumTileLevel) Sets the maximum tile level for raster data.void
setTileTargetReference
(ILcdGeoReference aTargetReference) Sets the reference to encode rasters in.
-
Field Details
-
IMAGE_FORMAT_PNG
Constant for PNG image compression.- See Also:
-
IMAGE_FORMAT_JPEG
Constant for JPEG image compression.- See Also:
-
-
Constructor Details
-
TLcdGeoPackageModelEncoder
public TLcdGeoPackageModelEncoder()Creates a new GeoPackage model encoder
-
-
Method Details
-
getCompressionQuality
public float getCompressionQuality()Returns the current image compression quality setting.- Returns:
- the current compression quality setting.
- See Also:
-
setCompressionQuality
public void setCompressionQuality(float aCompressionQuality) Sets the image compression quality setting between 0.0 and 1.0. A value of 0.0 indicates high compression is preferred; a value of 1.0 indicates high image quality is preferred.The default quality is
0.75
.- Parameters:
aCompressionQuality
- the new compression quality setting.- See Also:
-
getImageCompressionFormat
Returns the current image compression format.- Returns:
- the current image compression format
- See Also:
-
getElevationCompressionFormat
Returns the current elevation compression format.- Returns:
- the current elevation compression format
- Since:
- 2020.1
- See Also:
-
getCompressionMode
Returns the compression mode.- Returns:
- the compression mode
- Since:
- 2020.1
- See Also:
-
setDeleteExistingFile
public void setDeleteExistingFile(boolean aDeleteExistingFile) When the target file already exists it can either be removed first or the model can be added to the existing file.true
indicates that the existing file will be deleted and a new one created when exporting a model.false
indicates that the model will be added to the existing file. If the file already contains the dataset, it will be overwritten.
Disabled by default.
- Parameters:
aDeleteExistingFile
- true if any existing file needs to be deleted first, false otherwise.- See Also:
-
isDeleteExistingFile
public boolean isDeleteExistingFile()When the target file already exists it can either be removed first or the model can be added to the existing file.- Returns:
- true if the existing file needs to be deleted first, false otherwise.
- See Also:
-
setImageCompressionFormat
Sets the format to use when compressing imagery data.- Parameters:
aImageCompressionFormat
- the new image compression format
-
setElevationCompressionFormat
public void setElevationCompressionFormat(TLcdGeoPackageModelEncoder.ElevationCompressionFormat aElevationCompressionFormat) Sets the format to use when compressing elevation data.- Parameters:
aElevationCompressionFormat
- the new elevation compression format- Since:
- 2020.1
-
setCompressionMode
Sets the compression mode of the encoded images. The default isCOMPRESSION_LZW
.- Parameters:
aCompressionMode
- one of the supported TIFF compression schemes:COMPRESSION_NONE
,COMPRESSION_LZW
,- Since:
- 2020.1
-
getExportVersion
Returns the GeoPackage specification version configured for exporting models.- Returns:
- the GeoPackage specification version configured for exporting models.
- Since:
- 2020.1
-
setExportVersion
Sets the GeoPackage specification to use for exporting a model to a GeoPackage file.- Parameters:
aExportVersion
- the GeoPackage specification value.- Since:
- 2020.1
-
addStatusListener
Description copied from interface:ILcdStatusSource
Registers the given listener so it will receive status events from this source.
In case you need to register a listener which keeps a reference to an object with a shorter life-time than this status source, you can use a
ALcdWeakStatusListener
instance as status listener.- Specified by:
addStatusListener
in interfaceILcdStatusSource
- Parameters:
aListener
- The listener to be notified when the status has changed.
-
removeStatusListener
Description copied from interface:ILcdStatusSource
Removes the specified listener so it is no longer notified.- Specified by:
removeStatusListener
in interfaceILcdStatusSource
- Parameters:
aListener
- The listener to remove.
-
getTileTargetReference
Returns the reference rasters will be encoded in.- Returns:
- the current target reference.
- See Also:
-
setTileTargetReference
Sets the reference to encode rasters in.Rasters that are defined in another reference than the input model's will be converted to the target reference before being encoded.
By default, this is not set, meaning the input model's reference it used.
- Parameters:
aTargetReference
- the new target reference.
-
getAreaOfInterest
Returns the bounds of the area to encode.- Returns:
- the current area to encode.
- See Also:
-
getAreaOfInterestReference
Returns the reference the current area to encode is defined in.- Returns:
- the reference of the area to encode.
- See Also:
-
setAreaOfInterest
public void setAreaOfInterest(ILcdBounds aAreaOfInterest, ILcdGeoReference aAreaOfInterestReference) Sets the bounds to encode. Only the data overlapping with this area will be encoded.By default, no bounds are set.
Use
null
bounds if no bounds should be set.- Parameters:
aAreaOfInterest
- the new bounds to encode, ornull
if no bounds should be set.aAreaOfInterestReference
- the reference the bounds are defined in.
-
getMaximumTileLevel
public int getMaximumTileLevel()Returns the maximum tile level.- Returns:
- the current maximum tile level.
- See Also:
-
setMaximumTileLevel
public void setMaximumTileLevel(int aMaximumTileLevel) Sets the maximum tile level for raster data.If a multilevel raster or tile set with a higher number of levels is encoded only up to aMaximumTileLevel of the least detailed levels will be encoded.
Default is unlimited.
- Parameters:
aMaximumTileLevel
- the new maximum tile level.
-
getDisplayName
Description copied from interface:ILcdModelEncoder
Returns a short, displayable name for the format thisILcdModelEncoder
encodes to.- Specified by:
getDisplayName
in interfaceILcdModelEncoder
- Returns:
- the displayable name of this
ILcdModelEncoder
.
-
canSave
Returns whether this model encoder can save the specified model to the location it originally came from. This model encoder can only save GeoPackage feature data, raster data will be ignored.- Specified by:
canSave
in interfaceILcdModelEncoder
- Parameters:
aModel
- the model to be verified.- Returns:
true
if this encoder can save to the GeoPackage database.- See Also:
-
save
Saves the model to the location where it originally came from.This is only supported for GeoPackage feature data. Raster data is simply ignored.
To do the actual save, this method calls
TLcdDatabaseModel.commit()
.Note: any settings you configure on this model encoder are ignored. The changes are stored into the original database using the settings from the
decoder
.- Specified by:
save
in interfaceILcdModelEncoder
- Parameters:
aModel
- the model to be saved.- Throws:
IllegalArgumentException
IOException
-
canExport
Description copied from interface:ILcdModelEncoder
Returns whether this encoder can export the specified model to the specified destination. This method will typically check whether the contents of the specified model are compatible with the format this encoder is written for.- Specified by:
canExport
in interfaceILcdModelEncoder
- Parameters:
aModel
- the model to be verified.aDestination
- the location where the model should be exported to.- Returns:
true
if this encoder can export the specified model to the specified location,false
otherwise.- See Also:
-
export
public void export(ILcdModel aModel, String aDestination) throws IllegalArgumentException, IOException Description copied from interface:ILcdModelEncoder
Exports the specified model to the specified destination.- Specified by:
export
in interfaceILcdModelEncoder
- Parameters:
aModel
- the model to be exported.aDestination
- the location where the model should be saved. Typically, this is a name for the output file, but it can also point to a file containing the required properties to create a set of data files.- Throws:
IllegalArgumentException
- if the model cannot be saved by this encoder (!canExport(aModel, aDestinationName)
).IOException
- if an I/O error occurs during encoding.
-