Skip to content

Commit 12d8f43

Browse files
committed
Another update to 0.7 development version. Full 0.7 release coming soon
1 parent de46b16 commit 12d8f43

15 files changed

+2217
-1627
lines changed

src/LSDFlowInfo.cpp

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,12 @@ void LSDFlowInfo::retrieve_receiver_information(int current_node,
850850
int& receiver_node, int& receiver_row,
851851
int& receiver_col)
852852
{
853+
if (current_node >= NDataNodes)
854+
{
855+
cout << "Fatal error, you are looking for a flowinfo node that doesn't exist" << endl;
856+
exit(0);
857+
}
858+
853859
int rn, rr, rc;
854860
rn = ReceiverVector[current_node];
855861
rr = RowIndex[rn];
@@ -870,6 +876,12 @@ void LSDFlowInfo::retrieve_receiver_information(int current_node,
870876
void LSDFlowInfo::retrieve_receiver_information(int current_node,
871877
int& receiver_node)
872878
{
879+
if (current_node >= NDataNodes)
880+
{
881+
cout << "Fatal error, you are looking for a flowinfo node that doesn't exist" << endl;
882+
exit(0);
883+
}
884+
873885
int rn;
874886
rn = ReceiverVector[current_node];
875887
receiver_node = rn;
@@ -887,6 +899,12 @@ void LSDFlowInfo::retrieve_receiver_information(int current_node,
887899
void LSDFlowInfo::retrieve_current_row_and_col(int current_node,int& curr_row,
888900
int& curr_col)
889901
{
902+
if (current_node >= NDataNodes)
903+
{
904+
cout << "Fatal error, you are looking for a flowinfo node that doesn't exist" << endl;
905+
exit(0);
906+
}
907+
890908
int cr, cc;
891909
cr = RowIndex[current_node];
892910
cc = ColIndex[current_node];
@@ -900,6 +918,63 @@ int LSDFlowInfo::get_NodeIndex_from_row_col(int row, int col)
900918
return NodeIndex[row][col];
901919
}
902920

921+
922+
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
923+
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
924+
// algorithms for searching the vectors
925+
// This gets the rows and columns of a vector of node
926+
//
927+
// SMM 15/06/2022
928+
//
929+
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
930+
void LSDFlowInfo::retrieve_rows_and_cols_from_node_list(vector<int> current_nodes,vector<int>& curr_rows,
931+
vector<int>& curr_cols)
932+
{
933+
934+
int n_nodes = int(current_nodes.size());
935+
int cr, cc;
936+
vector<int> crs;
937+
vector<int> ccs;
938+
int current_node;
939+
for(int i = 0; i< n_nodes; i++)
940+
{
941+
current_node = current_nodes[i];
942+
if (current_node >= NDataNodes)
943+
{
944+
cout << "Fatal error, you are looking for a flowinfo node that doesn't exist" << endl;
945+
exit(0);
946+
}
947+
948+
crs.push_back(RowIndex[current_node]);
949+
ccs.push_back(ColIndex[current_node]);
950+
}
951+
952+
curr_rows = crs;
953+
curr_cols = ccs;
954+
}
955+
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
956+
957+
958+
959+
vector<int> LSDFlowInfo::retrieve_contributing_pixels_from_node_list(vector<int> current_nodes)
960+
{
961+
vector<int> NContrib;
962+
int current_node;
963+
int n_nodes = int(current_nodes.size());
964+
for (int i = 0; i<n_nodes; i++)
965+
{
966+
current_node = current_nodes[i];
967+
if (current_node >= NDataNodes)
968+
{
969+
cout << "Fatal error, you are looking for a flowinfo node that doesn't exist" << endl;
970+
exit(0);
971+
}
972+
NContrib.push_back( NContributingNodes[current_node] );
973+
}
974+
return NContrib;
975+
}
976+
977+
903978
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
904979
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
905980
// algorithms for searching the vectors
@@ -910,6 +985,12 @@ int LSDFlowInfo::get_NodeIndex_from_row_col(int row, int col)
910985
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
911986
void LSDFlowInfo::get_x_and_y_from_current_node(int current_node, float& current_X, float& current_Y)
912987
{
988+
if (current_node >= NDataNodes)
989+
{
990+
cout << "Fatal error, you are looking for a flowinfo node that doesn't exist" << endl;
991+
exit(0);
992+
}
993+
913994
int cr,cc;
914995
retrieve_current_row_and_col(current_node, cr,cc);
915996
get_x_and_y_locations(cr, cc, current_X, current_Y);
@@ -925,6 +1006,12 @@ void LSDFlowInfo::get_x_and_y_from_current_node(int current_node, float& current
9251006
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
9261007
void LSDFlowInfo::get_lat_and_long_from_current_node(int current_node, double& current_lat, double& current_long, LSDCoordinateConverterLLandUTM Converter)
9271008
{
1009+
if (current_node >= NDataNodes)
1010+
{
1011+
cout << "Fatal error, you are looking for a flowinfo node that doesn't exist" << endl;
1012+
exit(0);
1013+
}
1014+
9281015
int cr,cc;
9291016
retrieve_current_row_and_col(current_node, cr,cc);
9301017
double latitude;

0 commit comments

Comments
 (0)