8.1. C++ API Docs
8.1.1. Overview
8.1.2. C++ class
8.1.2.1. JSON
-
class cell : public jsonmodel::JSONBase
Public Members
-
std::vector<long> aNeighbor
neighbor ID
-
std::vector<long> aNeighbor_land
land neighbor ID
-
std::vector<long> aNeighbor_ocean
ocean neighbor ID
-
std::vector<float> aNeighbor_distance
neighbor distance
-
float dElevation_mean
average elevation
-
float dElevation_profile0
elevation profile
-
float dElevation_raw
original elevation
-
float dLatitude_center_degree
latitude
-
float dLongitude_center_degree
longitude
-
float dArea
cell area
-
float dAccumulation
flow accumulation
-
float dSlope_between
slope between this cell and downslope cell
-
float dSlope_within
slope based on high resolution DEM
-
float dSlope_profile
slope based on elevation profile between downslope cell
-
float dLength_flowline
flowline length
-
float dLength
effective cell length
-
float dDistance_to_downslope
distance to downsloe
-
float dDistance_to_subbasin_outlet
distance to subbasin outlet
-
float dDistance_to_watershed_outlet
distance to watershed outlet
-
int nVertex
number of vertex
-
long lCellID
global cell ID
-
long lCellID_downstream_burned
pre-descibed global downstream cell ID
-
long lCellID_downslope
global downslope cell ID
-
std::vector<long> aNeighbor
-
class vertex
8.1.2.2. Domain
-
class domain
Public Functions
-
domain(std::string sFilename_configuration_in)
- Parameters:
sFilename_configuration_in – user provided model configuration file please refer to the user guide for I/O instruction
-
int domain_read()
read data from the model configuration file
- Returns:
-
int domain_read_configuration_file()
read the user provided configuration file
- Returns:
-
int domain_read_input_data()
read input data
- Returns:
int
-
int domain_retrieve_user_input()
extract the dictionary from user provided configuration file
- Returns:
-
int domain_run()
run the model
- Returns:
-
int domain_cleanup()
clean up the model status
- Returns:
-
domain(std::string sFilename_configuration_in)
8.1.2.3. Compset
-
class compset
Public Functions
-
int compset_initialize_model()
initialize the model
- Returns:
-
int compset_save_model()
save all the model outputs
- Returns:
-
int compset_priority_flood_depression_filling()
DEM depression filling
- Returns:
-
int compset_stream_burning_with_topology(long lCellID_center)
- Parameters:
lCellIndex_center –
- Returns:
int
-
int compset_stream_burning_without_topology(long lCellID_center)
- Parameters:
lCellIndex_center –
- Returns:
int
-
int compset_breaching_stream_elevation(long lCellID_center)
- Parameters:
lCellID_active –
- Returns:
int
-
int compset_calculate_flow_direction()
calculate the flow direction based on elevation, this step “should” only be run after the depression filling
- Returns:
-
int compset_calculate_flow_accumulation()
calculate the flow accumulation based on flow direction
- Returns:
-
int compset_define_stream_grid()
define the stream network using flow accumulation value
- Returns:
-
int compset_define_watershed_boundary()
define the watershed boundary using outlet
- Returns:
-
int compset_define_stream_confluence()
define the stream confluence point because we need to topology info, the vCell_active will be used
- Returns:
-
int compset_define_stream_segment()
define the stream segment, must use vCell_active
- Returns:
-
int compset_define_subbasin()
define subbasin boundary, it requires cell topology, so the vCell_active is used
- Returns:
-
int compset_calculate_watershed_characteristics()
- Returns:
int
-
int compset_save_watershed_characteristics()
save the watershed characteristics in the output
- Returns:
-
std::vector<hexagon> compset_obtain_boundary(std::vector<hexagon> vCell_in)
retrieve the boundary of the hexagon grid boundary it is not ordered
- Parameters:
vCell_in – :the hexagon grid
- Returns:
-
int find_land_ocean_interface_neighbors(long lCellID_in)
- Parameters:
lCellID_in –
- Returns:
int
-
int compset_update_cell_elevation()
- Returns:
int
-
int compset_update_vertex_elevation()
- Returns:
int
-
int compset_check_digital_elevation_model_depression(std::vector<hexagon> vCell_in)
private functions. check whether there is local depression in the dem or not. in fact, a more rigorous method should pass in dem instead of the hexagon vector but because we will not change any member variable here, it should be safe to pass in the vector
- Parameters:
vCell_in –
- Returns:
-
int compset_initialize_model()
8.1.2.4. General
-
class edge
Public Functions
-
int calculate_length()
calculate the arc length of an edge on a sphere
- Returns:
int
-
int check_point_overlap(vertex pt)
check whether a vertex is one the edge or not
- Parameters:
pVertex_in –
- Returns:
int
-
int check_overlap(vertex pt_start, vertex pt_end)
check whether an edge overlap with another edge, this algorithm has error
- Parameters:
pVertex_start –
pVertex_end –
- Returns:
int
check whether two edge are the same ignoring the direction
- Parameters:
pEdge_in –
- Returns:
int
-
int calculate_length()
-
class flowline
Public Functions
check whether two flowlines share a starting or ending vertex
- Parameters:
pFlowline_in –
- Returns:
int
check two flowlines share the specified vertex
- Parameters:
pFlowline_in –
pVertex_shared –
- Returns:
int
-
class hexagon
Public Functions
-
int calculate_average_edge_length()
calculate the mean edge length
- Returns:
int
-
int calculate_effective_resolution()
calculate the effective resolution using area
- Returns:
int
-
int update_location()
update the x y z location
- Returns:
int
Public Members
-
long lCellID
Brief description. this is the mesh id from the json, it might be the same with Global ID,
Detailed description starts here.
-
int calculate_average_edge_length()
-
class segment
-
class subbasin
-
class watershed
Public Functions
-
int watershed_build_stream_topology()
build the stream topology based on stream segment information
- Returns:
-
int watershed_define_stream_order()
build the stream order based on stream topology
- Returns:
-
int calculate_watershed_characteristics()
calculate the watershed characteristics
- Returns:
-
int calculate_watershed_drainage_area()
calculate the watershed drainage total area we can either sum up hexagon or sum up subbasin
- Returns:
-
int calculate_watershed_total_stream_length()
calculate the total stream length
- Returns:
-
int calculate_watershed_longest_stream_length()
calculate the longest stream length
- Returns:
-
int calculate_watershed_drainage_density()
calculate the watershed area to stream length ratio
- Returns:
-
int calculate_watershed_average_slope()
calculate the mean slope of the watershed we can use either subbasin or each cell
- Returns:
-
int calculate_topographic_wetness_index()
calculate the TWI index using method from //https://en.wikipedia.org/wiki/Topographic_wetness_index // {\displaystyle \ln {a \over \tan b}}
- Returns:
-
int save_watershed_characteristics()
save the watershed characteristics in the output
- Returns:
-
int watershed_build_stream_topology()
8.1.2.5. Data
-
class data
Public Static Functions
-
static float *read_binary(std::string sFilename_in)
read_eco3d binary file (float type)
- Parameters:
sFilename_in –
- Returns:
float*
-
static std::vector<float> read_binary_vector(std::string sFilename_in)
read_eco3d binary and save to a vector
- Parameters:
sFilename_in –
- Returns:
vector<float>
-
static int write_binary_vector(std::string sFilename_in, vector<float> vData_in)
write vector to float binary file
- Parameters:
sFilename_out –
vData_in –
- Returns:
int
-
static float *read_binary(std::string sFilename_in)