NGen
|
A lightweight, graph based index of hydrologic features. More...
#include <network.hpp>
Public Member Functions | |
Network () | |
Construct a new empty Network object. | |
Network (geojson::GeoJSON fabric) | |
Construct a new Network object from the features in fabric, assumes features have already been linked. | |
Network (geojson::GeoJSON features, std::string *link_key) | |
Construct a new Network object from features in fabric, creating edges between feature properties defined by link_key. | |
virtual | ~Network () |
Destroy the Network object. | |
NetworkIndexT::const_reverse_iterator | begin () |
Iterator to the first graph vertex descriptor of the topologically ordered graph vertices. | |
NetworkIndexT::const_reverse_iterator | end () |
Iterator to the end of the topologically ordered graph vertices. | |
auto | filter (std::string type, SortOrder order=SortOrder::Topological) |
Provides a boost transform_iterator, filtered by type , to the topologically ordered graph vertex string id's. | |
auto | filter (std::string type, int target_layer, SortOrder order=SortOrder::Topological) |
Provides a boost transform_iterator, filtered by type , to the topologically ordered graph vertex string id's. | |
std::string | get_id (Graph::vertex_descriptor idx) |
Get the string id of a given graph vertex_descriptor idx . | |
std::vector< std::string > | get_origination_ids (const std::string &id) |
Get the origination (upstream) ids (immediate neighbors) of all vertices with an edge connecting to id . | |
std::vector< std::string > | get_destination_ids (const std::string &id) |
Get the destination (downstream) ids (immediate neighbors) of all vertices with an edge from id . | |
std::size_t | size () |
The number of features in the network (number of vertices) | |
IndexPair | headwaters () |
An iterator pair (begin, end) of the network headwater features. | |
IndexPair | tailwaters () |
An iterator pair (begin, end) of the network tailwater features. | |
void | print_network () |
Print a graphviz (text) representation of the network. | |
Private Member Functions | |
void | init_indicies () |
Initializes the head/tailwater iterators after the underlying graph is constructed. | |
const NetworkIndexT & | get_sorted_index (SortOrder order=SortOrder::Topological, bool cache=true) |
Get an index of the graph in a particular order. | |
Private Attributes | |
NetworkIndexT | topo_order |
Vector of topologically sorted features. | |
NetworkIndexT | tdfp_order |
NetworkIndexT | headwaters_idx |
Vector of headwater features. | |
NetworkIndexT | tailwaters_idx |
Vector of tailwater features. | |
Graph | graph |
The underlying boost::Graph. | |
std::unordered_map< std::string, Graph::vertex_descriptor > | descriptor_map |
Mapping of identity to graph vertex descriptor. | |
std::unordered_map< std::string, long > | layer_map |
Mapping of identifier to hydrofabric layer. | |
A lightweight, graph based index of hydrologic features.
This class provides various iterators and access to hydrologic feature identities based on their topological relationships. It uses a boost::graph to model the relationship of features, and various iterators of the features based on traversal of this graph.
|
inline |
Construct a new empty Network object.
Network::Network | ( | geojson::GeoJSON | fabric | ) |
Construct a new Network object from the features in fabric, assumes features have already been linked.
fabric | a geojson::GeoJSON collection of features to add as nodes to the graph |
References network::DEFAULT_LAYER_ID, descriptor_map, graph, init_indicies(), and layer_map.
Network::Network | ( | geojson::GeoJSON | features, |
std::string * | link_key ) |
Construct a new Network object from features in fabric, creating edges between feature properties defined by link_key.
features | a geojson::GeoJSON collection of features to add as nodes to the graph |
link_key | the property to read from features to determine edge linking, i.e. 'toid' |
References descriptor_map, graph, and init_indicies().
|
inlinevirtual |
Destroy the Network object.
NetworkIndexT::const_reverse_iterator Network::begin | ( | ) |
Iterator to the first graph vertex descriptor of the topologically ordered graph vertices.
References topo_order.
Referenced by get_destination_ids(), get_origination_ids(), and init_indicies().
NetworkIndexT::const_reverse_iterator Network::end | ( | ) |
Iterator to the end of the topologically ordered graph vertices.
References topo_order.
Referenced by get_destination_ids(), get_origination_ids(), and init_indicies().
|
inline |
Provides a boost transform_iterator, filtered by type
, to the topologically ordered graph vertex string id's.
This function is useful when only interested in a single type of feature. It returns the a topologically ordered set of feature ids. For example, to print all catchments in the network:
type | The type of feature to filter for, i.e. 'cat', 'nex' |
target_layer | The layer that filtered results should be in |
order | What order to return results in |
References hy_features::identifiers::catchment, get_id(), get_sorted_index(), hy_features::identifiers::isCatchment(), hy_features::identifiers::isNexus(), layer_map, hy_features::identifiers::nexus, and hy_features::identifiers::seperator.
|
inline |
Provides a boost transform_iterator, filtered by type
, to the topologically ordered graph vertex string id's.
This function is useful when only interested in a single type of feature. It returns the a topologically ordered set of feature ids. For example, to print all catchments in the network:
type | The type of feature to filter for, i.e. 'cat', 'nex' |
order | What order to return results in |
References hy_features::identifiers::catchment, get_id(), get_sorted_index(), hy_features::identifiers::isCatchment(), hy_features::identifiers::isNexus(), hy_features::identifiers::nexus, and hy_features::identifiers::seperator.
std::vector< std::string > Network::get_destination_ids | ( | const std::string & | id | ) |
Get the destination (downstream) ids (immediate neighbors) of all vertices with an edge from id
.
id |
References begin(), descriptor_map, end(), get_id(), and graph.
std::string Network::get_id | ( | Graph::vertex_descriptor | idx | ) |
Get the string id of a given graph vertex_descriptor idx
.
idx |
std::invalid_argument | if idx is not in the range of valid vertex descriptors [0, num_verticies) |
References graph.
Referenced by filter(), filter(), get_destination_ids(), and get_origination_ids().
std::vector< std::string > Network::get_origination_ids | ( | const std::string & | id | ) |
Get the origination (upstream) ids (immediate neighbors) of all vertices with an edge connecting to id
.
id |
References begin(), descriptor_map, end(), get_id(), and graph.
|
private |
Get an index of the graph in a particular order.
order | The desired order |
cache | NOT YET IMPLEMENTED. Whether to cache the generated index. Default is true. |
References network::df_preorder_sort(), graph, tdfp_order, topo_order, and network::TransposedDepthFirstPreorder.
IndexPair Network::headwaters | ( | ) |
An iterator pair (begin, end) of the network headwater features.
References headwaters_idx.
|
private |
Initializes the head/tailwater iterators after the underlying graph is constructed.
References begin(), end(), graph, headwaters_idx, tailwaters_idx, and topo_order.
|
inline |
Print a graphviz (text) representation of the network.
References graph.
std::size_t Network::size | ( | ) |
IndexPair Network::tailwaters | ( | ) |
An iterator pair (begin, end) of the network tailwater features.
References tailwaters_idx.
|
private |
Mapping of identity to graph vertex descriptor.
Referenced by Network(), Network(), get_destination_ids(), and get_origination_ids().
|
private |
The underlying boost::Graph.
Referenced by Network(), Network(), get_destination_ids(), get_id(), get_origination_ids(), get_sorted_index(), init_indicies(), print_network(), and size().
|
private |
Vector of headwater features.
Referenced by headwaters(), and init_indicies().
|
private |
|
private |
Vector of tailwater features.
Referenced by init_indicies(), and tailwaters().
|
private |
Referenced by get_sorted_index().
|
private |
Vector of topologically sorted features.
Referenced by begin(), end(), get_sorted_index(), and init_indicies().