TravelMapping / DataProcessing

Data Processing Scripts and Programs for Travel Mapping Project
4 stars 6 forks source link

Straightforward_intersection: `(` check #608

Open yakra opened 10 months ago

yakra commented 10 months ago

First, let's simplify array indexing in Waypoint::label_references_route to make things more compact & readable:

bool Waypoint::label_references_route(Route *r)
{   std::string no_abbrev = r->name_no_abbrev();
    if ( strncmp(label.data(), no_abbrev.data(), no_abbrev.size()) )
        return 0;
    const char* c = label.data() + no_abbrev.size();
    if (*c == 0 || *c == '_')
        return 1;
    if ( strncmp(c, r->abbrev.data(), r->abbrev.size()) )
    {   /*if (*c == '/')
            Datacheck::add(route, label, "", "", "UNEXPECTED_DESIGNATION", c+1);//*/
        return 0;
    }
    c += r->abbrev.size();
    if (*c == 0 || *c == '_')
        return 1;
    /*if (*c == '/')
        Datacheck::add(route, label, "", "", "UNEXPECTED_DESIGNATION", c+1);//*/
    return 0;
}

(This change may in fact be committed very soon.)

Then, change both if (*c == 0 || *c == '_') to if (*c == 0 || *c == '_' || *c == '('). With HighwayData @ c52ad21011e926096e8f91b675de4265aa9d679b, what are our results?

24788c24788
< Keep_failsafe: A6@N702_W&N702@A6(3)
---
> Straightforward_intersection: A6@N702_W&N702@A6(3) -> A6(3)/N702_W
106391c106391
< Exit/Intersection: D200@O6(15)&O6@D200 -> D200/O6
---
> Straightforward_intersection: D200@O6(15)&O6@D200 -> D200/O6(15)
161341c161341
< Exit/Intersection: A-35@QC133&QC133@A-35(15) -> QC133/A-35
---
> Straightforward_intersection: A-35@QC133&QC133@A-35(15) -> A-35(15)/QC133
172093c172093
< Exit/Intersection: A33@N344&N344@A33(31) -> N344/A33
---
> Straightforward_intersection: A33@N344&N344@A33(31) -> A33(31)/N344
200936c200936
< Keep_failsafe: I-26@US17_S&US17@I-26(End)
---
> Straightforward_intersection: I-26@US17_S&US17@I-26(End) -> I-26(End)/US17_S
204774c204774
< Keep_failsafe: FLTpk@US1_Cut&US1@FLTpk(12A)
---
> Straightforward_intersection: FLTpk@US1_Cut&US1@FLTpk(12A) -> FLTpk(12A)/US1_Cut
229821c229821
< Keep_failsafe: M3@MR36_W&MR36@M3(5)
---
> Straightforward_intersection: M3@MR36_W&MR36@M3(5) -> M3(5)/MR36_W
229875c229875
< Keep_failsafe: M3@MR36_E&MR36@M3(14)
---
> Straightforward_intersection: M3@MR36_E&MR36@M3(14) -> M3(14)/MR36_E
230231c230231
< Exit/Intersection: A96@M1(20)&M1@A96 -> A96/M1
---
> Straightforward_intersection: A96@M1(20)&M1@A96 -> A96/M1(20)
288524c288524
< Exit/Intersection: D550@O33(3)&O33Hor@D550 -> D550/O33Hor
---
> Straightforward_intersection: D550@O33(3)&O33Hor@D550 -> D550/O33(3)
322816c322816
< Keep_failsafe: US460@US460BusChr_A&US460BusChr@US460(5)
---
> Straightforward_intersection: US460@US460BusChr_A&US460BusChr@US460(5) -> US460(5)/US460BusChr_A

These may beg further investigation, label changes, or comments. Holding off on this for the most part as I need to prioritize. :)

yakra commented 10 months ago

6 Keep_failsafe cases

24788c24788
< Keep_failsafe: A6@N702_W&N702@A6(3)
---
> Straightforward_intersection: A6@N702_W&N702@A6(3) -> A6(3)/N702_W
200936c200936
< Keep_failsafe: I-26@US17_S&US17@I-26(End)
---
> Straightforward_intersection: I-26@US17_S&US17@I-26(End) -> I-26(End)/US17_S
204774c204774
< Keep_failsafe: FLTpk@US1_Cut&US1@FLTpk(12A)
---
> Straightforward_intersection: FLTpk@US1_Cut&US1@FLTpk(12A) -> FLTpk(12A)/US1_Cut
229821c229821
< Keep_failsafe: M3@MR36_W&MR36@M3(5)
---
> Straightforward_intersection: M3@MR36_W&MR36@M3(5) -> M3(5)/MR36_W
229875c229875
< Keep_failsafe: M3@MR36_E&MR36@M3(14)
---
> Straightforward_intersection: M3@MR36_E&MR36@M3(14) -> M3(14)/MR36_E
322816c322816
< Keep_failsafe: US460@US460BusChr_A&US460BusChr@US460(5)
---
> Straightforward_intersection: US460@US460BusChr_A&US460BusChr@US460(5) -> US460(5)/US460BusChr_A

No comments here just yet.

yakra commented 10 months ago

5 Exit/Intersection cases

106391c106391
< Exit/Intersection: D200@O6(15)&O6@D200 -> D200/O6
---
> Straightforward_intersection: D200@O6(15)&O6@D200 -> D200/O6(15)
161341c161341
< Exit/Intersection: A-35@QC133&QC133@A-35(15) -> QC133/A-35
---
> Straightforward_intersection: A-35@QC133&QC133@A-35(15) -> A-35(15)/QC133
172093c172093
< Exit/Intersection: A33@N344&N344@A33(31) -> N344/A33
---
> Straightforward_intersection: A33@N344&N344@A33(31) -> A33(31)/N344
230231c230231
< Exit/Intersection: A96@M1(20)&M1@A96 -> A96/M1
---
> Straightforward_intersection: A96@M1(20)&M1@A96 -> A96/M1(20)
288524c288524
< Exit/Intersection: D550@O33(3)&O33Hor@D550 -> D550/O33Hor
---
> Straightforward_intersection: D550@O33(3)&O33Hor@D550 -> D550/O33(3)

These all look like improvements -- in brevity & readability at the very least -- except for that last one, where we lose the IMO important Hor distinction.