feat(transit): name YRT's local branch routes

YRT encodes a branch as a two-digit suffix on the base route id. The Viva
table already depended on that scheme — `60102` is Viva Blue's B branch —
but local routes were passed through whole, on the reasoning that a YRT
route id is already the number on the bus. For a plain route it is. For a
branch it is not: a rider watching route 83's B-branch bus saw "8301".

A 15:41 EDT sample of the live feed found four branch ids in service.
Three are published in York Region's GTFS `routes.txt` and are named here
from it, unpadded to match the local routes beside them (the file says
`083A`; the registry has always preferred `105` to `005`):

    10702 -> 107B   KEELE
    8301  -> 83A    TRENCH
    9002  -> 90B    LESLIE

The fourth, `9101`, runs in the realtime feed but appears nowhere in
`routes.txt`. The pattern all but spells "91A" and that is precisely why
it is absent: the registry translates published names, it does not infer
them. It stays opaque until York Region publishes it.

Renamed YRT_VIVA_ROUTE_NAMES to YRT_ROUTE_NAMES, since the table is no
longer only about Viva.
This commit is contained in:
Cliff Flood committed 2026-10-15 20:18:15 -04:00
1 parent a7fc5ea7c5
commit 4ffbdda3f5
2 files changed
+34 -6

No files matched your search

+18 -6
View File
@@ -186,18 +186,30 @@ function guelphRouteLabel(routeId) {
/**
* YRT publishes Viva bus rapid transit by route id (`601`), while every rider,
* station sign and map calls it "Viva Blue". The local routes are already the
* number on the bus and are left alone. Colours are from York Region's own
* published GTFS `routes.txt`; Viva Green (604) and Pink (606) are not in
* current service and so are absent here too.
* station sign and map calls it "Viva Blue". Plain local routes are already the
* number on the bus and are left alone, unpadded: `105` reads better than the
* `005` of `routes.txt`.
*
* Branches are the exception. YRT suffixes a two-digit branch onto the base
* route — the scheme Viva's own `60102` follows — so a branch id reaches a
* rider as "8301" unless it is translated. Names and colours are from York
* Region's own published GTFS `routes.txt`; Viva Green (604) and Pink (606)
* are not in current service and so are absent here too.
*
* Only branches observed live AND published in `routes.txt` are listed. `9101`
* runs but is unpublished, so it is deliberately missing: the pattern suggests
* "91A", and suggesting is not knowing.
*/
const YRT_VIVA_ROUTE_NAMES = Object.freeze({
const YRT_ROUTE_NAMES = Object.freeze({
601: 'Viva Blue',
60102: 'Viva Blue B',
603: 'Viva Purple',
60301: 'Viva Purple A',
605: 'Viva Orange',
607: 'Viva Yellow',
8301: '83A',
9002: '90B',
10702: '107B',
});
/**
@@ -206,7 +218,7 @@ const YRT_VIVA_ROUTE_NAMES = Object.freeze({
* @returns {string|null}
*/
function yrtRouteLabel(routeId) {
return YRT_VIVA_ROUTE_NAMES[routeId] || routeId;
return YRT_ROUTE_NAMES[routeId] || routeId;
}
/**
+16
View File
@@ -416,6 +416,22 @@ test('Viva bus rapid transit is named by its colour, not its route number', () =
assert.equal(transitRouteLabel(yrt, '9899'), '9899');
});
test('YRT local branches read as the branch letter, not the padded id', () => {
// YRT suffixes a two-digit branch onto the base route, the same scheme the
// Viva table already relies on for `60102`. Unsuffixed, that leaks to a rider
// as "8301". The letters are York Region's own published GTFS
// `routes.txt` short names, unpadded to match the local routes beside them.
const yrt = getTransitFeed('yrt-york');
assert.equal(transitRouteLabel(yrt, '10702'), '107B');
assert.equal(transitRouteLabel(yrt, '8301'), '83A');
assert.equal(transitRouteLabel(yrt, '9002'), '90B');
// `9101` runs in the realtime feed but is absent from routes.txt, so there is
// no published name to give it. Inventing "91A" from the pattern is exactly
// the guess the registry refuses to make; it stays opaque until it is
// published.
assert.equal(transitRouteLabel(yrt, '9101'), '9101');
});
test('Burlington route ids are joined, never prefix-stripped', () => {
// `351` is route 1 and `3510` is route 10, so no amount of trimming a `35`
// prefix works — the table is the only correct answer.