|
NGen
|
Reads a hydrofabric v4.0beta1 GeoPackage. More...
#include <GeoPackageHydrofabricReader.hpp>
Inheritance diagram for ngen::hydrofabric::V4_0Beta1GeoPackageHydrofabricReader:
Collaboration diagram for ngen::hydrofabric::V4_0Beta1GeoPackageHydrofabricReader:Public Member Functions | |
| V4_0Beta1GeoPackageHydrofabricReader (geopackage::GeoPackageReader divides_reader, std::optional< geopackage::GeoPackageReader > nexus_reader) | |
| 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. | |
Protected Member Functions | |
| void | check_required_columns (const std::string &layer) const override |
Verify up front that layer carries the columns this version needs. | |
| void | attribute_divide_toid (geojson::PropertyMap &properties, const std::string &id) const override |
| Attribute "toid" on one divide, however this variant expresses it. | |
| void | normalize_nexus (geojson::FeatureCollection &nexus) const override |
| Bring a freshly read nexus collection into ngen's canonical vocabulary, in place. | |
| void | normalize_divides (geojson::FeatureCollection ÷s) const override |
| Alias each divide's downstream nexus to "toid", then warn once with a count of the divides that ended up without one, rather than once per divide. | |
| const geopackage::GeoPackageReader & | reader_for (const std::string &layer) const |
The reader for the file holding layer. | |
| HydrofabricVersion | version () const noexcept |
| The detected schema version, for the version-keyed schema utilities. | |
Private Attributes | |
| std::unordered_map< std::string, std::string > | divide_toid_lookup_ |
| bool | divide_toid_lookup_built_ = false |
| geopackage::GeoPackageReader | divides_reader_ |
| std::optional< geopackage::GeoPackageReader > | nexus_reader_ |
| const HydrofabricVersion | version_ |
Reads a hydrofabric v4.0beta1 GeoPackage.
beta1 divides have no downstream column of their own and reach their nexus indirectly, through the flowpath they contain. This reader resolves that join once per read into a lookup table, rather than once per divide.
| ngen::hydrofabric::V4_0Beta1GeoPackageHydrofabricReader::V4_0Beta1GeoPackageHydrofabricReader | ( | geopackage::GeoPackageReader | divides_reader, |
| std::optional< geopackage::GeoPackageReader > | nexus_reader ) |
| [in] | divides_reader | Reader for the GeoPackage holding the divides layer |
| [in] | nexus_reader | Reader for the nexus layer's GeoPackage, if a separate file |
|
overrideprotectedvirtual |
Attribute "toid" on one divide, however this variant expresses it.
Leaving "toid" unset marks the divide terminal, which is what an absent downstream reference means to every consumer downstream of the loader.
| [in,out] | properties | Property map for the divide |
| [in] | id | Resolved divide id |
| std::runtime_error | if a column this variant requires is absent from the row |
Implements ngen::hydrofabric::AbstractV4GeoPackageHydrofabricReader.
References divide_toid_lookup_, and ngen::hydrofabric::TOID_KEY.
|
overrideprotectedvirtual |
Verify up front that layer carries the columns this version needs.
Checking before the read means a file missing a required column is reported as the schema problem it is, rather than as a failure to find a column mid-row. The default checks nothing.
| [in] | layer | Hydrofabric layer about to be read |
| std::runtime_error | if a required column is absent |
Reimplemented from ngen::hydrofabric::AbstractV4GeoPackageHydrofabricReader.
References ngen::hydrofabric::AbstractV4GeoPackageHydrofabricReader::check_required_columns(), ngen::hydrofabric::DIVIDES_LAYER, ngen::hydrofabric::FLOWPATH_ID_COLUMN, ngen::hydrofabric::GeoPackageHydrofabricReader::reader_for(), ngen::hydrofabric::GeoPackageHydrofabricReader::version(), and ngen::hydrofabric::version_label().
|
overrideprotectedvirtualinherited |
Alias each divide's downstream nexus to "toid", then warn once with a count of the divides that ended up without one, rather than once per divide.
| [in,out] | divides | Divides collection to update in place |
| std::runtime_error | if a row cannot be translated |
Implements ngen::hydrofabric::GeoPackageHydrofabricReader.
References ngen::hydrofabric::AbstractV4GeoPackageHydrofabricReader::attribute_divide_toid(), ngen::hydrofabric::DIVIDE_ID_COLUMN, ngen::hydrofabric::TOID_KEY, ngen::hydrofabric::GeoPackageHydrofabricReader::version(), and ngen::hydrofabric::version_label().
|
overrideprotectedvirtualinherited |
Bring a freshly read nexus collection into ngen's canonical vocabulary, in place.
The generic read stores each column under the file's own name for it, but for simplicity, ngen's consumers key on specific names: "id" and "toid". A version that names them differently aliases its columns onto those names here, leaving the originals in place. Implementations also validate the rows they translate and summarize outcomes worth a warning.
| [in,out] | nexus | Nexus collection to update in place |
| std::runtime_error | if a row cannot be translated |
Implements ngen::hydrofabric::GeoPackageHydrofabricReader.
References ngen::hydrofabric::ID_KEY, ngen::hydrofabric::NEXUS_ID_COLUMN, ngen::hydrofabric::NEXUS_TOID_COLUMN, ngen::hydrofabric::TOID_KEY, ngen::hydrofabric::GeoPackageHydrofabricReader::version(), and ngen::hydrofabric::version_label().
|
overridevirtual |
Read the hydrofabric's divides.
| [in] | ids | Optional 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. |
| std::runtime_error | if the divides cannot be read |
Reimplemented from ngen::hydrofabric::GeoPackageHydrofabricReader.
References ngen::hydrofabric::build_divide_toid_lookup(), divide_toid_lookup_, divide_toid_lookup_built_, ngen::hydrofabric::DIVIDES_LAYER, ngen::hydrofabric::GeoPackageHydrofabricReader::read_divides(), ngen::hydrofabric::GeoPackageHydrofabricReader::reader_for(), and ngen::hydrofabric::GeoPackageHydrofabricReader::version().
|
overridevirtualinherited |
Read the hydrofabric's nexuses.
| [in] | ids | Optional subset of nexus IDs to capture; if empty, all nexuses are read. IDs that the hydrofabric does not contain are silently ignored. |
| std::runtime_error | if the nexuses cannot be read |
Implements ngen::hydrofabric::HydrofabricReader.
References ngen::hydrofabric::GeoPackageHydrofabricReader::check_required_columns(), ngen::geopackage::GeoPackageReader::db(), ngen::hydrofabric::get_layer_id_column(), ngen::hydrofabric::NEXUS_LAYER, ngen::hydrofabric::GeoPackageHydrofabricReader::normalize_nexus(), ngen::geopackage::GeoPackageReader::read(), ngen::hydrofabric::GeoPackageHydrofabricReader::reader_for(), and ngen::hydrofabric::GeoPackageHydrofabricReader::version_.
|
protectedinherited |
The reader for the file holding layer.
The two hydrofabric roles are the whole domain: "nexus" resolves to the second file when there is one and otherwise to the single shared file, and "divides" always resolves to the file it was constructed from. Any other name is refused rather than guessed at – in a split hydrofabric there is no honest answer for which file holds a layer this class does not know, and a guess would surface later as a missing-table error naming the wrong file.
| [in] | layer | Hydrofabric layer name, "divides" or "nexus" |
| std::logic_error | if layer is neither "divides" nor "nexus" |
References ngen::hydrofabric::DIVIDES_LAYER, ngen::hydrofabric::GeoPackageHydrofabricReader::divides_reader_, ngen::hydrofabric::NEXUS_LAYER, and ngen::hydrofabric::GeoPackageHydrofabricReader::nexus_reader_.
Referenced by ngen::hydrofabric::AbstractV4GeoPackageHydrofabricReader::check_required_columns(), check_required_columns(), ngen::hydrofabric::V4_0GeoPackageHydrofabricReader::check_required_columns(), ngen::hydrofabric::GeoPackageHydrofabricReader::read_divides(), read_divides(), and ngen::hydrofabric::GeoPackageHydrofabricReader::read_nexus().
|
protectednoexceptinherited |
The detected schema version, for the version-keyed schema utilities.
References ngen::hydrofabric::GeoPackageHydrofabricReader::version_.
Referenced by ngen::hydrofabric::AbstractV4GeoPackageHydrofabricReader::check_required_columns(), check_required_columns(), ngen::hydrofabric::V4_0GeoPackageHydrofabricReader::check_required_columns(), ngen::hydrofabric::AbstractV4GeoPackageHydrofabricReader::normalize_divides(), ngen::hydrofabric::AbstractV4GeoPackageHydrofabricReader::normalize_nexus(), and read_divides().
|
private |
Referenced by attribute_divide_toid(), and read_divides().
|
private |
Referenced by read_divides().
|
privateinherited |
Referenced by ngen::hydrofabric::GeoPackageHydrofabricReader::reader_for().
|
privateinherited |
Referenced by ngen::hydrofabric::GeoPackageHydrofabricReader::reader_for().
|
privateinherited |