Skip to content

Different ConnectedRoutes that can be combined #492

Closed

Description

@yakra

These will not always be flagged by the datachecks proposed in #338.
#338 (comment)
https://forum.travelmapping.net/index.php?topic=3652.msg19191#msg19191

Examples as of 0df0a8c1d1f5469a7b534ed899108c9101690acb:
KY/IN: I-265FutLou
ENG/SCT: B6318 & B6452
DEU: A270 & B208
ITA RA5 & RA6
ESP: A15
TKM/UZB: A381

FPs are possible, e.g. AB201.

Probably best to address #338 first, see what hash tables that produces, and get a better idea of how to proceed.

Activity

  1. changed the title [-]Separate ConnectedRoutes that can be connected[/-] [+]Separate ConnectedRoutes that can be combined[/+] on Feb 16, 2022
  2. yakra commented on Mar 29, 2022

    @yakra
    ContributorAuthor

    I forget my reasoning behind thinking hash tables would be involved. Need to review #338.
    That said...

    • Is the end of a ConnectedRoute colocated?
    • If so, is a colocated point on a different ConnectedRoute in the same HighwaySystem?
    • If so, is it ConnectedRoute::first_point() or ConnectedRoute::last_point?
      (These functions don't exist yet, but are what they say on the tin. Piece of cake to implement.)
    • If so, does this ConnectedRoute have the same route + banner?
      (Will figure out what to do with groupName as I start to implement this & see what results I get.)
    • If so, flag a datacheck error.

    ...Unless I'm missing something?

  3. yakra commented on Oct 18, 2024

    @yakra
    ContributorAuthor

    b1726d8a8480b26b810fc3fd124983fe24c2711d

    grep COMBINE_CON_RTES logs/datacheck.log \
    | sed -r 's~^(.+)(;.+;;;COMBINE_CON_RTES;)(.+)(@.*)~[\1](https://travelmapping.net/hb/showroute.php?cr\&r=\1)\2[\3](https://travelmapping.net/hb/showroute.php?cr\&r=\3)\4~'

    All 16 results:
    deuby.b019wur;BY/BW;;;COMBINE_CON_RTES;deubw.b019@BY/BW
    deusn.b093bor;SN/TH;;;COMBINE_CON_RTES;deuth.b093@SN/TH
    frabfc.d005788;BFC/GES;;;COMBINE_CON_RTES;frages.d005788rup@BFC/GES
    frabfc.d005788beu;BFC/GES;;;COMBINE_CON_RTES;frages.d005788ram@BFC/GES
    frabfc.d005788beu;GES/BFC;;;COMBINE_CON_RTES;frages.d005788rup@GES/BFC
    frages.d003708ren;GES/HDF;;;COMBINE_CON_RTES;frahdf.d003708@GES/HDF
    frages.d005788;GES/BFC;;;COMBINE_CON_RTES;frabfc.d005788@GES/BFC
    frages.d005788ram;GES/BFC;;;COMBINE_CON_RTES;frabfc.d005788cha@GES/BFC
    frages.d098051ant;GES/HDF;;;COMBINE_CON_RTES;frahdf.d098051vie@GES/HDF
    frages.d098051ver;GES/HDF;;;COMBINE_CON_RTES;frahdf.d098051@GES/HDF
    frahdf.d003708;HDF/GES;;;COMBINE_CON_RTES;frages.d003708sev@HDF/GES
    frahdf.d098051;HDF/GES;;;COMBINE_CON_RTES;frages.d098051ant@HDF/GES
    frahdf.d098051vie;HDF/GES;;;COMBINE_CON_RTES;frages.d098051@HDF/GES
    indmh.ka010;MH/KA;;;COMBINE_CON_RTES;indka.ka010@MH/KA
    indmh.ka122;MH/KA;;;COMBINE_CON_RTES;indka.ka122@MH/KA
    indtg.ka010;KA/TG;;;COMBINE_CON_RTES;indka.ka010@KA/TG
    @michihdeu, do the ones in your regions all look like legitimate cases that could be combined? Any FPs?

    ToDo:

    See what causes crashes when ITA split systems are uncommented.

    • 0m38.489s 492-0.l0g
      • last debug text
        518879: p=itacal.ra004@A2Rac
        518880: &cr2=0
      • error
        8: Could not parse itaa2_con.csv line: [itaa2;RA4;;Raccordo Autostradale di Reggio Calabria;itacal.ra004;], expected 5 fields, found 6
      • cause
        ConnectedRoute construction failed, so itacal.ra004 was never assigned a con_route, staying NULL.
        Attempts to dereference (either right away to call cr2->connected_rtes_line() for debug text or later to call cr2->roots[0]->con_beg()).
      • fix
        Put an if () around ConnectedRoute* cr2 = p->route->con_route; only proceed if cr2 is valid.
    • 1m44.646s 492-1.l0g
      • last debug text
        1667918: ConnectedRoute (0): itaa2;RA4;;Raccordo Autostradale di Reggio Calabria;
      • error
        8: Could not parse itaa2_con.csv line: [itaa2;RA4;;Raccordo Autostradale di Reggio Calabria;itacal.ra004;], expected 5 fields, found 6
      • cause
        Invalid ConnectedRoute object was created, rather than destroyed once it became apparent construction could not succeed.
      • fix
        ConnectedRoute ctor needs to do like the Route ctor does, and throw when it can't parse a line.
        HighwaySystem ctor needs to catch, same way.
    • 1m45.639s 492-2.l0g
      • last debug text
        1699408: ConnectedRoute (0): itass2;SS106;Ter;;
      • error
        11: No valid roots in itass2_con.csv line: itass2;SS106;Ter;;itacal.ss106ter
      • cause
        Same as above.
      • fix
        Also throw when no valid roots are found.
    • 1m45.707s 492-3.l0g
      • last debug text
        1703816: ConnectedRoute (3): itass2;SS259;;;itatos.ss258,itaemi.ss258mol,itatos.ss258raf
        1703817: w=0
      • error
        19: [Errno 2] No such file or directory: '/home/yakra/tm/HighwayData/data/ITA-TOS/itass2/itatos.ss258.wpt'
        20: [Errno 2] No such file or directory: '/home/yakra/tm/HighwayData/data/ITA-TOS/itass2/itatos.ss258raf.wpt'
      • cause
        No waypoints means Route::points.data was initialized to 0 and never allocated, so con_beg() returns NULL.
      • fix
        Only proceed to checking w->colocated when w is nonzero.
    • 2m2.857s 492-4.l0g
      • last debug text
        1703816: ConnectedRoute (3): itass2;SS259;;;itatos.ss258,itaemi.ss258mol,itatos.ss258raf
        1703817: w=0
        1703818: w=0xffffffffffffff78
      • error
        Same as above.
      • cause
        0xffffffffffffff78 = -136, one sizeof(Waypoint) below 0.
        Route::points.back() returns NULL - 1 (Route::points.size - 1).
        This in turn gets returned by Route::con_beg() and/or Route::con_beg().
      • fix
        Use a ternary to set w to 0 if points.size == 0. The previous fix will then kick in.
    • 2m11.642s
      GREAT SUCCESS
  4. changed the title [-]Separate ConnectedRoutes that can be combined[/-] [+]Different ConnectedRoutes that can be combined[/+] on Oct 18, 2024
  5. added a commit that references this issue on Oct 18, 2024
  6. michihdeu commented on Oct 18, 2024

    @michihdeu
    Contributor

    Fixed. No FP. Thanks @yakra for that great error check 😄

  7. michihdeu commented on Oct 18, 2024

    @michihdeu
    Contributor

    Will this error check be live soon? I'd like to check that I didn't miss one....

  8. yakra commented on Oct 18, 2024

    @yakra
    ContributorAuthor

    If all goes well I can have it go live later today.
    And as soon as I typed that out, I found that all has gone well!
    Just finished fixing one last bug caused by missing .wpt files.

  9. yakra commented on Oct 18, 2024

    @yakra
    ContributorAuthor

    Leaving this 37-line monstrosity here in case I ever want to restore the debug text:

      std::cout << "ConnectedRoute (" << cr.roots.size() << "): " << cr.connected_rtes_line() << std::endl;
      for (Waypoint* w : {	cr.roots[ 0 ] -> points.size ? cr.roots[ 0 ] -> con_beg() : 0,
    			cr.roots.back()->points.size ? cr.roots.back()->con_end() : 0})
      { std::cout << "w=" << w << std::endl;
        if (w && w->colocated) // empty routes (eg file not found) had w set to nullptr above
        { std::cout << "  " << w->root_at_label() << " is colocated" << std::endl;
          for (Waypoint* p : *w->colocated)
          { std::cout << "    p=" << p->root_at_label() << std::endl;
    	if (ConnectedRoute* cr2 = p->route->con_route) // skip if Route has no ConnectedRoute
    	{	std::cout << "    &cr2=" << cr2 << std::endl;
    		std::cout << "    cr2=" << cr2->connected_rtes_line() << std::endl;
    	        if (w->route->region != p->route->region)
    	        { std::cout << "      " << w->route->region->code << " != " << p->route->region->code << std::endl;
    	          if (w < p)
    	          { std::cout << "        " << w << " < " << p << std::endl;
    	            if (this == p->route->system)
    	            { std::cout << "          match " << systemname << std::endl;
    	              if (&cr != cr2)
    	              { std::cout << "            " << &cr << " != " << cr2 << std::endl;
    	                if (p == cr2->roots[0]->con_beg() || p == cr2->roots.back()->con_end())
    	                { std::cout << "              p is terminus" << std::endl;
    	                  if (w->route->route == p->route->route)
    	                  { std::cout << "                " << w->route->route << " == " << p->route->route << std::endl;
    	                    if (w->route->banner == p->route->banner)
    	                    { std::cout << "                  " << w->route->banner << " == " << p->route->banner << std::endl;
    		              Datacheck::add(w->route,  w->label, "", "", "COMBINE_CON_RTES", p->root_at_label());
    		            }
    		          }
    		        }
    		      }
    		    }
    		  }
    		}
    	}
          }
        }
      }

    Now to make it more compact if not readable, and trim it back to what was in the draft commit + the actual bugfixes.

    To diff logs:

    diff \
      <(sed -r -e 's~0x[0-9a-f]{6,12}~ADDX~g' -e 's~^\[[0-9]+\.[0-9]\]~[TIME]~' 492-3.l0g) \
      <(sed -r -e 's~0x[0-9a-f]{6,12}~ADDX~g' -e 's~^\[[0-9]+\.[0-9]\]~[TIME]~' 492-4.l0g) \
    | less
  10. yakra commented on Oct 18, 2024

    @yakra
    ContributorAuthor

    @michihdeu, what's your opinion on whether this should be red or blue on the datacheck page?

  11. michihdeu commented on Oct 18, 2024

    @michihdeu
    Contributor

    It doesn't falsify user stats if they use 4-field entries. Blue. But if 6-field.... hm, red?

  12. yakra commented on Oct 18, 2024

    @yakra
    ContributorAuthor

    For 6-field entries, it wouldn't falsify anything; it simply wouldn't allow the entry to be made.

  13. added a commit that references this issue on Oct 18, 2024
  14. yakra commented on Oct 18, 2024

    @yakra
    ContributorAuthor

    I'm going with red, simply because that's what no-build in that part of the code gives us.
    If later on we decide blue is better, we can do that.

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