NGen
Loading...
Searching...
No Matches
ngen::hydrofabric::GeoJSONHydrofabricReader Class Reference

Reads a hydrofabric stored as a pair of GeoJSON files. More...

#include <GeoJSONHydrofabricReader.hpp>

+ Inheritance diagram for ngen::hydrofabric::GeoJSONHydrofabricReader:
+ Collaboration diagram for ngen::hydrofabric::GeoJSONHydrofabricReader:

Public Member Functions

 GeoJSONHydrofabricReader (std::string divides_path, std::string nexus_path)
 
geojson::GeoJSON read_divides (const std::vector< std::string > &ids={}) override
 Read the hydrofabric's divides.
 
geojson::GeoJSON read_nexus (const std::vector< std::string > &ids={}) override
 Read the hydrofabric's nexuses.
 

Private Attributes

const std::string divides_path_
 
const std::string nexus_path_
 

Detailed Description

Reads a hydrofabric stored as a pair of GeoJSON files.

This is the original hydrofabric format, and the reason the drivers take two data paths: the divides and the nexuses were always separate files. There is no schema version to detect and nothing to translate – GeoJSON hydrofabrics carry "id" and "toid" as ordinary feature properties – so this reader is a thin pass-through to geojson::read().

That last point is an assumption, not a check: this reader translates nothing, so it reads only the "id"/"toid" vocabulary that HydrofabricVersion::V1_GEOJSON names. GeoJSON exported from a later hydrofabric would carry that release's column names instead – divide_id, nexus_id, flowpath_toid – and would load with empty feature ids rather than being refused. Nothing in ngen produces such files today; supporting them would mean identifying a release from GeoJSON content, which no caller currently needs.

Constructor & Destructor Documentation

◆ GeoJSONHydrofabricReader()

ngen::hydrofabric::GeoJSONHydrofabricReader::GeoJSONHydrofabricReader ( std::string divides_path,
std::string nexus_path )
Parameters
[in]divides_pathPath to the GeoJSON file holding the divides
[in]nexus_pathPath to the GeoJSON file holding the nexuses; may name the same file

Member Function Documentation

◆ read_divides()

geojson::GeoJSON ngen::hydrofabric::GeoJSONHydrofabricReader::read_divides ( const std::vector< std::string > & ids = {})
overridevirtual

Read the hydrofabric's divides.

Parameters
[in]idsOptional subset of divide IDs to capture; if empty, all divides are read. IDs that the hydrofabric does not contain are silently ignored, so the result is the intersection of the hydrofabric and ids.
Returns
geojson::GeoJSON Collection of divide features
Exceptions
std::runtime_errorif the divides cannot be read

Implements ngen::hydrofabric::HydrofabricReader.

References divides_path_, and geojson::read().

◆ read_nexus()

geojson::GeoJSON ngen::hydrofabric::GeoJSONHydrofabricReader::read_nexus ( const std::vector< std::string > & ids = {})
overridevirtual

Read the hydrofabric's nexuses.

Parameters
[in]idsOptional subset of nexus IDs to capture; if empty, all nexuses are read. IDs that the hydrofabric does not contain are silently ignored.
Returns
geojson::GeoJSON Collection of nexus features
Exceptions
std::runtime_errorif the nexuses cannot be read

Implements ngen::hydrofabric::HydrofabricReader.

References nexus_path_, and geojson::read().

Member Data Documentation

◆ divides_path_

const std::string ngen::hydrofabric::GeoJSONHydrofabricReader::divides_path_
private

Referenced by read_divides().

◆ nexus_path_

const std::string ngen::hydrofabric::GeoJSONHydrofabricReader::nexus_path_
private

Referenced by read_nexus().


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