Washington State Route name and ref tag changes

I believe @Minh_Nguyen is talking about cases where multiple refs are concatenated together on a way since they all apply. For example, this happens on sections of road that are dual-designated (ref=WA 509;WA 516), and on link roads with multiple destinations including SRs (destination:ref=WA 169 South;WA 900 West).

2 Likes

That did indeed return more results. My original query got 14560 ways, the updated regex got 14678.

Looking at the diff the new regex caught some other incongruities like refs with a dash “WA-21” where most of the tags just have a space. You were also correct about the multi-destination/multi-ref situation.

By the way, if you intend to conduct a poll, then you’d want to hold off on making any changes locally until the poll concludes. Otherwise, your changeset will quickly get out of date and conflict as others edit these roads.

Fair point. Ielenia had mentioned they were going to mention this thread in slack, haven’t seen any objections comes up. There seems to be consensus around this issue. Is it worth running the poll?

Ah, you mean this thread. Personally, I’d still run a quick straw poll publicly here out of fairness to any local mappers who aren’t on Slack. It’ll be a little inconvenient for the Slackers to weigh in yet again, but at least you’ll have something to point to if anyone ever tries to change it back unilaterally.

1 Like

Sounds good, how long should I leave the poll open for?

The usual time for straw polls around here seems to be two weeks. Aim for turnout that reflects the active mapper community in the state.

Sounds good, that’ll give me plenty of time to validate the process I intend to use.

Rationale for change detailed in 1st post. Nobody actually uses ‘WA’ prefixes in real life. Prefixes should be updated to match what is actually used.

Change Washington State Highway Prefixes from WA to SR?
  • Yes
  • No
0 voters
1 Like

Oh, yeah, make sure to tell Mapbox to update their rules so that proper highway shields appear instead of the generic rounded rectangle (Utah, I’m looking at you!).

Mapbox was notified of Utah changing to SR via OSMUS Slack Slack

Seeing no objections I’m going to go ahead with this.

I do need some help figuring out the regex for the overpass query. Right now I’m using this:

[out:json][timeout:90];
area["ISO3166-2"="US-WA"]["admin_level"="4"]->.searchArea;
(
  way["highway"]["ref"~"(^|;)WA"](area.searchArea);
);
out geom;

Which gets the actual routes but I also need to replace all the destination:ref tags.

way["highway"="motorway_link"]["destination:ref"~"WA"](area.searchArea);

That’s my first approach at an additional selection, seems to be getting the right stuff. If anyone has any other ideas for things to include let me know.

1 Like

Some ideas for making the queries more comprehensive:

  • Occasionally, a single roadway is part of one route going in one direction but another route going in the opposite direction. The way would be tagged ref:forward=* ref:backward=* (preferred and recognized by routers) or ref:left=* and ref:right=* (preferred by renderer and geocoder developers but not yet implemented).
  • destination:ref=* and destination:ref:*=* often appears on highway=*_link ways besides highway=motorway_link, and sometimes on non-link ways as well.
  • If I recall correctly, some of the Washington State Ferries carry state routes, so they might be tagged ref=*. If not, I wouldn’t add it, since it might get confused with a ferry line number.
1 Like

I decided to try brute forcing it by having a loose tag regex and selecting by the route values.

This returns a few extra things

[out:json][timeout:90];
area["ISO3166-2"="US-WA"]["admin_level"="4"]->.searchArea;
(
  way[~"ref"~"WA\s{0,1}"](area.searchArea);
);
out geom;

This is what I’d like to run, but it returns 0 results for some reason despite working fine on sample data.

[out:json][timeout:90];
area["ISO3166-2"="US-WA"]["admin_level"="4"]->.searchArea;
(
  way[~"ref"~"WA\s{0,1}\d{1,3}"](area.searchArea);
);
out geom;

Overpass doesn’t seem to like the digit term in the regex.

You’d need to escape the backslashes in the regular expression, since they occur inside a string. Besides that, metacharacters aren’t supported in OverpassQL as far as I know. Try WA ?[0-9]{1,3} instead.

(Taking notes for later if I receive the green light to do the same in my home state)

1 Like

It works. I was hoping to capture nodes where there wasn’t a space between the sections but that can just be a separate query.

The ? is for missing spaces.

So my final process is a little silly but seems to generate the right result. I got XML from overpass with this query:

[out:json][timeout:90];
area["ISO3166-2"="US-WA"]["admin_level"="4"]->.searchArea;
(
  way[~"ref"~"(^|;)WA"](area.searchArea);
);
out geom;

There were a few unexpected inclusions like the comfort inn hotels but the next step didn’t get any of those. Roads seem to all have the space in there. I confirmed that with this regex in Notepad++ WA\s{0}\d{1,3}(?!\d)

I then grabbed a list of all state routes in Washington from here, built a replacement dictionary, and wrote a quick Python script to do the replacement.

import xml.etree.ElementTree as ET

swapdict = {
    'WA 3': 'SR 3',
    'WA 4': 'SR 4',
    'WA 6': 'SR 6',
    'WA 7': 'SR 7',
    'WA 8': 'SR 8',
    'WA 9': 'SR 9',
    'WA 10': 'SR 10',
    'WA 11': 'SR 11',
    'WA 12': 'SR 12',
    'WA 14': 'SR 14',
    'WA 16': 'SR 16',
    'WA 17': 'SR 17',
    'WA 18': 'SR 18',
    'WA 19': 'SR 19',
    'WA 20': 'SR 20',
    'WA 21': 'SR 21',
    'WA 22': 'SR 22',
    'WA 23': 'SR 23',
    'WA 24': 'SR 24',
    'WA 25': 'SR 25',
    'WA 26': 'SR 26',
    'WA 27': 'SR 27',
    'WA 28': 'SR 28',
    'WA 30': 'SR 30',
    'WA 31': 'SR 31',
    'WA 35': 'SR 35',
    'WA 41': 'SR 41',
    'WA 92': 'SR 92',
    'WA 96': 'SR 96',
    'WA 99': 'SR 99',
    'WA 100': 'SR 100',
    'WA 102': 'SR 102',
    'WA 103': 'SR 103',
    'WA 104': 'SR 104',
    'WA 105': 'SR 105',
    'WA 106': 'SR 106',
    'WA 107': 'SR 107',
    'WA 108': 'SR 108',
    'WA 109': 'SR 109',
    'WA 110': 'SR 110',
    'WA 111': 'SR 111',
    'WA 112': 'SR 112',
    'WA 113': 'SR 113',
    'WA 115': 'SR 115',
    'WA 116': 'SR 116',
    'WA 117': 'SR 117',
    'WA 119': 'SR 119',
    'WA 120': 'SR 120',
    'WA 121': 'SR 121',
    'WA 122': 'SR 122',
    'WA 123': 'SR 123',
    'WA 124': 'SR 124',
    'WA 125': 'SR 125',
    'WA 126': 'SR 126',
    'WA 127': 'SR 127',
    'WA 128': 'SR 128',
    'WA 129': 'SR 129',
    'WA 131': 'SR 131',
    'WA 140': 'SR 140',
    'WA 141': 'SR 141',
    'WA 142': 'SR 142',
    'WA 143': 'SR 143',
    'WA 150': 'SR 150',
    'WA 151': 'SR 151',
    'WA 153': 'SR 153',
    'WA 155': 'SR 155',
    'WA 160': 'SR 160',
    'WA 161': 'SR 161',
    'WA 162': 'SR 162',
    'WA 163': 'SR 163',
    'WA 164': 'SR 164',
    'WA 165': 'SR 165',
    'WA 166': 'SR 166',
    'WA 167': 'SR 167',
    'WA 168': 'SR 168',
    'WA 169': 'SR 169',
    'WA 170': 'SR 170',
    'WA 171': 'SR 171',
    'WA 172': 'SR 172',
    'WA 173': 'SR 173',
    'WA 174': 'SR 174',
    'WA 181': 'SR 181',
    'WA 193': 'SR 193',
    'WA 194': 'SR 194',
    'WA 202': 'SR 202',
    'WA 203': 'SR 203',
    'WA 204': 'SR 204',
    'WA 206': 'SR 206',
    'WA 207': 'SR 207',
    'WA 209': 'SR 209',
    'WA 211': 'SR 211',
    'WA 213': 'SR 213',
    'WA 215': 'SR 215',
    'WA 220': 'SR 220',
    'WA 221': 'SR 221',
    'WA 223': 'SR 223',
    'WA 224': 'SR 224',
    'WA 225': 'SR 225',
    'WA 230': 'SR 230',
    'WA 231': 'SR 231',
    'WA 232': 'SR 232',
    'WA 237': 'SR 237',
    'WA 240': 'SR 240',
    'WA 241': 'SR 241',
    'WA 243': 'SR 243',
    'WA 251': 'SR 251',
    'WA 260': 'SR 260',
    'WA 261': 'SR 261',
    'WA 262': 'SR 262',
    'WA 263': 'SR 263',
    'WA 270': 'SR 270',
    'WA 271': 'SR 271',
    'WA 272': 'SR 272',
    'WA 274': 'SR 274',
    'WA 276': 'SR 276',
    'WA 278': 'SR 278',
    'WA 281': 'SR 281',
    'WA 282': 'SR 282',
    'WA 283': 'SR 283',
    'WA 285': 'SR 285',
    'WA 290': 'SR 290',
    'WA 291': 'SR 291',
    'WA 292': 'SR 292',
    'WA 294': 'SR 294',
    'WA 300': 'SR 300',
    'WA 302': 'SR 302',
    'WA 303': 'SR 303',
    'WA 304': 'SR 304',
    'WA 305': 'SR 305',
    'WA 306': 'SR 306',
    'WA 307': 'SR 307',
    'WA 308': 'SR 308',
    'WA 310': 'SR 310',
    'WA 311': 'SR 311',
    'WA 339': 'SR 339',
    'WA 397': 'SR 397',
    'WA 401': 'SR 401',
    'WA 402': 'SR 402',
    'WA 403': 'SR 403',
    'WA 407': 'SR 407',
    'WA 409': 'SR 409',
    'WA 410': 'SR 410',
    'WA 411': 'SR 411',
    'WA 431': 'SR 431',
    'WA 432': 'SR 432',
    'WA 433': 'SR 433',
    'WA 500': 'SR 500',
    'WA 501': 'SR 501',
    'WA 502': 'SR 502',
    'WA 503': 'SR 503',
    'WA 504': 'SR 504',
    'WA 505': 'SR 505',
    'WA 506': 'SR 506',
    'WA 507': 'SR 507',
    'WA 508': 'SR 508',
    'WA 509': 'SR 509',
    'WA 510': 'SR 510',
    'WA 512': 'SR 512',
    'WA 513': 'SR 513',
    'WA 514': 'SR 514',
    'WA 515': 'SR 515',
    'WA 516': 'SR 516',
    'WA 518': 'SR 518',
    'WA 519': 'SR 519',
    'WA 520': 'SR 520',
    'WA 522': 'SR 522',
    'WA 523': 'SR 523',
    'WA 524': 'SR 524',
    'WA 525': 'SR 525',
    'WA 526': 'SR 526',
    'WA 527': 'SR 527',
    'WA 528': 'SR 528',
    'WA 529': 'SR 529',
    'WA 530': 'SR 530',
    'WA 531': 'SR 531',
    'WA 532': 'SR 532',
    'WA 534': 'SR 534',
    'WA 536': 'SR 536',
    'WA 537': 'SR 537',
    'WA 538': 'SR 538',
    'WA 539': 'SR 539',
    'WA 540': 'SR 540',
    'WA 542': 'SR 542',
    'WA 543': 'SR 543',
    'WA 544': 'SR 544',
    'WA 546': 'SR 546',
    'WA 547': 'SR 547',
    'WA 548': 'SR 548',
    'WA 599': 'SR 599',
    'WA 603': 'SR 603',
    'WA 702': 'SR 702',
    'WA 704': 'SR 704',
    'WA 706': 'SR 706',
    'WA 801': 'SR 801',
    'WA 821': 'SR 821',
    'WA 823': 'SR 823',
    'WA 831': 'SR 831',
    'WA 832': 'SR 832',
    'WA 833': 'SR 833',
    'WA 900': 'SR 900',
    'WA 901': 'SR 901',
    'WA 902': 'SR 902',
    'WA 903': 'SR 903',
    'WA 904': 'SR 904',
    'WA 906': 'SR 906',
    'WA 908': 'SR 908',
    'WA 920': 'SR 920',
    'WA 970': 'SR 970',
    'WA 971': 'SR 971',
    'WA 9 Spur': 'SR 9 Spur',
    'WA 14 Spur': 'SR 14 Spur',
    'WA 14 Bus.': 'SR 14 Bus.',
    'WA 16 Alt.': 'SR 16 Alt.',
    'WA 16 Spur': 'SR 16 Spur',
    'WA 20 Spur': 'SR 20 Spur',
    'WA 20 Bus.': 'SR 20 Bus.',
    'WA 26 Spur': 'SR 26 Spur',
    'WA 28 Spur': 'SR 28 Spur',
    'WA 92 Spur': 'SR 92 Spur',
    'WA 100 Spur': 'SR 100 Spur',
    'WA 104 Spur': 'SR 104 Spur',
    'WA 105 Spur': 'SR 105 Spur',
    'WA 108 Bus.': 'SR 108 Bus.',
    'WA 109 Spur': 'SR 109 Spur',
    'WA 110 Spur': 'SR 110 Spur',
    'WA 125 Spur': 'SR 125 Spur',
    'WA 129 Spur': 'SR 129 Spur',
    'WA 141 Spur': 'SR 141 Spur',
    'WA 151 Spur': 'SR 151 Spur',
    'WA 155 Spur': 'SR 155 Spur',
    'WA 174 Spur': 'SR 174 Spur',
    'WA 240 Bus.': 'SR 240 Bus.',
    'WA 281 Spur': 'SR 281 Spur',
    'WA 302 Spur': 'SR 302 Spur',
    'WA 503 Spur': 'SR 503 Spur',
    'WA 504 Spur': 'SR 504 Spur',
    'WA 510 Spur': 'SR 510 Spur',
    'WA 524 Spur': 'SR 524 Spur',
    'WA 525 Spur': 'SR 525 Spur',
    'WA 529 Spur': 'SR 529 Spur',
    'WA 903 Spur': 'SR 903 Spur',
    'WA 906 Spur': 'SR 906 Spur'

}

tree = ET.parse('export.osm')
root = tree.getroot()

for tag in root.iter('tag'):
    val = tag.get('v')
    if val in swapdict:
        tag.set('v', swapdict[val])

tree.write('export_updated.osm', encoding='UTF-8', xml_declaration=True)

Everything seems to be working out as expected. These are the values that weren’t used:
['WA 108 Bus.', 'WA 111', 'WA 120', 'WA 126', 'WA 14 Bus.', 'WA 140', 'WA 141 Spur', 'WA 143', 'WA 151', 'WA 151 Spur', 'WA 16 Alt.', 'WA 168', 'WA 20 Bus.', 'WA 209', 'WA 220', 'WA 230', 'WA 232', 'WA 237', 'WA 240 Bus.', 'WA 251', 'WA 276', 'WA 294', 'WA 30', 'WA 306', 'WA 311', 'WA 402', 'WA 403', 'WA 407', 'WA 41', 'WA 431', 'WA 504 Spur', 'WA 510 Spur', 'WA 514', 'WA 537', 'WA 540', 'WA 603', 'WA 801', 'WA 831', 'WA 832', 'WA 833', 'WA 901', 'WA 904']

Does anyone see any faults with this? If not I’ll go ahead and re-run/push these changes up in a few days.

I’ve attached the old/new osm exports for comparison. Does anyone see any faults with this approach?

EDIT: I actually found an issue with this. Working on fixing it now.