GeoPackageManager is the entry point for all GeoPackage operations. It is a static class — do not instantiate it. Use it to open an existing GeoPackage file or create a new one, both of which return a GeoPackage instance.
Static properties
version
@ngageoint/geopackage library. Currently "5.0.0".
Static methods
open()
Opens an existing GeoPackage. In Node.js, pass a file path. In the browser, pass aUint8Array of the file’s raw bytes.
Path to the
.gpkg file on disk (Node.js), or a Uint8Array / Buffer containing the raw GeoPackage bytes (browser or in-memory use).Optional name for the GeoPackage instance. Defaults to the basename of the file path in Node.js, or
'geopackage' when loading from bytes.Resolves with an open
GeoPackage connection ready for reading and writing.GeoPackageException: 'Invalid GeoPackage - Invalid GeoPackage Extension'— the file path does not end with.gpkgor a recognised extension.GeoPackageException: 'Unable to initialize canvas.'— the canvas adapter could not be initialised (environment-specific).GeoPackageException: 'Unable to open GeoPackage.'— the file could not be read or the underlying SQLite connection failed.
create()
Creates a new, empty GeoPackage. In Node.js, a.gpkg file is written to the supplied path. In the browser (or when no path is given), an in-memory GeoPackage is created.
File path where the new
.gpkg file should be created (Node.js only). The parent directory is created if it does not already exist. Omit or pass undefined to create an in-memory GeoPackage.Optional name for the GeoPackage instance. Defaults to the basename of
gppath, or 'geopackage' for in-memory instances.Resolves with a newly created
GeoPackage instance with the minimum required internal tables already initialised.GeoPackageException: 'Invalid GeoPackage'— the supplied path does not use a valid GeoPackage file extension.GeoPackageException: 'Unable to initialize canvas.'— canvas adapter initialisation failed.GeoPackageException: 'Unable to create GeoPackage.'— the file could not be created or the SQLite connection failed.
Always call
geoPackage.close() when you are done to release the underlying SQLite connection. Using a try / finally block is the recommended pattern.