LuciadCPillar C# 2024.0.04
Luciad.Formats.Geopackage.GeoPackageModelEncoder Class Reference

The GeoPackageModelEncoder allows for exporting existing feature models as well as creating entirely new GeoPackage feature models. More...

Static Public Member Functions

static Luciad.Models.Features.IFeatureModel CreateEmptyGeoPackageDataSet (string path, Luciad.Formats.Geopackage.GeoPackageFeatureModelCreateOptions options)
 Creates a new empty table in the GeoPackage located at the specified path according to the data type specified in the options, and immediately decodes it as a feature model that can be edited. More...
 
static void ExportFeatureModel (string path, Luciad.Models.Features.IFeatureModel model)
 Exports the given IFeatureModel to the GeoPackage located at the specified path, using default options. More...
 
static void ExportFeatureModel (string path, Luciad.Models.Features.IFeatureModel model, Luciad.Formats.Geopackage.GeoPackageFeatureModelExportOptions options)
 Exports the given IFeatureModel to the GeoPackage located at the specified path. More...
 
static string GetCompliantName (string name)
 This function adds an underscore at the start if it starts with a digit, and converts all non alphanumeric characters to underscores. More...
 

Detailed Description

The GeoPackageModelEncoder allows for exporting existing feature models as well as creating entirely new GeoPackage feature models.

Both can be done to an existing GeoPackage file and to a new file.

Since
2024.0

Member Function Documentation

◆ CreateEmptyGeoPackageDataSet()

static Luciad.Models.Features.IFeatureModel Luciad.Formats.Geopackage.GeoPackageModelEncoder.CreateEmptyGeoPackageDataSet ( string  path,
Luciad.Formats.Geopackage.GeoPackageFeatureModelCreateOptions  options 
)
inlinestatic

Creates a new empty table in the GeoPackage located at the specified path according to the data type specified in the options, and immediately decodes it as a feature model that can be edited.

File creation and overwriting data

If no file exists, it is created. If an error occurs during creation, the file is deleted again.

If the file already exists, a new table is added to it. In the case of a name conflict (that is, there already exists a table with the same name as the data type, the existing data is only overwritten if the corresponding option is set to true. If overwriting is disabled (default) it results in an error instead and the creation is aborted.

If overwriting is enabled, any deleted data isn't recovered in case of failure.

Invalid names

The Data type and data property names must only consist of alphanumeric characters and underscores. Furthermore the first character must not be a digit.

If a name does not comply with this, encoding fails.

gpkg_geometry_columns settings

The GeoPackage feature tables are made with the least restrictive settings in the gpkg_geometry_columns table: A geometry_type_name of "GEOMETRY" and a z and m of 2 (optional).

Extensions

The rtree index and circularstring extensions are always enabled, these are official extensions that respectively improve performance and allow adding the CircularArcBy3Points geometry. The Luciad circle, ellipse and ellipticalarc extensions are only enabled if the corresponding option is set to true (which is the default).

With these extensions the geopackage accepts the following geometries:

Parameters
paththe path of the (new) GeoPackage file.
optionscreate options.
Returns
a decoded IFeatureModel of the new table.
Exceptions
System.IO.IOExceptionwhen creation fails.

◆ ExportFeatureModel() [1/2]

static void Luciad.Formats.Geopackage.GeoPackageModelEncoder.ExportFeatureModel ( string  path,
Luciad.Models.Features.IFeatureModel  model 
)
inlinestatic

Exports the given IFeatureModel to the GeoPackage located at the specified path, using default options.

Parameters
paththe path of the (new) GeoPackage file.
modelthe IFeatureModel to export.
Exceptions
System.IO.IOExceptionwhen exporting fails.

◆ ExportFeatureModel() [2/2]

static void Luciad.Formats.Geopackage.GeoPackageModelEncoder.ExportFeatureModel ( string  path,
Luciad.Models.Features.IFeatureModel  model,
Luciad.Formats.Geopackage.GeoPackageFeatureModelExportOptions  options 
)
inlinestatic

Exports the given IFeatureModel to the GeoPackage located at the specified path.

File creation and overwriting data

If no file exists, it is created. If an error occurs during exporting, the file is deleted again.

If the file already exists, the new data is added to it. In the case of a name conflict (that is, there already exists a table with the same name as one of the data types, the existing data is only overwritten if the corresponding option is set to true. If overwriting is disabled (default) it results in an error instead and the export is aborted.

If overwriting is enabled, any deleted data isn't recovered in case of failure.

Data types with no features

Each data type with associated features gets exported; no empty feature tables are created when exporting (use CreateEmptyGeoPackageDataSet instead for that). Attempting to export an empty IFeatureModel, that is, one without any features, results in an error.

Multiple data types

When a single IFeatureModel contains multiple data types, a feature table is created for each. However, keep in mind that when decoding, only a single table is loaded per IFeatureModel.

Name conversions

The Data type and data property names must only consist of alphanumeric characters and underscores. Furthermore the first character must not be a digit.

If a name does not comply, it is automatically converted as described in GeoPackageModelEncoder.GetCompliantName. This function can be used to do the same conversion as is done internally.

If converted names overlap this results in an error.

@javalink Luciad.Cartesian.Coordinate Coordinate} reference

The coordinate reference is inferred from the features contained in the model. All features belonging to a certain data type must have the same reference, the export fails otherwise.

gpkg_geometry_columns settings

The GeoPackage feature tables are made with the least restrictive settings in the gpkg_geometry_columns table: A geometry_type_name of "GEOMETRY" and a z and m of 2 (optional).

Extensions

The rtree index and circularstring extensions are always enabled, these are official extensions that respectively improve performance and allow adding the CircularArcBy3Points geometry. The Luciad circle, ellipse and ellipticalarc extensions are only enabled if the corresponding option is set to true (which is the default).

With these extensions the geopackage accepts the following geometries:

Parameters
paththe path of the (new) GeoPackage file.
modelthe IFeatureModel to export.
optionsexport options.
Exceptions
System.IO.IOExceptionwhen exporting fails.

◆ GetCompliantName()

static string Luciad.Formats.Geopackage.GeoPackageModelEncoder.GetCompliantName ( string  name)
inlinestatic

This function adds an underscore at the start if it starts with a digit, and converts all non alphanumeric characters to underscores.

Sequences of underscores are reduced to a single underscore.

The names of data types and data properties that do not comply are changed automatically in the case of an export. This function can be used to reliably get the new names based on the old ones.

In the case of CreateEmptyGeoPackageDataSet, the presence of non-compliant names results in an error.

Parameters
namea name (of a data type or a data property).
Returns
the name after encoding to the GeoPackage.