Skip to content

"editing" DUPLICATE_LABEL entries #412

Open

Description

@yakra

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...

  • bounding box for the HB
  • all line numbers in the .wpt file
  • first & last line number in the .wpt file
  • whatever might be most useful

Activity

  1. michihdeu commented on Feb 7, 2021

    @michihdeu
    Contributor

    bounding box for the HB

    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

  2. yakra commented on Jan 12, 2023

    @yakra
    ContributorAuthor

    Background: https://forum.travelmapping.net/index.php?topic=5045.msg30255#msg30255

    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.
      • git checkout afb28b1 -- classes/HighwaySystem/route_integrity.cpp
      • riM (Move): Nix the std::move bug
      • riC (Compound Conditional): Combine first two datachecks via ||
      • riR (Route): Refactor -> Route::hash_labels & reduce pointer-chasing.
      • 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.
  3. yakra commented on Jan 19, 2023

    @yakra
    ContributorAuthor

    Robustness.

    If this is worth doing, it's worth doing right the first time.

    A waypoint's position in Route::point_list may not correspond to its line number in the .wpt file, due to:

    1. Datacheck errors causing the line to not be processed
      • SINGLE_FIELD_LINE
      • LABEL_TOO_LONG
      • MALFORMED_URL
      • MALFORMED_LAT
      • MALFORMED_LON
    2. Blank lines in the .wpt file. It can happen.

    This forces our hand into refactoring label hashing into Route::read_wptwhere we can have the line number at our fingertips.

    1. Use the l index into the lines vector. SFSG, right?
    2. 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 strtok once upon a time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions