feat(transit): let a feed name its own modes, and call TTC trams streetcars

A Toronto 501 and a Helsinki 1010 are both the `tram` mode. Only one of
them is called a tram by the people who ride it, and the detection label
is documented as "what a person standing at the stop would call it".

So the mode stays shared — same silhouette, same speed limits — and a
registry entry may carry `modeWords` naming the modes it runs. Everything
without an override falls through to the shared table, so this renames one
word for one operator and nothing else.

Threading the feed to the detection metric needed a resolver in queries.js,
since the cached-contact path has only the entry. It answers from live feeds
first, so a feed disabled mid-session stops supplying vocabulary.
This commit is contained in:
Cliff Flood committed 2026-10-15 20:18:15 -04:00
1 parent c5f7fe285b
commit 9fc4a5ac04
4 files changed
+125 -9

No files matched your search

+25 -5
View File
@@ -12,6 +12,20 @@ import {
} from '../../data/transitFeeds.js';
import { transitModeTier } from '../../data/transitPresetStyle.js';
/**
* The registry entry behind a vehicle. Live feeds answer first so a feed the
* session disabled stops supplying vocabulary; the registry is the fallback,
* because a vehicle can outlive the poll that brought it.
* @param {object} state Layer state.
* @param {object} entry Vehicle entry.
* @returns {object|null}
*/
function feedForEntry(state, entry) {
const id = entry?.feedId;
if (!id) return null;
return state._activeFeeds.get(id) || getRegisteredTransitFeed(id) || null;
}
/**
* The layer row's answer to "what is on screen and is it honest?".
* @param {object} context
@@ -101,6 +115,7 @@ export function createQueries({ state, parts }) {
contact._entry,
contact._entry.mode,
now,
feedForEntry(state, contact._entry),
);
return;
}
@@ -132,10 +147,10 @@ export function createQueries({ state, parts }) {
entry.labelRecord = entry.record;
}
if (!entry.labelClass || entry.labelMode !== entry.mode) {
const feed =
state._activeFeeds.get(entry.feedId) ||
getRegisteredTransitFeed(entry.feedId);
entry.labelClass = transitDetectionClass(entry.mode, feed);
entry.labelClass = transitDetectionClass(
entry.mode,
feedForEntry(state, entry),
);
entry.labelMode = entry.mode;
}
const contact = {
@@ -146,7 +161,12 @@ export function createQueries({ state, parts }) {
id: entry.labelId,
type: 'VEH',
klass: entry.labelClass,
metric: transitDetectionMetric(entry, entry.mode, now),
metric: transitDetectionMetric(
entry,
entry.mode,
now,
feedForEntry(state, entry),
),
// The bracket carries the mode colour in every preset: the detection
// canvas sits above the post-FX chain, where the sprites' own colour
// is lost under NVG and FLIR. Keyless too — the feeds are keyless.