Class TLcdGeoPackageModelDecoder
- All Implemented Interfaces:
ILcdDataSourceModelDecoder,ILcdModelDecoder
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
TLcdDatabaseModelfor vector data andILcdModelfor raster and elevation data. - If there are multiple datasets, returns an
ILcdModelTreeNodethat 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
ILcdEarthModelDescriptorinterface. - Model descriptors for tile (elevation) datasets also implement the
ILcdImageModelDescriptorinterface. - Model descriptors for feature (vector) datasets also implements the
ILcdDatabaseModelDescriptorinterface. 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 descriptors for tile (raster) datasets also implement the
Model reference
- All models returned by this model decoder have a
com.luciad.reference.ILcdGridReferenceorcom.luciad.reference.ILcdGeodeticReference.
Model elements
- Feature (vector) data:
- GeoPackage geometry objects are mapped to
ILcdShapeobjects: - Elements also implement
ILcdDataObjectwith the data type described above. - See also
setMaxCacheSize(int)to learn how caching can affect performance.
LCDELLIPTICALARC,LCDCIRCLE,LCDELLIPSEare geometry types that are added as extensions to GeoPackage. These extensions allow you to store the corresponding shape in a GeoPackage. GeoPackage files containing these geometry types can only be opened with Luciad software products. - GeoPackage geometry objects are mapped to
- Tile (raster) data:
- Each decoded model contains a single implementation of
ALcdImageandILcdEarthTileSet. The tiling structure of this tile set matches the tile matrix set defined by the OGC GeoPackage dataset.
- Each decoded model contains a single implementation of
- Tile (elevation) data:
- Each decoded model contains a single implementation of
ALcdMultilevelImageMosaic. The tiling structure of this tile set matches the tile matrix set defined by the OGC GeoPackage dataset. - The sampling modes are mapped on
ELcdImageSamplingModeaccording to the following table.Grid Cell Encoding Sampling Mode grid-value-is-center AREA grid-value-is-area AREA grid-value-is-corner POINT
grid-value-is-center actually has no matching sample mode, so AREA is used
- Each decoded model contains a single implementation of
Updating the model
- Updating the model is only possible for feature (vector) data.
- Changes (
ILcdModel.addElement(java.lang.Object, int),ILcdModel.removeElement(java.lang.Object, int),ILcdModel.elementChanged(java.lang.Object, int)etc.) are only applied in-memory, they are not automatically saved in the database. - Use
TLcdDatabaseModel.commit()to make the changes persistent.
Thread safety
- Use
TLcdLockUtil.readLock(Object)when accessing elements in the model. - Use
TLcdLockUtil.writeLock(Object)when changing elements in the model.
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.
.gpkg extension.- Since:
- 2013.1
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancanDecodeSource(ILcdDataSource aDataSource) Checks whether the given data source can be decoded with this model decoder.booleancanDecodeSource(String aSource) Checks whether the given source can be decoded with this model decoder.Decodes all data sets in a GeoPackage file.decodeSource(ILcdDataSource aDataSource) Creates a model for the given data source.discoverDataSources(String aPath) This interface method delegates its work togetDataSources(String).getDataSources(String aSource) Returns all possible data sources in the given GeoPackage file.Returns a short, displayable name for the format that is decoded by thisILcdModelDecoder.intReturns the maximum number of features (domain objects) that decoded models can store using hard references.voidsetMaxCacheSize(int aMaxCacheSize) Sets the maximum number of features (domain objects) that decoded models can store using hard references.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.luciad.model.ILcdModelDecoder
decodeModelMetadata, decodeModelMetadata
-
Field Details
-
FEATURES_TYPE_NAME
Type name constant for GeoPackage models containing feature data.- See Also:
-
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 queryperformance.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.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.- If all the elements of the database model fit in memory, you can create a new
local modeland copy all database modelelementsover. 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
Description copied from interface:ILcdModelDecoderReturns a short, displayable name for the format that is decoded by thisILcdModelDecoder.- Specified by:
getDisplayNamein interfaceILcdModelDecoder- Returns:
- the displayable name of this
ILcdModelDecoder.
-
canDecodeSource
Checks whether the given data source can be decoded with this model decoder.This model decoder handles
TLcdGeoPackageDataSourcedata sources andTLcdDataSourcedata sourcees. The latter case delegates the source to thecanDecodeSource(String)method.- Specified by:
canDecodeSourcein interfaceILcdModelDecoder- Parameters:
aDataSource- the dataset to be decoded.- Returns:
trueif the data source is aTLcdGeoPackageDataSourceor aTLcdDataSource,falseotherwise- See Also:
-
decodeSource
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:
decodeSourcein interfaceILcdModelDecoder- 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
Checks whether the given source can be decoded with this model decoder.This model decoder handles only
.gpkgfiles.- Specified by:
canDecodeSourcein interfaceILcdModelDecoder- Parameters:
aSource- the data source to be verified; typically a file name or a URL.- Returns:
trueif the source has.gpkgextension.- See Also:
-
decode
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
TLcdModelTreeNodethat contains a model for each dataset.
- Specified by:
decodein interfaceILcdModelDecoder- 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:
- If there is only one dataset, returns a model structured as described in the
-
getDataSources
Returns all possible data sources in the given GeoPackage file.Each
data sourcecorresponds 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
This interface method delegates its work togetDataSources(String). It is identical in behavior an exists only to be compatible with theILcdModelDecoder.discoverDataSources(String)interface method. Returns all possible data sources in the given GeoPackage file.Each
data sourcecorresponds 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:
discoverDataSourcesin interfaceILcdModelDecoder- 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
-