From dc37d8ab88c17d32ed95408d1c6ca1615b144042 Mon Sep 17 00:00:00 2001 From: eric bryant Date: Tue, 17 Nov 2020 10:13:32 -0500 Subject: [PATCH] expand US_LETTER datacheck to account for city abbrevs --- .../cplusplus/classes/Waypoint/Waypoint.cpp | 6 +++++ siteupdate/python-teresco/siteupdate.py | 23 +++++++++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/siteupdate/cplusplus/classes/Waypoint/Waypoint.cpp b/siteupdate/cplusplus/classes/Waypoint/Waypoint.cpp index d1c4ca9e..d1c49127 100644 --- a/siteupdate/cplusplus/classes/Waypoint/Waypoint.cpp +++ b/siteupdate/cplusplus/classes/Waypoint/Waypoint.cpp @@ -529,6 +529,12 @@ inline void Waypoint::us_letter(DatacheckEntryList *datacheckerrors) if (*c < 'A' || *c++ > 'B') return; if (*c == 0 || *c == '/' || *c == '_' || *c == '(') datacheckerrors->add(route, label, "", "", "US_LETTER", ""); + // is it followed by a city abbrev? + else if (*c >= 'A' && *c++ <= 'Z' + && *c >= 'a' && *c++ <= 'z' + && *c >= 'a' && *c++ <= 'z' + && *c == 0 || *c == '/' || *c == '_' || *c == '(') + datacheckerrors->add(route, label, "", "", "US_LETTER", ""); } inline void Waypoint::visible_distance(DatacheckEntryList *datacheckerrors, char *fstr, double &vis_dist, Waypoint *&last_visible) diff --git a/siteupdate/python-teresco/siteupdate.py b/siteupdate/python-teresco/siteupdate.py index fc2a0bc1..ce97b38b 100755 --- a/siteupdate/python-teresco/siteupdate.py +++ b/siteupdate/python-teresco/siteupdate.py @@ -3953,22 +3953,37 @@ def run(self): # USA-only datachecks if usa_flag and len(w.label) >= 2: + # look for I-xx with Bus instead of BL or BS if re.fullmatch('\*?I\-[0-9]+[EeWwCcNnSs]?[Bb][Uu][Ss].*', w.label): datacheckerrors.append(DatacheckEntry(r,[w.label],'BUS_WITH_I')) + # look for Ixx without hyphen c = 1 if w.label[0] == '*' else 0 if w.label[c:c+2] == "To": c += 2; if len(w.label) >= c+2 and w.label[c] == 'I' and w.label[c+1].isdigit(): datacheckerrors.append(DatacheckEntry(r,[w.label],'INTERSTATE_NO_HYPHEN')) + # look for USxxxA but not USxxxAlt, B/Bus/Byp # Eric's paraphrase of Jim's original criteria # if re.fullmatch('\*?US[0-9]+[AB].*', w.label) and not re.fullmatch('\*?US[0-9]+Alt.*|\*?US[0-9]+Bus.*|\*?US[0-9]+Byp.*', w.label): - # Instead, let's cast a narrower net - if re.fullmatch('\*?US[0-9]+[AB]|\*?US[0-9]+[AB][/_(].*', w.label): - datacheckerrors.append(DatacheckEntry(r,[w.label],'US_LETTER')) - + # Instead, let's cast a narrower net (optimized for speed, just because): + try: + c = 3 if w.label[0] == '*' else 2 + if w.label[c-2] == 'U' and w.label[c-1] == 'S' and w.label[c].isdigit(): + while w.label[c].isdigit(): + c += 1 + if w.label[c] in 'AB': + c += 1 + if c == len(w.label) or w.label[c] in '/_(': + datacheckerrors.append(DatacheckEntry(r,[w.label],'US_LETTER')) + # is it followed by a city abbrev? + elif w.label[c].isupper() and w.label[c+1].islower() and w.label[c+2].islower() \ + and (c+3 == len(w.label) or w.label[c+3] in '/_('): + datacheckerrors.append(DatacheckEntry(r,[w.label],'US_LETTER')) + except IndexError: + pass prev_w = w # angle check is easier with a traditional for loop and array indices