Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 17 additions & 18 deletions siteupdate/cplusplus/classes/Route/read_wpt.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -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();
Expand Down