public final class GeoPackageModelDecoder extends Object
Model
.
This specific model can be either a IFeatureModel
or a IRasterModel
giving the ability to access the data within a GeoPackage file.
Modifier and Type | Method and Description |
---|---|
static Model |
decode(GeoPackageDataSource dataSource)
Creates a model for a OGC GeoPackage file.
|
static Model |
decode(GeoPackageDataSource dataSource,
GeoPackageModelDecoderOptions options)
Creates a model for a OGC GeoPackage file.
|
static List<GeoPackageTableMetadata> |
discoverTables(String source,
boolean includeUnsupportedDataTypes)
Discovers the available tables in the given source file.
|
@NotNull public static List<GeoPackageTableMetadata> discoverTables(@NotNull String source, boolean includeUnsupportedDataTypes) throws IOException
source
- The absolute path to the GeoPackage file. The extension of the file should be '.gpkg'.includeUnsupportedDataTypes
- Whether to include unsupported data types.IOException
- when discovering the tables fails.@NotNull public static Model decode(@NotNull GeoPackageDataSource dataSource) throws IOException
dataSource
- The data source description to use for data retrieval.IOException
- when decoding the GeoPackage file fails.@NotNull public static Model decode(@NotNull GeoPackageDataSource dataSource, @NotNull GeoPackageModelDecoderOptions options) throws IOException
The GeoPackage decoder allows decoding files following the OGC GeoPackage specification.
The supported table types are
GeoPackageTableMetadata#typeFeatures
GeoPackageTableMetadata#typeTiles
GeoPackageTableMetadata#type2dGriddedCoverage
GeoPackageModelDecoder#discoverTables
to retrieve the list of tables within the GeoPackage file.
Geometry Type Codes | Description for geometry in model |
---|---|
Point | Point |
LineString | Polyline |
CircularString | CircularArcBy3Points (or a collection of...) |
Polygon | Polygon |
MultiPoint | MultiGeometry with Point sub-geometries |
MultiLineString | MultiGeometry with Polyline sub-geometries |
MultiPolygon | MultiGeometry with Polygon sub-geometries |
GeometryCollection | MultiGeometry |
Custom Geometry Type Codes | Description for geometry in model |
---|---|
LcdCircle | Patch with CircleByCenterPoint as base geometry |
LcdEllipse | Patch with Ellipse as base geometry |
LcdEllipticalArc | EllipticalArc |
For curve geometries there is an implicit curve interpolation based on the type of Coordinate Reference System (CRS). When the CRS is a geodetic coordinate reference, e.g. WGS84, the interpolation is geodesic, otherwise the curve interpolation is linear.
FeatureQuery
expression filter can be used to order and filter the features that has to be loaded in memory. The filtering is done by the database and only the resulted features are loaded in memory.GeoPackageModelDecoderOptions
. The decoded model's IFeatureModel#getUpdater
method will then return an IFeatureModelUpdater
which can be used to modify the model. Changes to the model are not automatically persisted into the gpkg file, persisting is done using the FeatureModelPersistenceManager
, accessed using IFeatureModel#getPersistenceManager
.
The following elevation data formats are supported:
Decoding of GeoPackage files is limited to coordinate references supported by the CoordinateReferenceProvider#create
method.
String source = "test/resources/Data/GeoPackage/states10.gpkg";
try {
List<GeoPackageTableMetadata> tables = GeoPackageModelDecoder.discoverTables(source, false);
Log.i("gpkg", "The GeoPackage file contains " + tables.size() + " table(s):");
for (GeoPackageTableMetadata table : tables) {
Log.i("gpkg", " * Table '" + table.getName() + "' ");
if (GeoPackageTableMetadata.TypeFeatures.equals(table.getType())) {
GeoPackageDataSource datasource = GeoPackageDataSource.newBuilder()
.source(source)
.tableName(table.getName())
.build();
try {
Model model = GeoPackageModelDecoder.decode(datasource);
if (model instanceof IFeatureModel) {
IFeatureModel featureModel = (IFeatureModel) model;
AtomicLong count = new AtomicLong(0);
IFeatureQueryCallback callback = feature -> {
count.incrementAndGet();
return true;
};
featureModel.query(FeatureQuery.all(), callback);
Log.i("gpkg", "contains " + count + " features.");
}
} catch (Exception e) {
Log.w("gpkg", "could not be decoded: " + e.getMessage());
}
} else {
Log.i("gpkg", "contains raster data.");
}
}
} catch (Exception e) {
Log.w("gpkg", "Failed to load GeoPackage file " + source + ": " + e.getMessage());
}
dataSource
- The data source description to use for data retrieval.options
- Options for decoding GeoPackage data, e.g. an option to make a feature model editable.IOException
- when decoding the GeoPackage file fails.