You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Each Route already has a duplicate_labels set used for writing warnings to userlogs.
Making these into a hash table is a simple modification in both C++ & Python.
If a label is included in a file more than twice, we can look up the existing datacheck and modify its info.
We could keep a list, for example, of...
The usual link in the Route column could remain as the default. Whatever the default may be; not ruling out wptedit in the future.
Right now, a bit confusingly, if there are n>2 of the same label in a file, there will be n-1 DUPLICATE_LABEL errors that all look identical. No Info or anything to tell how they're different or where any of these labels are.
This "look up and edit" approach means having just one error that encompasses all occurrences of a label in a route.
all line numbers in the .wpt file
This.
The Info column (currently unused) could have links (similar to what's done with ABBREV_AS_CON_BANNER & some other errors) to each .wpt line's blame on GitHub. The idea here is, if a duplicate label is in use, the contributor could use the blame feature to find which label was in the file first, and keep that one in order to avoid breaking .list files.
Approach:
Don't clear the labels_in_use set upon writing labelsinuse.log.
Upon initial insertion, put the line numbers into the info value. 1,2.
riW(Waypoint): Or even Waypoint::hash_labels (which may bring pointer-chasing back? Less iterating though.)
Either one facilitates refactoring into read_wpt.
riI(Inline/Include): a variant inlined directly into Route::read_wpt, where we have both the Route object and Waypoint pointer right at our fingertips, avoids:
riR's iteration and indexing into point_list
riW's chasing of the route pointer
Swap: r->duplicate_labels.insert before Datacheck::add
Now go crazy with the new stuff!
If insertion fails, look up the existing error (C++, we have a handy-dandy iterator; Python, just look it up) and append the new line number. 1,2,3.
Take another pass thru the data after .list processing. Iterating thru the datacheck errors seems the most efficient way to go, so probably add this into existing Datacheck::mark_fps. If the label is unused, replace the Info with a simple "unused" tag that lets the contributor easily know the label can be safely deleted from anywhere in the file.
There's a chance, however unlikely, that a ton of labels could result in an info string too long to fit in the DB. So do one final check, and if this is the case, replace with a shorter string that can be captured by datacheck.php and replaced with a link to the blame for the entire .wpt file.
This forces our hand into refactoring label hashing into Route::read_wptwhere we can have the line number at our fingertips.
Use the l index into the lines vector. SFSG, right?
Well... no. Consecutive newlines are all skipped together. A blank line is not skipped after being added to lines, but rather, isn't added to lines at all.
This begs for a read_wpt solution that adds each individual line to lines and then skips all blank lines, even lines that are blank before stripping whitespace.
The current (somewhat awkward) routine is a legacy of having used strtokonce upon a time.
Activity
michihdeu commentedon Feb 7, 2021
I prefer directly opening the wpt editor. DL are highlighted on the wpt table. Don't spend time on intermediate solutions. Just my 2ct.
TravelMapping/Web#372
yakra commentedon Jan 12, 2023
Background: https://forum.travelmapping.net/index.php?topic=5045.msg30255#msg30255
The usual link in the
Routecolumn could remain as the default. Whatever the default may be; not ruling out wptedit in the future.Right now, a bit confusingly, if there are n>2 of the same label in a file, there will be n-1 DUPLICATE_LABEL errors that all look identical. No
Infoor anything to tell how they're different or where any of these labels are.This "look up and edit" approach means having just one error that encompasses all occurrences of a label in a route.
This.
The
Infocolumn (currently unused) could have links (similar to what's done with ABBREV_AS_CON_BANNER & some other errors) to each .wpt line's blame on GitHub. The idea here is, if a duplicate label is in use, the contributor could use the blame feature to find which label was in the file first, and keep that one in order to avoid breaking .list files.Approach:
labels_in_useset upon writing labelsinuse.log.1,2.git checkout afb28b1 -- classes/HighwaySystem/route_integrity.cpp||Route::hash_labels& reduce pointer-chasing.Waypoint::hash_labels(which may bring pointer-chasing back? Less iterating though.)Either one facilitates refactoring into
read_wpt.Route::read_wpt, where we have both theRouteobject andWaypointpointer right at our fingertips, avoids:point_listroutepointerr->duplicate_labels.insertbeforeDatacheck::add1,2,3.Datacheck::mark_fps. If the label is unused, replace theInfowith a simple "unused" tag that lets the contributor easily know the label can be safely deleted from anywhere in the file.yakra commentedon Jan 19, 2023
Robustness.
If this is worth doing, it's worth doing right the first time.
A waypoint's position in
Route::point_listmay not correspond to its line number in the .wpt file, due to:This forces our hand into refactoring label hashing into
Route::read_wptwhere we can have the line number at our fingertips.lindex into thelinesvector. SFSG, right?lines, but rather, isn't added tolinesat all.This begs for a
read_wptsolution that adds each individual line tolinesand then skips all blank lines, even lines that are blank before stripping whitespace.The current (somewhat awkward) routine is a legacy of having used
strtokonce upon a time.