Class TLcdGeoPackageModelDecoder

java.lang.Object
com.luciad.format.sqlite.geopackage.TLcdGeoPackageModelDecoder
All Implemented Interfaces:
ILcdDataSourceModelDecoder, ILcdModelDecoder

@LcdService(service=ILcdModelDecoder.class, priority=20000) public class TLcdGeoPackageModelDecoder extends Object implements ILcdModelDecoder, ILcdDataSourceModelDecoder
A model decoder that decodes OGC GeoPackage files.

Input Files

File Required Entry point Description
*.gpkg X X The database file

Supported file transfer protocols

  • This model decoder supports all transfer protocols that are supported by java.io.File.

Model structure

  • If there is only one dataset, the model is a TLcdDatabaseModel for vector data and ILcdModel for raster and elevation data.
  • If there are multiple datasets, returns an ILcdModelTreeNode that contains a model for each dataset as described above.

Model descriptor

  • All models returned by this model decoder have a TLcdGeoPackageModelDescriptor.
    • Model descriptors for tile (raster) datasets also implement the ILcdEarthModelDescriptor interface.
    • Model descriptors for tile (elevation) datasets also implement the ILcdImageModelDescriptor interface.
    • Model descriptors for feature (vector) datasets also implements the ILcdDatabaseModelDescriptor interface. This exposes a data model with one data type. Each non-geometry column of the GeoPackage table is available as a property on the data type. The GeoPackage data type of the column is mapped on the corresponding Java type.

Model reference

  • All models returned by this model decoder have a com.luciad.reference.ILcdGridReference or com.luciad.reference.ILcdGeodeticReference.

Model elements

Updating the model

Thread safety

Sample code

Decoding GeoPackage data and visualizing it on a Lightspeed map:

    //First create the model
    ILcdModelDecoder decoder =
        new TLcdCompositeModelDecoder(TLcdServiceLoader.getInstance(ILcdModelDecoder.class));
    ILcdModel model = decoder.decode("Data/GeoPackage/states.gpkg");

    //Create a layer for the model
    ILspLayer layer = createGeoPackageLayer(model);

    //Add the layer to the Lightspeed view (an ILspView)
    view.addLayer(layer);

Decoding GeoPackage data and visualizing it on a GXY map:

    //First create the model
    ILcdModelDecoder decoder =
        new TLcdCompositeModelDecoder(TLcdServiceLoader.getInstance(ILcdModelDecoder.class));
    ILcdModel model = decoder.decode("Data/GeoPackage/states.gpkg");

    //Create a layer for the model with default styling
    ILcdGXYLayer layer = createGXYGeoPackageLayer(model);
    //Wrap the layer with an async layer wrapper to ensure
    //that the view remains responsive while data is being painted
    layer = ILcdGXYAsynchronousLayerWrapper.create(layer);

    //Add the async layer to the GXY view (an ILcdGXYView)
    view.addGXYLayer(layer);

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.
These files have a .gpkg extension.
Since:
2013.1
  • Field Details

    • FEATURES_TYPE_NAME

      public static final String FEATURES_TYPE_NAME
      Type name constant for GeoPackage models containing feature data.
      See Also:
    • TILES_TYPE_NAME

      public static final String TILES_TYPE_NAME
      Type name constant for GeoPackage models containing tiled raster (RGBA) data.
      See Also:
  • Constructor Details

    • TLcdGeoPackageModelDecoder

      public TLcdGeoPackageModelDecoder()
      Creates a new GeoPackage model decoder.
  • Method Details

    • setMaxCacheSize

      public void setMaxCacheSize(int aMaxCacheSize)
      Sets the maximum number of features (domain objects) that decoded models can store using hard references.

      Each individual decoded model (or sub-model when there are multiple datasets in the source) can store this many domain objects. More objects can be stored using soft references.

      The default value is 300.

      Strategies: caching affects mainly spatial query performance.

      1. aMaxCacheSize > 0: two queries are performed: one to determine overlapping object IDs, one to retrieve the geometry and properties of each object that is not yet in cache. This maximally reduces the amount of geometries and features that have to be read from file.
      2. aMaxCacheSize == 0: all overlapping objects (geometries and properties) are read from file in one query. This maximally reduces the number of queries that have to be made to the database, which is useful if the round-trip time is high.
      3. If all the elements of the database model fit in memory, you can create a new local model and copy all database model elements over. This results in a single large query upfront, and the database model can then be disposed.

      Parameters:
      aMaxCacheSize - the max number of objects cached with hard references.
    • getMaxCacheSize

      public int getMaxCacheSize()
      Returns the maximum number of features (domain objects) that decoded models can store using hard references.

      The default value is 300.

      Returns:
      the maximum number of objects that will be stored using hard references.
      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(ILcdDataSource aDataSource)
      Checks whether the given data source can be decoded with this model decoder.

      This model decoder handles TLcdGeoPackageDataSource data sources and TLcdDataSource data sourcees. The latter case delegates the source to the canDecodeSource(String) method.

      Specified by:
      canDecodeSource in interface ILcdModelDecoder
      Parameters:
      aDataSource - the dataset to be decoded.
      Returns:
      true if the data source is a TLcdGeoPackageDataSource or a TLcdDataSource, false otherwise
      See Also:
    • decodeSource

      public ILcdModel decodeSource(ILcdDataSource aDataSource) throws IOException
      Creates a model for the given data source.

      The data source must be a TLcdGeoPackageDataSource, which represents one data set in the GeoPackage file.

      Specified by:
      decodeSource in interface ILcdModelDecoder
      Parameters:
      aDataSource - the dataset to be decoded.
      Returns:
      A model with the structure described in the class javadoc
      Throws:
      IOException - if the dataset cannot be loaded.
      See Also:
    • canDecodeSource

      public boolean canDecodeSource(String aSource)
      Checks whether the given source can be decoded with this model decoder.

      This model decoder handles only .gpkg files.

      Specified by:
      canDecodeSource in interface ILcdModelDecoder
      Parameters:
      aSource - the data source to be verified; typically a file name or a URL.
      Returns:
      true if the source has .gpkg extension.
      See Also:
    • decode

      public ILcdModel decode(String aSource) throws IOException
      Decodes all data sets in a GeoPackage file.
      • If there is only one dataset, returns a model structured as described in the class javadoc
      • If there are multiple datasets, returns a TLcdModelTreeNode that contains a model for each dataset.
      Specified by:
      decode in interface ILcdModelDecoder
      Parameters:
      aSource - the GeoPackage file to be decoded.
      Returns:
      A model with the structure described above
      Throws:
      IOException - if the file cannot be loaded.
      See Also:
    • getDataSources

      public List<TLcdGeoPackageDataSource> getDataSources(String aSource) throws IOException
      Returns all possible data sources in the given GeoPackage file.

      Each data source corresponds to a single dataset in the file.

      You can use decodeSource(com.luciad.model.ILcdDataSource) to create a model for an individual data source.

      Parameters:
      aSource - The GeoPackage file
      Returns:
      The datasets in the file
      Throws:
      IOException - if the file cannot be read
      See Also:
    • discoverDataSources

      public List<TLcdGeoPackageDataSource> discoverDataSources(String aPath) throws IOException
      This interface method delegates its work to getDataSources(String). It is identical in behavior an exists only to be compatible with the ILcdModelDecoder.discoverDataSources(String) interface method.

      Returns all possible data sources in the given GeoPackage file.

      Each data source corresponds to a single dataset in the file.

      You can use decodeSource(com.luciad.model.ILcdDataSource) to create a model for an individual data source.

      Specified by:
      discoverDataSources in interface ILcdModelDecoder
      Parameters:
      aPath - A path to the data source to be decoded; typically a file name or a URL.
      Returns:
      A list of datasets in the given file.
      Throws:
      IOException - if the file cannot be read