NGen
Loading...
Searching...
No Matches
ngen::geopackage::GeoPackageReader Class Reference

Reads feature collections out of the layers of a single GeoPackage. More...

#include <GeoPackageReader.hpp>

+ Collaboration diagram for ngen::geopackage::GeoPackageReader:

Public Member Functions

 GeoPackageReader (sqlite::database db)
 Take ownership of an open database.
 
 GeoPackageReader (const GeoPackageReader &)=delete
 
GeoPackageReader & operator= (const GeoPackageReader &)=delete
 
 GeoPackageReader (GeoPackageReader &&)=default
 
GeoPackageReader & operator= (GeoPackageReader &&)=default
 
std::shared_ptr< geojson::FeatureCollection > 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.
 
const sqlite::database & db () const noexcept
 The database being read.
 

Private Attributes

sqlite::database db_
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ GeoPackageReader() [1/3]

ngen::geopackage::GeoPackageReader::GeoPackageReader ( sqlite::database db)
explicit

Take ownership of an open database.

Parameters
[in]dbOpen GeoPackage database to read from

◆ GeoPackageReader() [2/3]

ngen::geopackage::GeoPackageReader::GeoPackageReader ( const GeoPackageReader & )
delete

◆ GeoPackageReader() [3/3]

ngen::geopackage::GeoPackageReader::GeoPackageReader ( GeoPackageReader && )
default

Member Function Documentation

◆ db()

◆ operator=() [1/2]

GeoPackageReader & ngen::geopackage::GeoPackageReader::operator= ( const GeoPackageReader & )
delete

◆ operator=() [2/2]

GeoPackageReader & ngen::geopackage::GeoPackageReader::operator= ( GeoPackageReader && )
default

◆ read()

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]layerLayer (table) name within the GeoPackage
[in]idsOptional 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_columnColumn 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_errorif 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().

Member Data Documentation

◆ db_

sqlite::database ngen::geopackage::GeoPackageReader::db_
private

Referenced by db(), and read().


The documentation for this class was generated from the following files: