NGen
Loading...
Searching...
No Matches
hy_features::attributes Namespace Reference

Classes

struct  area_from_geometry_visitor
 Measures whichever geometries enclose an area; anything else has none to give. More...
 

Enumerations

enum class  AreaSource {
  attribute ,
  geometry
}
 Where a catchment's areal extent is taken from when both are available. More...
 

Functions

std::optional< double > area_from_attribute (const geojson::Feature &feature)
 The area attribute in km^2, where the feature carries it under either spelling.
 
std::optional< double > area_from_geometry (const geojson::geometry &geometry)
 The area a feature's geometry encloses, in square kilometers, where it encloses one.
 
double area_sqkm (const geojson::Feature &feature, AreaSource preferred=AreaSource::attribute)
 The areal extent of a catchment feature, in square kilometers.
 

Variables

static const std::string area_v2 = "area_sqkm"
 Reading the hydrofabric attributes a feature is realized from.
 
static const std::string area_v1 = "areasqkm"
 The area attribute as hydrofabric v1 spells it.
 

Enumeration Type Documentation

◆ AreaSource

Where a catchment's areal extent is taken from when both are available.

Enumerator
attribute 

The area attribute the hydrofabric carries.

geometry 

The area of the divide polygon, measured on the WGS84 spheroid.

Function Documentation

◆ area_from_attribute()

std::optional< double > hy_features::attributes::area_from_attribute ( const geojson::Feature & feature)
inline

The area attribute in km^2, where the feature carries it under either spelling.

References area_v1, and area_v2.

Referenced by area_sqkm().

◆ area_from_geometry()

std::optional< double > hy_features::attributes::area_from_geometry ( const geojson::geometry & geometry)
inline

The area a feature's geometry encloses, in square kilometers, where it encloses one.

Read through the feature rather than copied out of it: a divide is large, and nothing measuring one needs to own it.

A non-positive result means the polygon is degenerate or wound the wrong way, which is no more an extent than no polygon at all.

References geometry.

Referenced by area_sqkm().

◆ area_sqkm()

double hy_features::attributes::area_sqkm ( const geojson::Feature & feature,
AreaSource preferred = AreaSource::attribute )
inline

The areal extent of a catchment feature, in square kilometers.

A hydrofabric gives this twice over: as an attribute, and as the divide whose area can be measured. Either answers, so preferred decides only which is consulted first and the other still serves when it is absent. Nothing guarantees they are equal, so which one to use is a choice.

Parameters
featureThe hydrofabric feature a catchment is realized from.
preferredWhich source to consult first. Defaults to attribute.
Exceptions
std::invalid_argumentIf the feature carries neither an area attribute nor a divide.

References area_from_attribute(), area_from_geometry(), area_v1, area_v2, and attribute.

Variable Documentation

◆ area_v1

const std::string hy_features::attributes::area_v1 = "areasqkm"
static

The area attribute as hydrofabric v1 spells it.

Referenced by area_from_attribute(), and area_sqkm().

◆ area_v2

const std::string hy_features::attributes::area_v2 = "area_sqkm"
static

Reading the hydrofabric attributes a feature is realized from.

The area attribute as hydrofabric v2 spells it; tried first, being the current one.

Referenced by area_from_attribute(), and area_sqkm().