Skip to content
Merged
Show file tree
Hide file tree
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
61 changes: 29 additions & 32 deletions siteupdate/cplusplus/classes/DatacheckEntry.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,38 +7,35 @@ class DatacheckEntry
as the endpoints of a too-long segment or the three points that
form a sharp angle)

code is the error code string, one of:
BAD_ANGLE
BUS_WITH_I
DUPLICATE_COORDS
DUPLICATE_LABEL
HIDDEN_JUNCTION
HIDDEN_TERMINUS
INVALID_FINAL_CHAR
INVALID_FIRST_CHAR
LABEL_INVALID_CHAR
LABEL_LOOKS_HIDDEN
LABEL_PARENS
LABEL_SELFREF
LABEL_SLASHES
LABEL_UNDERSCORES
LACKS_GENERIC
LONG_SEGMENT
LONG_UNDERSCORE
MALFORMED_LAT
MALFORMED_LON
MALFORMED_URL
NONTERMINAL_UNDERSCORE
OUT_OF_BOUNDS
SHARP_ANGLE
US_BANNER
VISIBLE_DISTANCE
VISIBLE_HIDDEN_COLOC

info is additional information, at this time either a distance (in
miles) for a long segment error, an angle (in degrees) for a sharp
angle error, or a coordinate pair for duplicate coordinates, other
route/label for point pair errors
code is the error code | info is additional
string, one of: | information, if used:
-----------------------+--------------------------------------------
BAD_ANGLE |
BUS_WITH_I |
DUPLICATE_COORDS | coordinate pair
DUPLICATE_LABEL |
HIDDEN_JUNCTION | number of incident edges in TM master graph
HIDDEN_TERMINUS |
INVALID_FINAL_CHAR | final character in label
INVALID_FIRST_CHAR | first character in label other than *
LABEL_INVALID_CHAR |
LABEL_LOOKS_HIDDEN |
LABEL_PARENS |
LABEL_SELFREF |
LABEL_SLASHES |
LABEL_UNDERSCORES |
LACKS_GENERIC |
LONG_SEGMENT | distance in miles
LONG_UNDERSCORE |
MALFORMED_LAT | malformed "lat=" parameter from OSM url
MALFORMED_LON | malformed "lon=" parameter from OSM url
MALFORMED_URL | always "MISSING_ARG(S)"
NONTERMINAL_UNDERSCORE |
OUT_OF_BOUNDS | coordinate pair
SHARP_ANGLE | angle in degrees
US_BANNER |
VISIBLE_DISTANCE | distance in miles
VISIBLE_HIDDEN_COLOC | hidden point at same coordinates

fp is a boolean indicating whether this has been reported as a
false positive (would be set to true later)
Expand Down
70 changes: 38 additions & 32 deletions siteupdate/cplusplus/classes/Waypoint/Waypoint.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -249,66 +249,72 @@ std::string Waypoint::root_at_label()
{ return route->root + "@" + label;
}

void Waypoint::nmplogs(std::list<std::string> &nmpfplist, std::ofstream &nmpnmp, std::list<std::string> &nmploglines)
void Waypoint::nmplogs(std::unordered_set<std::string> &nmpfps, std::ofstream &nmpnmp, std::list<std::string> &nmploglines)
{ if (!near_miss_points.empty())
{ // sort the near miss points for consistent ordering to facilitate NMP FP marking
near_miss_points.sort(sort_root_at_label);
bool nmplooksintentional = 0;
// construct string for nearmisspoints.log & FP matching
std::string nmpline = str() + " NMP";
std::list<std::string> nmpnmplines;
for (Waypoint *other_w : near_miss_points) nmpline += " " + other_w->str();
// check for string in fp list
std::unordered_set<std::string>::iterator fpit = nmpfps.find(nmpline);
if (fpit == nmpfps.end()) fpit = nmpfps.find(nmpline+" [LOOKS INTENTIONAL]");
if (fpit == nmpfps.end()) fpit = nmpfps.find(nmpline+" [SOME LOOK INTENTIONAL]");
bool fp = fpit != nmpfps.end();
// write lines to tm-master.nmp
size_t li_count = 0;
for (Waypoint *other_w : near_miss_points)
{ if ((fabs(lat - other_w->lat) < 0.0000015) && (fabs(lng - other_w->lng) < 0.0000015))
nmplooksintentional = 1;
nmpline += " " + other_w->str();
{ bool li = (fabs(lat - other_w->lat) < 0.0000015) && (fabs(lng - other_w->lng) < 0.0000015);
if (li) li_count++;
// make sure we only plot once, since the NMP should be listed
// both ways (other_w in w's list, w in other_w's list)
if (sort_root_at_label(this, other_w))
{ char coordstr[51];

std::string nmpnmpline = root_at_label();
nmpnmp << root_at_label();
sprintf(coordstr, " %.15g", lat);
if (!strchr(coordstr, '.')) strcat(coordstr, ".0"); // add single trailing zero to ints for compatibility with Python
nmpnmpline += coordstr;
nmpnmp << coordstr;
sprintf(coordstr, " %.15g", lng);
if (!strchr(coordstr, '.')) strcat(coordstr, ".0"); // add single trailing zero to ints for compatibility with Python
nmpnmpline += coordstr;
nmpnmplines.push_back(nmpnmpline);

nmpnmpline = other_w->root_at_label();
nmpnmp << coordstr;
if (fp || li)
{ nmpnmp << ' ';
if (fp) nmpnmp << "FP";
if (li) nmpnmp << "LI";
}
nmpnmp << '\n';

nmpnmp << other_w->root_at_label();
sprintf(coordstr, " %.15g", other_w->lat);
if (!strchr(coordstr, '.')) strcat(coordstr, ".0"); // add single trailing zero to ints for compatibility with Python
nmpnmpline += coordstr;
nmpnmp << coordstr;
sprintf(coordstr, " %.15g", other_w->lng);
if (!strchr(coordstr, '.')) strcat(coordstr, ".0"); // add single trailing zero to ints for compatibility with Python
nmpnmpline += coordstr;
nmpnmplines.push_back(nmpnmpline);
nmpnmp << coordstr;
if (fp || li)
{ nmpnmp << ' ';
if (fp) nmpnmp << "FP";
if (li) nmpnmp << "LI";
}
nmpnmp << '\n';
}
}
// indicate if this was in the FP list or if it's off by exact amt
// so looks like it's intentional, and detach near_miss_points list
// so it doesn't get a rewrite in nmp_merged WPT files
// also set the extra field to mark FP/LI items in the .nmp file
std::string extra_field;
std::list<std::string>::iterator fp = nmpfplist.begin();
while (fp != nmpfplist.end() && *fp != nmpline) fp++;
if (fp != nmpfplist.end())
{ nmpfplist.erase(fp);
nmpline += " [MARKED FP]";
if (li_count)
{ if ( li_count == std::distance(near_miss_points.begin(), near_miss_points.end()) )
nmpline += " [LOOKS INTENTIONAL]";
else nmpline += " [SOME LOOK INTENTIONAL]";
near_miss_points.clear();
extra_field += "FP";
}
if (nmplooksintentional)
{ nmpline += " [LOOKS INTENTIONAL]";
if (fp)
{ nmpfps.erase(fpit);
nmpline += " [MARKED FP]";
near_miss_points.clear();
extra_field += "LI";
}
if (extra_field != "") extra_field = " " + extra_field;
nmploglines.push_back(nmpline);

// write actual lines to .nmp file, indicating FP and/or LI
// for marked FPs or looks intentional items
for (std::string nmpnmpline : nmpnmplines)
nmpnmp << nmpnmpline << extra_field << '\n';
}
}

Expand Down
2 changes: 1 addition & 1 deletion siteupdate/cplusplus/classes/Waypoint/Waypoint.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,7 +35,7 @@ class Waypoint
std::string simple_waypoint_name();
bool is_or_colocated_with_active_or_preview();
std::string root_at_label();
void nmplogs(std::list<std::string> &, std::ofstream &, std::list<std::string> &);
void nmplogs(std::unordered_set<std::string> &, std::ofstream &, std::list<std::string> &);
inline Waypoint* hashpoint();
bool label_references_route(Route *, DatacheckEntryList *);

Expand Down
15 changes: 8 additions & 7 deletions siteupdate/cplusplus/siteupdate.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -121,9 +121,7 @@ int main(int argc, char *argv[])
}
closedir(dir);
}
else { cout << "Error opening directory " << args.userlistfilepath << ". (Not found?)" << endl;
return 0;
}
else el.add_error("Error opening user list file path \""+args.userlistfilepath+"\". (Not found?)");
}
else for (string &id : traveler_ids) id += ".list";

Expand DownExpand Up@@ -356,18 +354,18 @@ int main(int argc, char *argv[])
cout << et.et() << "Near-miss point log and tm-master.nmp file." << endl;

// read in fp file
list<string> nmpfplist;
unordered_set<string> nmpfps;
file.open(args.highwaydatapath+"/nmpfps.log");
while (getline(file, line))
{ while (line.back() == 0x0D || line.back() == ' ') line.erase(line.end()-1); // trim DOS newlines & whitespace
if (line.size()) nmpfplist.push_back(line);
if (line.size()) nmpfps.insert(line);
}
file.close();

list<string> nmploglines;
ofstream nmplog(args.logfilepath+"/nearmisspoints.log");
ofstream nmpnmp(args.logfilepath+"/tm-master.nmp");
for (Waypoint *w : all_waypoints.point_list()) w->nmplogs(nmpfplist, nmpnmp, nmploglines);
for (Waypoint *w : all_waypoints.point_list()) w->nmplogs(nmpfps, nmpnmp, nmploglines);
nmpnmp.close();

// sort and write actual lines to nearmisspoints.log
Expand All@@ -378,10 +376,13 @@ int main(int argc, char *argv[])

// report any unmatched nmpfps.log entries
ofstream nmpfpsunmatchedfile(args.logfilepath+"/nmpfpsunmatched.log");
list<string> nmpfplist(nmpfps.begin(), nmpfps.end());
nmpfplist.sort();
for (string &line : nmpfplist)
nmpfpsunmatchedfile << line << '\n';
nmpfpsunmatchedfile.close();
nmpfplist.clear();
nmpfps.clear();

// if requested, rewrite data with near-miss points merged in
if (args.nmpmergepath != "" && !args.errorcheck)
Expand DownExpand Up@@ -952,7 +953,7 @@ int main(int argc, char *argv[])
{ cout << "ABORTING due to " << el.error_list.size() << " errors:" << endl;
for (unsigned int i = 0; i < el.error_list.size(); i++)
cout << i+1 << ": " << el.error_list[i] << endl;
return 0;
return 1;
}

#ifdef threading_enabled
Expand Down
Loading