Reads feature collections out of the layers of a single GeoPackage.
This class knows nothing about hydrofabrics or their schema versions, and nothing about any other convention a particular GeoPackage might follow: it implements the generic "turn a GPKG table into
a FeatureCollection" algorithm and nothing else. Everything that varies between schemas is either a parameter of read() or the caller's business afterward, so a caller with schema knowledge composes this reader rather than specializing it.
A reader owns its database connection for its lifetime, so a caller reading several layers of one file constructs a single reader and calls read() once per layer.
| std::shared_ptr< geojson::FeatureCollection > ngen::geopackage::GeoPackageReader::read |
( |
const std::string & | layer, |
|
|
const std::vector< std::string > & | ids = {}, |
|
|
const std::string & | id_column = "id" ) const |
Build a feature collection from one layer of this GeoPackage.
- Parameters
-
| [in] | layer | Layer (table) name within the GeoPackage |
| [in] | ids | Optional subset of feature IDs to capture; if empty, the entire layer is converted. IDs absent from the layer are silently ignored, so the result is the intersection of the layer and ids. |
| [in] | id_column | Column to read each feature's id from, which is also the column ids is matched against. Defaults to the conventional "id"; a caller that knows the layer names it otherwise passes that name here. |
- Returns
- std::shared_ptr<geojson::FeatureCollection> Collection of the layer's features, with a bounding box covering all of them
- Exceptions
-
| std::runtime_error | if layer is not a queryable table name or does not exist in this GeoPackage |
References ngen::geopackage::build_feature(), ngen::geopackage::build_properties(), ngen::geopackage::check_table_name(), ngen::sqlite::database::connection(), ngen::sqlite::database::contains(), db_, ngen::sqlite::database::iterator::done(), ngen::sqlite::database::iterator::get(), ngen::sqlite::database::iterator::next(), and ngen::sqlite::database::query().
Referenced by ngen::hydrofabric::GeoPackageHydrofabricReader::read_divides(), and ngen::hydrofabric::GeoPackageHydrofabricReader::read_nexus().