Mass rename of Perth bus stop names

Bus naming 2 electric boogaloo.

This post is mainly about addressing the first point I made in my previous post about bus stop naming, namely the fact that most bus stops do not follow OSM’s guidance around abbreviations, where it is made very clear that you should not do it. It occurred to me that 95% of the work could be done with some basic automated editing, namely something akin to this overpass query:

node({{bbox}})
    ["network:wikidata" = Q1503488]
    [highway=bus_stop]
    [name~"(after|before)"];
node({{bbox}})
    ["network:wikidata" = Q1503488]
    [highway=bus_stop]
    [name~"\\b(Hwy|Rd|St|Ave|Av|Tce|Ln|Blvd|Ct|Dr|Cres)\\b", i];

The first query is trivial, just look for bus stops with “after” or “before” in lower case, the edit could just upper case them to comply with title case.

The second query just looks for common abbreviations like “Hwy” for Highway, “Rd” for Road, etc. Anything found in this query can just be a trivial search and replace for the unabbreviated name. For the second query some manual editing will need to be done in order to avoid false positives, mostly around the abbreviation of “St”, as expanding “St Georges Terrace” to “Street Georges Terrace” is obviously wrong. Still, there are not many “St [name]” streets in Perth, so I’d imagine that all of them could be found rather quickly and manually removed from the renaming before being uploaded.

I’m asking here first because whilst I am in favour of doing this its a relatively large change and I don’t want to dive into doing an automated edit without first asking people if they’re OK with it.

edit: apparently I can make a poll, so here’s a poll :slight_smile: :

  • Yes
  • No
0 voters

I’m not familiar with the mass editing process, but can see many other potential abbreviations other than “st” creating problems. How is the “manual editing” done? Do you see a list of all the changes to be made before they are committed, and can then check through them, make the reversions where required, then commit the changes?

I can see many other potential abbreviations other than “st” creating problems.

I mean I’d like to know them, I can’t think of any obvious abbreviations for e.g. “Rd” other than “Road” that would be used on a bus stop. Or any of the other in the list e.g. Hwy

How is the “manual editing” done? Do you see a list of all the changes to be made before they are committed, and can then check through them, make the reversions where required, then commit the changes?

Yes, I’m just going to be using the JOSM Scripting plugin, then manually cleaning up the results.

I mean I’d like to know them, I can’t think of any obvious abbreviations for e.g. “Rd” other than “Road” that would be used on a bus stop. Or any of the other in the list e.g. Hwy

Ah, I suppose if they were stand-alone “words” (ie either a space or end of line before and after them), and case sensitive, I guess there shouldn’t many many other issues.

Ah, I suppose if they were stand-alone “words” (ie either a space or end of line before and after them), and case sensitive, I guess there shouldn’t many many other issues.

yep, the \b in the regex is a word boundary and does exactly that.

1 Like

While this is the case for road names, as I mentioned in the other thread, it’s very common practice to have the abbreviations from the signage appear as abbreviations in the bus stop name.

Either way I think there should be a strong support for expanding out the abbreviations for bus stops before doing so, and we shouldn’t just automatically inherit the guidance for road/street names. So I voted no, as a way to say let’s get wider support first, plus I’m still on the fence about it.

In terms of road/street names, it’s common to also see places refer to the street by the full name, but bus stop names are usually quite specific and only usually appear in the exact from per the sign.

Keeping the abbreviations would also make it easier to remain in sync with the Transperth PTA data.

I’d like to hear what @donmac703 thinks about your proposal.

Just for some clarification on Perth bus stop naming conventions: Bus stops do not typically have their names plastered on them on any physical signage on the ground, the most identifying feature they usually have is just some kind of stopID and a timetable (and sometimes not even that). The actual names displayed in apps and that are used in conversation are derived almost always from some kind of relation with their surrounding streets, e.g. “Davies Rd After Shenton Rd”, “Rokeby Rd Before Hay St”, etc. For stops that do have names on the physically (e.g. the CAT services) they use the full name like “Outram Street” on the shelter.

The use of abbreviations in OSM are derived almost entirely from the fact that Transperth uses the abbreviations as display names in their apps from what I can tell.

To provide some examples of transperth bus stop naming conventions:

The typical “generic” stops will usually have a pole with a stop number, a list of busses that stop at that location as well as a timetable. The list of busses that stop do often (but not always) abbreviate their destination i.e. “960 to Curtin University Bus Stn via foobar Ave”, though sometimes this is omitted if the name is short enough or there isn’t an appropriate abbreviation e.g. " 99 to XYZ place via The Boulevard" or “100 to Perth Busport”. No pole that I have encountered so far that follows the “[Street name] [before/after] [Street name]” convention actually has any physical signage with its name on it.

A couple examples I found on the internet, this is your typical bus stop post with a timetable and everything. This is an image of the focusing on the list of busses that stop, and here is an image of a post with no timetable.

When they do have their names on the post or surrounding infrastructure they opt for the long name, for example the perth CAT’s use the long name on the shelters and/or posts, as well as the posts on St Georges Terrace and Adelaide Terrace that just use the unabbreviated name of the stop

After some testing I’ve come up with this script, its not perfect (the abbreviations used are inconsistent, of course… sometimes even “L” was used for “Lane”, which I have opted to just fix manually) but it correctly edited 95% of the bus stops, whilst skipping most of the “saint named” bus stops I could find used in Perth, it places the names of the ones that were skipped in a file so I can review them layer (I also want to put the way ID in there as well when/if I actually do this for real).

import josm from 'josm'
import { buildChangeCommand } from 'josm/command'
import layers from 'josm/layers'
const Files = Java.type('java.nio.file.Files')
const Paths = Java.type('java.nio.file.Paths')

const KEY = 'name'
const QUERY = /\b(after|before|hwy|rd|st|tce|ln|pl|cl|cnr|wy|rmbl|rtt|gdns|pde|prom|ct|dr|pwy|ave|av|blvd|bvd|bld|cres|cr)\b/gi
const MAP = {
    ["after"]: "After",
    ["before"]: "Before",
    ["hwy"]: "Highway",
    ["rd"]: "Road",
    ["st"]: "Street",
    ["tce"]: "Terrace",
    ["ln"]: "Lane",
    ["pl"]: "Place",
    ["cl"]: "Close",
    ["cnr"]: "Corner",
    ["wy"]: "Way",
    ["rmbl"]: "Ramble",
    ["rtt"]: "Retreat",
    ["gdns"]: "Gardens",
    ["pde"]: "Parade",
    ["prom"]: "Promenade",
    ["ct"]: "Court",
    ["dr"]: "Drive",
    ["pwy"]: "Parkway",

    ["ave"]: "Avenue",
    ["av"]: "Avenue",

    ["blvd"]: "Boulevard",
    ["bvd"]: "Boulevard",
    ["bld"]: "Boulevard",

    ["cres"]: "Crescent",
    ["cr"]: "Crescent",
};

const SAINT_ROADS = [
    "st george",
    "st leonard",
    "st lawrence",
    "st vincent",
    "st alban",
    "st monica",
    "st peter",
    "st columban",
    "st kilda",
    "st ettiene",
    "st pierre",
    "st quentin",
    "st barbara",
    "st michael",
    "st john",
    "st andrew",
    "st raphael",
    "st emilies",
    "st brigids",
    "st james",
    "st patrick",
    "st joseph",
    "st helier",
    "st helen",
    "st tropez",
    "st alban",
    "st lucia",
    "st laurent",
    "st blaise",
    "st remy",
    "st louis",
    "st clair",
    "st michael",
    "st cloud",
    "st stephen",
    "st ives",
    "st anne",
    "st barnabas",
]

/**
 * @param name {string}
 */
function isOnSaintRoad(name) {
    const n = name.toLowerCase();
    return n.startsWith("st") || SAINT_ROADS.some(s => n.includes(s))
}
const SKIPPED_FILE = '~/skipped_names.txt'

const layer = layers.activeLayer
const selected = layer.data.getSelected()
const skippedNames = new Set()
let changed = 0

for (const obj of selected) {
    const oldValue = obj.get(KEY)
    if (oldValue == null) continue
    if (isOnSaintRoad(oldValue)) {
        skippedNames.add(oldValue)
        continue
    }

    const newValue = oldValue.replace(QUERY, (match, abbr) => MAP[abbr.toLowerCase()] ?? match)

    if (newValue !== oldValue) {
        buildChangeCommand(obj, { tags: { [KEY]: newValue } }).applyTo(layer)
        changed++
    }
}
if (skippedNames.size > 0) {
    try {
        const text = [...skippedNames].join('\n') + '\n'
        Files.writeString(Paths.get(SKIPPED_FILE), text)
    } catch (e) {
        josm.alert(`Could not write ${SKIPPED_FILE}: ${e}`)
    }
}
josm.alert(`Changed ${changed} objects`)

ideally it would probably also check around the node within some distance (e.g. 50-100 metres or something) for roads with a certain name, i.e. bus stop “Foo Way Before Bar Street” would look for “Foo Way” and “Bar Street” within that distance, which would also reduce false edits/errors.

The only issue I see with this proposal is that it makes the map somewhat more cluttered, but map styles can still calculate abbreviated names based on full names if that actually becomes a problem, similar to how some map styles choose to abbreviate road names. (In my opinion, it doesn’t really make sense for bus stop names to be shown at all on the map given they’re largely descriptive + based on nearby street names - but that’s a separate thing haha)

I don’t really see how this is relevant - tagging refs on bus stops is pretty established, and it sounds like these refs are even verifiable on the ground. If you are referring specifically to keeping name changes in sync, mapping the full name back to abbreviations is much easier compared to the other way round.

I’m pretty sure it used to be the case that if you searched the Transperth app or website for e.g. “Bagot Road before Francis Street” it wouldn’t find “Bagot Rd Before Francis St”. That bug has been fixed now though. Expanding the road abbreviations will make things read a bit nicer (i.e. the bus stop name will more closely match the street names on the maps).

The fact that Transperth don’t put the name on the signs is really silly, given that that’s how they refer to the stops in the timetables. How people are supposed to know when it’s a “before x” name rather than an “after y” one, I don’t know.

That is one of the motivation behind the change. The article on abbreviation notes that its much easier to go from “St Andrews Street After Pickett Drive” to “St Andrews St After Pickett Dr” for computer software than it is to go the other way around. If abbreviations are needed the map style can almost always safely truncate Street to St, Drive to Dr, etc, etc. It’ll also be more consistent as well, because right now there are 2 different abbreviations for Avenue and Crescent and 3 for Boulevard that are in use.

At the very least even if the proposal for unabbreviating stop names isn’t accepted I’ll probably go ahead with title casing After & Before for consistency, the map is currently using both lower and upper case for them, and Transperth uses capital After/Before.

I think that’s the case for most bus stops.

Yes I think so, indeed since the names aren’t signposted and given the sames always seem to exactly match PTA data, they must have been originally sourced from PTA data (which luckily is CC BY with a waiver so we can use it, however there is no attribution listed on Contributors - OpenStreetMap Wiki which given the high likely hood that PTA data is being used as a source, someone should add it)

Agreed.

I’m thinking that PTNA would keep flagging the names as different, but yes PTNA could try to make the compare abbreviations aware.

To me having the name=* match exactly the name used by the transport agencies on any signage or official references in apps or online, abbreviations and all makes it easier to compare between the two.

In theory, as you’re attempting in your scripts, you should be able to convert to all abbreviations or all expanded, but if we bake that into OSM we’ll never be able to get back the exact string used by the agencies (apart from matching against their data by ID).

After some testing I’ve come up with this script, its not perfect (the abbreviations used are inconsistent, of course… sometimes even “L” was used for “Lane”, which I have opted to just fix manually)

Yeah I noticed Node: ‪Kintail Rd After Stack L‬ (‪7115763318‬) | OpenStreetMap (uses L for lane, not Ln), but again I’m still not sure if we should strive to have the name match what the agency uses, or try to “fix” it.

Node: ‪Booragoon‬ (‪12906006140‬) | OpenStreetMap interestingly in the PTA data includes stand codes, missing from OSM, and abbreviates to “Booragoon Bus Stn”

Node: ‪Dean Rd After Grave Pass‬ (‪2564428618‬) | OpenStreetMap for example “Passage” / “Pass”

Node: ‪Calley Dr After Oakland Hts‬ (‪12898874290‬) | OpenStreetMap for example “Heights” / “Hts”

I’ve undone my vote, if you and others think this is a good idea, all good. If I want exactly what the agency has I can always source it via the ref IDs.

AFAIK ptna.openstreetmap.de does not have Transperth data as the GTFS feeds are all proprietary anyways.

Uh, whoops, that was my mistake :face_with_tongue: . Per the last thread I’ve been gradually removing the stand suffixes and didn’t notice that the Booragoon stands didn’t have a corresponding local_ref already. I’ve gone ahead and fixed that.

welp, considering the discussion here and the polls current 4-1 (or 4-0? someone did both??) I’m going to go ahead with the renaming. There will be some manual renaming of the St streets afterwards.

Sorry, I have been busy.

I have a number of points to make.

  1. Is this intended to be expanded to other states/public transport authorities, or are we to have mish-mash of things across the country? (Shouldn’t there be at least some sort of consistency in one country?)
  2. Is someone going to capture these mapping rules on the appropriate wiki so that they can be used in an automated QA function or by new mappers so that they know how to craft an “acceptable name” from whatever data they are looking at? As new stops are added or renamed it is certain that some names will “no longer comply”.
  3. Is this intended to be a “One-and-done” exercise, or is it going to continue in the future? If so, who is signing up?
  4. Have we looked at the Transperth GTFS feed? What values is it supplying? If they are different from what we are putting into OSM, we should publish the recognition of that fact on the wiki, so that people know that the GTFS names have to be “adjusted” to fit the new naming standard, and not simply copy/paste them into the OSM attributes (probably most of the PT data in Australia reflects the published GTFS data)

If we intend to have our own home-baked names, we will need to load the GTFS stops data to the appropriate gtfs: name space fields, so that automated comparisons can take place.

The key thing here is how to detect that a stop now has a different name (yes, it happens often enough) as opposed to one that doesn’t meet the “naming standard”. Otherwise, we end up having have compliant but incorrect data.

It’s only been three days, I don’t believe it’s settled and given @donmac703 is joining the discussion, please allow further time.

Maybe?, the PTA operates other bus routes around the state under the name transregional. However, besides Bunbury the routes, bus stops, etc seem to be hardly mapped at all (e.g. I can’t see anything for TransHedland in Port Hedland). Its probably a good idea for them to follow these rules, but the infrastructure will have to be mapped first, and in that case its all being done manually anyways.

Not necessarily, Australia is a federal state and each state handles things differently. Whilst there should be some agreement in places each state has its own quirks that have to be handled differently from each other. Each state handles its transport infrastructure differently and each states mapping community should handle it how they see fit as far as I’m concerned, public transport infrastructure is probably the part of mapping that has the largest differences between the states

However, thats not to say that I think that no agreements or cohesion can be put in place, if we actually look at the different states bus names we’ll see:

Melbourne follows a very different naming convention “Stop <number>: <Stop Name>” or “<Street Name>/ <Street Name>”. There is no “before/after”, “at/opp”, or shortening of street names.

Adelaide seems to follow a similar convention, though they drop the colon and add a “side” to the name. I.e. “Stop <number> <Street Name> - South/North side”

Sydney’s stop seem to follow a somewhat similar convention to perth, and use abbreviations, though they seem to opt for a naming convention like “Something St at Foobar St”, or “Something St opp Place Name”, rarely using “Something St after Foobar St”, they dont consistently use “Something St before/after Foobar St” like Transperth does.

Brisbane’s… just seems all over the place tbh, they follow a similar convention to Sydney, but whether or not the street names are abbreviated seems random, and they also append the stop number at the end. So you see stuff like “Jurgens St at Balaclava Street, stop 10” but also things like “Jerrang St near Market St, stop 32”. They also make use of places as well, e.g. “Kingfisher Creek at railway St” (without any stop name)

Darwin seems to use place names and then a stop id in brackets, “Winnellie Shops (182)” for example. When street names are used they don’t seem to be abbreviated.

There can probably be some agreement found here, but as far as I’m concerned its up to the various mappers in their respective states to come up with whatever policy they want for their state. My concern is with Perth mapping first and foremost.

It can be added to Perth - OpenStreetMap Wiki and the Western Australia page if/when its expanded to Transregional.

At the present moment yes, Transperth does not set up or change its busses often enough for me to justify setting up some kind of bot to automagically “fix” any additional bus stops (plus, I feel like that can only go poorly). If/when new bus stops are added hopefully the mapper will see the convention of other bus stops in the area and name accordingly, and if they don’t it can always be fixed later.

That won’t catch everyone of course, nor am I omniscient. But for now I am fine with the possibility that in the future someone will come along and use the “wrong” names. Its not like the map was consistent before, plenty of stops in the norther suburbs were already using the unabbreviated “Road”, “Street”, etc. Just because the person mapping them didn’t opt to shorten them.

I agree that it should probably be noted, as they do provide the short names rather than the long names. A big problem is that Transperth’s GTFS data is copyrighted, so it can’t be used in the first place, nor do the names GTFS provide actually follow the on ground names that Transperth sometimes uses. For example, the CAT services on the ground have simple names like “Ord Street”, “East Perth TAFE”, etc. but in the GTFS data they have names like “Outram St Outram Street Cat Id 93”