GeoPackageMapFormat Class
The format that stores a map as one GeoPackage file named after its region, such as France.gpkg: a feature table per layer, with an R-tree spatial index, that QGIS, GDAL and ArcGIS open.
public sealed class GeoPackageMapFormat : MapFormatRemarks
The file is a GeoPackage 1.4 in WGS 84 (EPSG:4326). A layer is the table named after MapFormat.GetLayerName, with hyphens replaced by underscores, such as states_provinces: its identifier is the name of the region and of the layer, and its description the attribution. The metadata of the map, the JSON of the metadata.json file of the folder formats, is in the metadata extension, with the scope of the whole file.
The property values get the type of their column: a Boolean for BOOLEAN, an Int32 for MEDIUMINT, a Int64 for INTEGER, a Double for DOUBLE, a DateTimeOffset for DATETIME, an array of bytes for BLOB and a String for TEXT. The writer gives a column the type of its values, as the FlatGeobuf writer does, and the text of the values for other mixes.
Reading a file needs the native SQLite library of Microsoft.Data.Sqlite, with its R-tree module.
- Inheritance
MapFormatGeoPackageMapFormat
Properties
| Name | Description |
|---|---|
| Instance | Gets the GeoPackage format. |
| Name | Gets the name of the format, such as FlatGeobuf. |
Instance
GeoPackageMapFormat.csMethods
| Name | Description |
|---|---|
| GetPath(string, string) | Gets the path of the map of a region in the folder of a catalog, such as the folder maps/France or the file maps/France.gpkg. |
| Open(string) | Opens the map at a path. The layers are read when they are loaded. |
| TryGetRegion(string, string?) | Gets the region of the map at a path, when the file or folder at this path is a map of this format. |
| Write(string, MapMetadata, IReadOnlyDictionary<MapLayer, GeoFeatureCollection>) | Writes a map: its layers, and its metadata. The layers of a map that was at this path, and that layers does not have, are removed. |
GetPath(string, string)
GeoPackageMapFormat.csGets the path of the map of a region in the folder of a catalog, such as the folder maps/France or the file maps/France.gpkg.
Open(string)
GeoPackageMapFormat.csOpens the map at a path. The layers are read when they are loaded.
Parameters
pathstring- The path of the map, one that
MapFormat.TryGetRegionaccepts.
Returns
Map The map.
Exceptions
FormatException- The file is not a GeoPackage, or its metadata is not valid.
TryGetRegion(string, string?)
GeoPackageMapFormat.csGets the region of the map at a path, when the file or folder at this path is a map of this format.
Write(string, MapMetadata, IReadOnlyDictionary<MapLayer, GeoFeatureCollection>)
GeoPackageMapFormat.csWrites a map: its layers, and its metadata. The layers of a map that was at this path, and that layers does not have, are removed.
public override void Write(string path, MapMetadata metadata, IReadOnlyDictionary<MapLayer, GeoFeatureCollection> layers)Parameters
pathstring- The path of the map, such as the one
MapFormat.GetPathreturns. metadataMapMetadata- The description of the map.
layersIReadOnlyDictionary<MapLayer, GeoFeatureCollection>- The features of each layer; a layer that is not there is not written.
Exceptions
ArgumentException- A property cannot be a column of a table: its name is
fidorgeom, or differs from another one only by case.
Remarks
The file is replaced. Its dates, the last change of the layers, are MapMetadata.LastModified, else the current date: with the same date, the same map gives the same file.