NGen
Loading...
Searching...
No Matches
ngen::geopackage Namespace Reference

Classes

class  GeoPackageReader
 Reads feature collections out of the layers of a single GeoPackage. More...
 
struct  wkb
 A recursive WKB reader. More...
 

Enumerations

enum  wkb_geom_t {
  geometry = 0 ,
  point = 1 ,
  linestring = 2 ,
  polygon = 3 ,
  multipoint = 4 ,
  multilinestring = 5 ,
  multipolygon = 6 ,
  geometry_collection = 7
}
 

Functions

geojson::geometry build_geometry (const ngen::sqlite::database::iterator &row, const std::string &geom_col, std::vector< double > &bounding_box)
 Build a geometry object from GeoPackage WKB.
 
geojson::PropertyMap build_properties (const ngen::sqlite::database::iterator &row, const std::string &geom_col)
 Build properties from GeoPackage table columns.
 
geojson::Feature build_feature (const ngen::sqlite::database::iterator &row, const std::string &id, const std::string &geom_col, geojson::PropertyMap properties)
 Build a feature from a GPKG table row.
 
GeoPackageReader make_reader (const std::string &gpkg_path)
 Open gpkg_path for generic reading.
 
static void check_table_name (const std::string &table)
 Reject table names that are unsafe to interpolate into a query.
 
void throw_if_not_type (uint32_t given, wkb_geom_t expected)
 

Enumeration Type Documentation

◆ wkb_geom_t

Enumerator
geometry 
point 
linestring 
polygon 
multipoint 
multilinestring 
multipolygon 
geometry_collection 

Function Documentation

◆ build_feature()

geojson::Feature ngen::geopackage::build_feature ( const ngen::sqlite::database::iterator & row,
const std::string & id,
const std::string & geom_col,
geojson::PropertyMap properties )

Build a feature from a GPKG table row.

Schema-agnostic: reads only the geometry from row and wraps the given id and properties in the appropriate geojson::*Feature subclass. The id is taken from id alone – nothing here reads it back out of properties – so resolving which column an id came from, and publishing any derived property, is the caller's business, before or after. properties must not contain the geometry column.

Parameters
[in]rowSQLite iterator at the row to build a feature from
[in]idResolved feature id; stored on the returned Feature
[in]geom_colName of geometry column containing GPKG WKB
[in]propertiesPre-built property map for the feature
Returns
geojson::Feature Feature containing geometry and properties from the given row

References build_geometry(), geojson::GeometryCollection, geojson::LineString, geojson::MultiLineString, geojson::MultiPoint, geojson::MultiPolygon, geojson::Point, and geojson::Polygon.

Referenced by ngen::geopackage::GeoPackageReader::read().

◆ build_geometry()

geojson::geometry ngen::geopackage::build_geometry ( const ngen::sqlite::database::iterator & row,
const std::string & geom_col,
std::vector< double > & bounding_box )

Build a geometry object from GeoPackage WKB.

Parameters
[in]rowSQLite iterator at the row containing a geometry column
[in]geom_colName of geometry column containing GPKG WKB
[out]bounding_boxBounding box of the geometry to output
Returns
geojson::geometry GPKG WKB converted and projected to a boost geometry model

References utils::copy_from(), ngen::sqlite::database::iterator::get(), ngen::srs::epsg::get(), and ngen::srs::epsg::wgs84.

Referenced by build_feature().

◆ build_properties()

geojson::PropertyMap ngen::geopackage::build_properties ( const ngen::sqlite::database::iterator & row,
const std::string & geom_col )

Build properties from GeoPackage table columns.

Parameters
[in]rowSQLite iterator at the row containing the data columns
[in]geom_colName of geometry column containing GPKG WKB to ignore
Returns
geojson::PropertyMap PropertyMap of properties from the given row

References ngen::sqlite::database::iterator::columns(), and ngen::sqlite::database::iterator::types().

Referenced by ngen::geopackage::GeoPackageReader::read().

◆ check_table_name()

static void ngen::geopackage::check_table_name ( const std::string & table)
static

Reject table names that are unsafe to interpolate into a query.

Layer names reach the query text directly (SQLite cannot bind an identifier), so anything but a plain table name is refused up front.

Parameters
[in]tableTable name to validate
Exceptions
std::runtime_errorif the name is a SQLite internal table or contains characters outside the allowed set

Referenced by ngen::geopackage::GeoPackageReader::read().

◆ make_reader()

GeoPackageReader ngen::geopackage::make_reader ( const std::string & gpkg_path)

Open gpkg_path for generic reading.

Parameters
[in]gpkg_pathPath to the GeoPackage file to read
Returns
GeoPackageReader Reader owning the opened database
Exceptions
ngen::sqlite::sqlite_errorif the file cannot be opened

Referenced by ngen::hydrofabric::anonymous_namespace{HydrofabricReaderFactory.cpp}::identify().

◆ throw_if_not_type()

void ngen::geopackage::throw_if_not_type ( uint32_t given,
wkb_geom_t expected )