Skip to content

3+ intersection suffixes & redundancy #418

Open

Description

@yakra

Waypoint simplification for 3+_intersection cases has trouble at beltway ends.

Find these cases by adding a continue to a refactored 3+_intersection routine:

if len(self.ap_coloc) > 2:
    suffixes = [""] * len(self.ap_coloc)
    for check in self.ap_coloc:
        match = False
        for index, other in enumerate(self.ap_coloc):
            if other == check:
                continue
            other_no_abbrev = other.route.name_no_abbrev()
            if check.label.startswith(other_no_abbrev):
                # should check here for false matches, like
                # NY50/67 would match startswith NY5
                match = True
                if len(suffixes[index]):	### REMOVE THESE TWO ###
                    continue			### LINES FOR DIFFS ###
                try:
                    suffix = check.label[check.label.index('_'):]
                    # we confirmed above that other_no_abbrev matches, so skip past it
                    # we need only match the suffix with or without the abbrev
                    if check.label[len(other_no_abbrev):] == suffix \
                    or other.route.abbrev + suffix == check.label[len(other_no_abbrev):]:
                        suffixes[index] = suffix
                except ValueError:
                    pass
        if not match:
            break
    if match:
        label = self.ap_coloc[0].route.list_entry_name() + suffixes[0]
        for index in range(1,len(self.ap_coloc)):
            label += "/" + self.ap_coloc[index].route.list_entry_name() + suffixes[index]
        log.append("3+_intersection: " + name + " -> " + label)
        return label

There's something more at play in the diffs than just beltway ends...

  • 740 points changed in waypointsimplification.log
  • 315 DUPLICATE_COORDS cases (36 datacheck.log entries + 279 matched FPs)
  • What are the other 425 changes?

Activity

  1. yakra commented on Feb 28, 2021

    @yakra
    ContributorAuthor

    only related in that they're 3+_intersection:

    3+_intersection: GA11@GA211_N&GA53@GA211_Win&GA211@GA11/53 -> GA11/GA53/GA211_Win
    3+_intersection: GA11@GA53_W&GA53@GA11/211&GA211@GA53_Win -> GA11/GA53_Win/GA211
    
  2. yakra commented on Feb 28, 2021

    @yakra
    ContributorAuthor
    • What are the other 425 changes?
    268710c268710
    < 3+_intersection: LA29@LA1174_N&LA95@LA1174_S&LA1174@LA29/95_B -> LA29/LA95/LA1174_S
    ---
    > 3+_intersection: LA29@LA1174_N&LA95@LA1174_S&LA1174@LA29/95_B -> LA29/LA95/LA1174_N

    Due to a wrong-way multiplex, this point is LA1174_N on LA29 and LA1174_S on LA95.

    Don't know if this accounts for all 425 changes, but I'm not about to examine them all in detail. I'll see what changes once I start messing with the code.

  3. added
    CWN
    on Mar 2, 2021
  4. yakra commented on Mar 2, 2021

    @yakra
    ContributorAuthor

    See also #260

  5. yakra commented on Jun 17, 2021

    @yakra
    ContributorAuthor

    diffs & stats as in the OP
    HighwayData @ 8ff82de099da29963190be37677060b775d8c6cc

    grep -v -F -f logs/unmatchedfps.log ~/tm/HighwayData/datacheckfps.csv > matchedfps.txt
    echo `grep -c DUPLICATE_COORDS logs/datacheck.log` datacheck.log entries
    echo `grep -c DUPLICATE_COORDS matchedfps.txt` matched FPs
    echo `grep DUPLICATE_COORDS logs/datacheck.log matchedfps.txt | wc -l` total cases
    grep DUPLICATE_COORDS logs/datacheck.log matchedfps.txt | cut -f6 -d';' | sort | uniq | tr -d '()' | tr , ' ' | sed 's~.*~ &$~' > coords.txt
    echo `cat coords.txt | wc -l` unique locations
    oldl=`grep -f coords.txt graphs/tm-master-simple.tmg | sed 's~ .*~~' | sort | uniq`
    newl=`grep -f coords.txt _3pC/graphs/tm-master-simple.tmg | sed 's~ .*~~' | sort | uniq`
    diff logs/waypointsimplification.log _3pC/logs/waypointsimplification.log | grep '^< ' | sed 's~^< ~~' > ldiff
    diff logs/waypointsimplification.log _3pC/logs/waypointsimplification.log | grep '^> ' | sed 's~^> ~~' > rdiff
    grep -F -f <(echo "$oldl") ldiff > l80
    grep -F -f <(echo "$newl") rdiff > r80
    grep -v -F -f l80 ldiff > ldiff2
    grep -v -F -f r80 rdiff > rdiff2

    745 points changed in waypointsimplification.log.
    312 unique-location active/preview DUPLICATE_COORDS cases.
    Only 80 of these vertex labels appear in DIFFs


    In other news:

    { // should check here for false matches, like
    // NY50/67 would match startswith NY5

    # should check here for false matches, like
    # NY50/67 would match startswith NY5

    Implementing this results in some diffs I don't understand yet...
    Edit: Must have been working with a revision of the code other than the one I thought I was working with. Things are behaving closer to expectation now.
    Here are the first 4 diffs from implementation:

    197457c197457
    < 3+_intersection: E017@M7&E22@M7Ufa&M7@M7Perm&M7Per@M7 -> E017/E22/M7/M7Per
    ---
    > _Keep_failsafe_: E017@M7&E22@M7Ufa&M7@M7Perm&M7Per@M7
    • False abbrev. There is no M7Ufa. The route of M7 is matching the label of M7 + some other stuff,
    203177c203177
    < 3+_intersection: DJ112@DN11&DN11@DJ112A&E574@DJ112A -> DJ112/DN11/E574
    ---
    > _Keep_failsafe_: DJ112@DN11&DN11@DJ112A&E574@DJ112A
    • Label DJ112A a false match for route DJ112. Fix the label and we're OK again.
    204777c204777
    < 3+_intersection: DK45@DW459&DK46@DW459&DK94@DK459_E&DW459@DK45/46 -> DK45/DK46/DK94/DW459
    ---
    > _Keep_failsafe_: DK45@DW459&DK46@DW459&DK94@DK459_E&DW459@DK45/46
    • Label DK459_E a false match for route DK45. Fix label -> DW459_E & we're OK again.
    234759c234759
    < 3+_intersection: E87@I99_N&I9@II99_N&II99@I9_N -> E87/I9_N/II99_N
    ---
    > _Keep_failsafe_: E87@I99_N&I9@II99_N&II99@I9_N
    
    * Label I99_N a false match for route I9. Fix label -> II99_N & we're OK again.
  6. yakra commented on Nov 27, 2021

    @yakra
    ContributorAuthor

    Useful examples:
    egrep '.+@(.+)_S&.+@\1_N.* -> .*\1_[NEWS]|.+@(.+)_N&.+@\2_S.* -> .*\2_[NEWS]|.+@(.+)_W&.+@\3_E.* -> .*\3_[NEWS]|.+@(.+)_E&.+@\4_W.* -> .*\4_[NEWS]' waypointsimplification.log

  7. yakra commented on Mar 20, 2024

    @yakra
    ContributorAuthor

    Back to the OP...

    class Suffix
    {	static constexpr auto sarray = "\0..._W\0._S\0._SW\0_E\0.\0..._SE\0_S\0._N\0._NW\0\0..._W\0._NE\0_N\0._E\0.";
    
    	const char* str;
    	unsigned char bits;
    
    	public:
    	Suffix(): str(0), bits(0) {}
    
    	void set(const char* const s)
    	{	if (s[2]) str = s;
    		else switch (s[1])
    		{ case 'W': bits |= 4;  break;
    		  case 'S': bits |= 8;  break;
    		  case 'E': bits |= 16; break;
    		  case 'N': bits |= 32; break;
    		  default : str = s;
    		}
    	}
    
    	const char* const operator () () const
    	{	return str ? str : sarray+bits;
    	}
    };
    • Allow _N + _S and _E + _W to cancel out.
      Beware: On its own, this will cause collsions:

      3+_intersection: LA29@LA1174_N&LA95@LA1174_S&LA1174@LA29/95_E -> LA29/LA95/LA1174_S
      3+_intersection: LA29@LA95/1174&LA95@LA29/1174&LA1174@LA29/95_W -> LA29/LA95/LA1174

      For the 1st one, LA1174_N & LA1174_S cancel out, yielding LA29/LA95/LA1174.
      This makes the 2nd one a duplicate, causing it to revert to failsafe.
      Therefore 3+_intersection: induction variables; suffix efficiency yakra/DataProcessing#261 needs a rethink.

      • We do want to scan for a _ after a /.
        We don't want to compare the whole label.
      • Extra credit: What about scanning for route numbers that only occur after a /, e.g. LA95?
        • Is it necessary to avoid duplicates & reversions?
    • Prefer labels less likely to disagree, e.g. _A, _B, _C, _Foo, _Bar, etc.

      • Does it cause any funny business with _A, _B, _C?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CWNdata qualitygraph generation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions