Class TLcdGeoPackageModelEncoder

java.lang.Object
com.luciad.format.sqlite.geopackage.TLcdGeoPackageModelEncoder
All Implemented Interfaces:
ILcdModelEncoder, ILcdStatusSource, Serializable

@LcdService(service=ILcdModelEncoder.class, priority=20000) public class TLcdGeoPackageModelEncoder extends Object implements ILcdModelEncoder, ILcdStatusSource
A model encoder that converts models containing vector data or raster data to OGC GeoPackage files.

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() is true, the file is deleted first, and then re-created.
You can limit the input data spatially if necessary.

Encoding tiles (raster data)

This model encoder accepts models that contain ILcdRaster, 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:

For elevation data you can override:

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: Each property in the input data type is mapped to a column in the target table. If the data type has a 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:

FROM
ILcdShape
TO
GeoPackage 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:
  • ILcdPolyline
  • ILcdShapeList with a single ILcd2DEditableCircularArcBy3Points object or a single ILcdCompositeCurve with ILcd2DEditableCircularArcBy3Points objects
  • TLcdCompositeCurve with ILcdPolyline and ILcd2DEditableCircularArcBy3Points objects
MULTICURVE
ILcdShapeList containing the following objects:
  • ILcdPolyline
  • TLcdCompositeCurve with ILcdPolyline and ILcd2DEditableCircularArcBy3Points 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 using TLcdGeoPackageModelDecoder.

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.
The default version used for exporting models is the GeoPackage 1.2.1 specification. You can choose the version using setExportVersion(ELcdGeoPackageSpecificationVersion).
Since:
2013.1
See Also:
  • Field Details

  • 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

      public String getImageCompressionFormat()
      Returns the current image compression format.
      Returns:
      the current image compression format
      See Also:
    • getElevationCompressionFormat

      public TLcdGeoPackageModelEncoder.ElevationCompressionFormat getElevationCompressionFormat()
      Returns the current elevation compression format.
      Returns:
      the current elevation compression format
      Since:
      2020.1
      See Also:
    • getCompressionMode

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

      public void setImageCompressionFormat(String aImageCompressionFormat)
      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

      public void setCompressionMode(TLcdGeoPackageModelEncoder.CompressionMode aCompressionMode)
      Sets the compression mode of the encoded images. The default is COMPRESSION_LZW.
      Parameters:
      aCompressionMode - one of the supported TIFF compression schemes: COMPRESSION_NONE, COMPRESSION_LZW,
      Since:
      2020.1
    • getExportVersion

      public ELcdGeoPackageSpecificationVersion getExportVersion()
      Returns the GeoPackage specification version configured for exporting models.
      Returns:
      the GeoPackage specification version configured for exporting models.
      Since:
      2020.1
    • setExportVersion

      public void setExportVersion(ELcdGeoPackageSpecificationVersion aExportVersion)
      Sets the GeoPackage specification to use for exporting a model to a GeoPackage file.
      Parameters:
      aExportVersion - the GeoPackage specification value.
      Since:
      2020.1
    • addStatusListener

      public void addStatusListener(ILcdStatusListener aListener)
      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 interface ILcdStatusSource
      Parameters:
      aListener - The listener to be notified when the status has changed.
    • removeStatusListener

      public void removeStatusListener(ILcdStatusListener aListener)
      Description copied from interface: ILcdStatusSource
      Removes the specified listener so it is no longer notified.
      Specified by:
      removeStatusListener in interface ILcdStatusSource
      Parameters:
      aListener - The listener to remove.
    • getTileTargetReference

      public ILcdGeoReference getTileTargetReference()
      Returns the reference rasters will be encoded in.
      Returns:
      the current target reference.
      See Also:
    • setTileTargetReference

      public void setTileTargetReference(ILcdGeoReference aTargetReference)
      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

      public ILcdBounds getAreaOfInterest()
      Returns the bounds of the area to encode.
      Returns:
      the current area to encode.
      See Also:
    • getAreaOfInterestReference

      public ILcdGeoReference 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, or null 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

      public String getDisplayName()
      Description copied from interface: ILcdModelEncoder
      Returns a short, displayable name for the format this ILcdModelEncoder encodes to.
      Specified by:
      getDisplayName in interface ILcdModelEncoder
      Returns:
      the displayable name of this ILcdModelEncoder.
    • canSave

      public boolean canSave(ILcdModel aModel)
      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 interface ILcdModelEncoder
      Parameters:
      aModel - the model to be verified.
      Returns:
      true if this encoder can save to the GeoPackage database.
      See Also:
    • save

      public void save(ILcdModel aModel) throws IllegalArgumentException, IOException
      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 interface ILcdModelEncoder
      Parameters:
      aModel - the model to be saved.
      Throws:
      IllegalArgumentException
      IOException
    • canExport

      public boolean canExport(ILcdModel aModel, String aDestination)
      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 interface ILcdModelEncoder
      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 interface ILcdModelEncoder
      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.