From 62c6241a9c2c522f191e2fd45625bc328e95efef Mon Sep 17 00:00:00 2001 From: eric bryant Date: Sat, 7 Sep 2019 09:57:02 -0400 Subject: [PATCH] fix for 0-byte WPTs --- .../cplusplus/classes/Route/read_wpt.cpp | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/siteupdate/cplusplus/classes/Route/read_wpt.cpp b/siteupdate/cplusplus/classes/Route/read_wpt.cpp index e99c29fb..46800a68 100644 --- a/siteupdate/cplusplus/classes/Route/read_wpt.cpp +++ b/siteupdate/cplusplus/classes/Route/read_wpt.cpp @@ -110,25 +110,24 @@ void Route::read_wpt delete[] wptdata; // per-route datachecks - - // look for hidden termini - if (point_list.front()->is_hidden) datacheckerrors->add(this, point_list.front()->label, "", "", "HIDDEN_TERMINUS", ""); - if (point_list.back()->is_hidden) datacheckerrors->add(this, point_list.back()->label, "", "", "HIDDEN_TERMINUS", ""); - - // angle check is easier with a traditional for loop and array indices - for (unsigned int i = 1; i < point_list.size()-1; i++) - { //cout << "computing angle for " << point_list[i-1].str() << ' ' << point_list[i].str() << ' ' << point_list[i+1].str() << endl; - if (point_list[i-1]->same_coords(point_list[i]) || point_list[i+1]->same_coords(point_list[i])) - datacheckerrors->add(this, point_list[i-1]->label, point_list[i]->label, point_list[i+1]->label, "BAD_ANGLE", ""); - else { double angle = point_list[i]->angle(point_list[i-1], point_list[i+1]); - if (angle > 135) - { sprintf(fstr, "%.2f", angle); - datacheckerrors->add(this, point_list[i-1]->label, point_list[i]->label, point_list[i+1]->label, "SHARP_ANGLE", fstr); - } - } - } - if (point_list.size() < 2) el->add_error("Route contains fewer than 2 points: " + str()); + else { // look for hidden termini + if (point_list.front()->is_hidden) datacheckerrors->add(this, point_list.front()->label, "", "", "HIDDEN_TERMINUS", ""); + if (point_list.back()->is_hidden) datacheckerrors->add(this, point_list.back()->label, "", "", "HIDDEN_TERMINUS", ""); + + // angle check is easier with a traditional for loop and array indices + for (unsigned int i = 1; i < point_list.size()-1; i++) + { //cout << "computing angle for " << point_list[i-1].str() << ' ' << point_list[i].str() << ' ' << point_list[i+1].str() << endl; + if (point_list[i-1]->same_coords(point_list[i]) || point_list[i+1]->same_coords(point_list[i])) + datacheckerrors->add(this, point_list[i-1]->label, point_list[i]->label, point_list[i+1]->label, "BAD_ANGLE", ""); + else { double angle = point_list[i]->angle(point_list[i-1], point_list[i+1]); + if (angle > 135) + { sprintf(fstr, "%.2f", angle); + datacheckerrors->add(this, point_list[i-1]->label, point_list[i]->label, point_list[i+1]->label, "SHARP_ANGLE", fstr); + } + } + } + } std::cout << '.' << std::flush; //std::cout << str() << std::flush; //print_route();