Expand description
The parts of the OGC GeoPackage format that don’t need a database.
This crate contains the geometry codec, table definitions and validation
rules of GeoPackage 1.4, with no SQLite dependency. Most users want the
geopackage crate, which builds the SQLite container on top of this one.
Use this crate directly for format code without SQLite: in a fuzz target,
for example, or another GeoPackage implementation.
§Modules
gpb: The GeoPackage Binary (GPB) geometry header codecgeometry: A parsed geometry view (GpbGeometry), and GPB encoders for geometry objects and existing ISO WKBcurve: Envelopes read directly from ISO WKB, including exact extents for circular arcstypes: Column and geometry types (spec Table 1, Annex G)datetime:DATEandDATETIMEparsing, strict or lenient, with calendar validation and epoch conversionddl:CREATE TABLEstatements and the requiredgpkg_spatial_ref_sysrowssrs: A subset of EPSG WKT1 definitions forgpkg_spatial_ref_systriggers: RTree spatial index tables and triggers, by spec versiontiles: Tile pyramid table definitions and the tile matrix modelcoverage: Payload rules for tiled gridded coverages, checked from the TIFF or PNG headerschema: Column descriptions and value constraints from thegpkg_schemaextension (Annex F.9)metadata: Metadata records and references from thegpkg_metadataextension (Annex F.8)related: Relationships from the Related Tables Extension (OGC 18-000)version:application_idanduser_versionhandlingident: SQL identifier quoting
SQL is copied verbatim from the spec’s Annex C (“Table Definition SQL”) and Annex F.3 (“R-tree Spatial Indexes”).
§Example
Encode a geometry as a GPB blob and parse it back:
use geopackage_core::GpbGeometry;
use geopackage_core::geometry::encode_gpb;
let point = geo_types::Point::new(-6.26, 53.35);
let (blob, envelope) = encode_gpb(&point, 4326)?;
assert_eq!(envelope, Some([-6.26, -6.26, 53.35, 53.35]));
let parsed = GpbGeometry::parse(&blob)?;
assert_eq!(parsed.header().srs_id, 4326);
assert_eq!(parsed.xy_envelope(), envelope);§Cargo features
geo-types(default): EnablesGpbGeometry::to_geo, which converts a parsed geometry to ageo-typesgeometry. Thegeo_traitsimplementation doesn’t need it
§Untrusted input
GpbGeometry parses WKB with the wkb crate. Its 0.9.2 reader allocates
based on element counts read from the blob without checking them against
the blob’s length, so a malformed geometry can trigger a multi-gigabyte
allocation. Until this is fixed upstream in
georust/wkb, don’t parse geometries from
untrusted sources.
Re-exports§
pub use geometry::GeometryError;pub use geometry::GpbGeometry;pub use gpb::Envelope;pub use gpb::GpbError;pub use gpb::GpbHeader;pub use srs::SrsDefinition;pub use tiles::TileCoord;pub use tiles::TileError;pub use tiles::TileFormat;pub use tiles::TileMatrix;pub use tiles::TileMatrixSet;pub use types::ColumnType;pub use types::GeometryType;pub use types::GeometryTypeSet;pub use types::ZmFlag;pub use version::GpkgVersion;
Modules§
- coverage
- The payload profile of the tiled gridded coverage extension (OGC 17-066r2, version 1.1).
- curve
- XY envelopes computed directly from ISO WKB bytes, curve types included.
- datetime
DATE/DATETIMEcolumn value parsing and formatting.- ddl
- Normative table definition SQL (spec Annex C) and required seed rows.
- extensions
- Registered extension names (Annex F) and the
scopevalues agpkg_extensionsrow may take. - geometry
- Lazy geometry wrapper over a GeoPackage Binary (GPB) blob.
- gpb
- GeoPackage Binary (GPB) header codec.
- ident
- SQL identifier quoting for SQLite.
- metadata
- The
gpkg_metadataextension’s model (Annex F.8): metadata records and what they are attached to. - related
- The Related Tables Extension’s model (OGC 18-000): relationships between a base table and a table of related content, through a mapping table.
- schema
- The
gpkg_schemaextension’s model (Annex F.9): column descriptions and the constraints on their values. - srs
- Spatial reference system definitions: a vendored EPSG subset.
- tiles
- Tile pyramids: the user data table template (spec clause 2.2.8, Annex C), the tile matrix model, and the consistency rules a conforming pyramid satisfies.
- triggers
- RTree spatial index extension (
gpkg_rtree_index, spec Annex F.3). - types
- Column and geometry type vocabulary.
- version
- GeoPackage file identity: SQLite
application_idanduser_versionpragmas.
Enums§
- Error
- Errors produced by this crate.