From 279aedb2f48b1bcb684164044ab2de5f38995317 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Sat, 14 Nov 2026 09:54:01 -0800 Subject: [PATCH 01/30] Draw aids to navigation as buoys A buoy, beacon, RACON, light or IALA mark in the vessel feed was drawn as a ship. A vessel record whose type names one, or whose MMSI is an aid-to-navigation station's (99MIDxxxx), is now isAidToNavigation and vesselModelSpec draws it as the fleet set's buoy of its mark (cardinal N/E/S/W, port or starboard hand, safe water, isolated danger, special mark; a red can when the type names no mark), at its built size and flagged fixed so its model does not turn to a heading. Its icon is a disc instead of a chevron. AISStream now subscribes to AidsToNavigationReport by default, and the server names each report's aid type code (0 to 31) as its kind instead of reading it as a ship type. --- .env.example | 2 +- changelog.d/0000-buoy-models.md | 7 +++ docs/CURRENT-STATE.md | 2 +- public/models/README.md | 6 ++ scripts/package-boundaries.json | 6 ++ server/providers/vessels/ais-live.js | 2 + server/providers/vessels/ais-store.js | 8 ++- src/data/aisStreamSentinels.test.mjs | 26 +++++++++ src/data/fleetModels.js | 67 +++++++++++++++++++++-- src/data/fleetModels.test.mjs | 54 ++++++++++++++++++ src/data/vesselTypes.js | 79 +++++++++++++++++++++++++++ src/data/vesselTypes.test.mjs | 47 ++++++++++++++++ src/layers/vessels/ownership.test.mjs | 24 ++++++++ src/layers/vessels/rendering.js | 29 ++++++++-- 14 files changed, 345 insertions(+), 14 deletions(-) create mode 100644 changelog.d/0000-buoy-models.md create mode 100644 src/data/vesselTypes.test.mjs diff --git a/.env.example b/.env.example index 2caf21d29..a9819f100 100644 --- a/.env.example +++ b/.env.example @@ -176,7 +176,7 @@ VITE_AIS_LIVE_LABEL_MAX_ROWS=900 AISSTREAM_API_KEY= # Optional AISStream subscription filters. # AISSTREAM_BOUNDING_BOXES=[[[-90,-180],[90,180]]] -# AISSTREAM_MESSAGE_TYPES=PositionReport,StandardClassBPositionReport,ExtendedClassBPositionReport,ShipStaticData,StaticDataReport +# AISSTREAM_MESSAGE_TYPES=PositionReport,StandardClassBPositionReport,ExtendedClassBPositionReport,ShipStaticData,StaticDataReport,AidsToNavigationReport # Feed watchdog: silence (ms) after which the feed is REPORTED stale; the socket # is recycled at 2.5x that. Default 120000. The watchdog self-arms only for the # default worldwide subscription — a narrow filter above can be legitimately diff --git a/changelog.d/0000-buoy-models.md b/changelog.d/0000-buoy-models.md new file mode 100644 index 000000000..a41fd3957 --- /dev/null +++ b/changelog.d/0000-buoy-models.md @@ -0,0 +1,7 @@ +- Draw aids to navigation as buoys instead of ships: a buoy, beacon, RACON, + light or mark from the vessel feed (or any AIS station numbered 99MIDxxxx) + is now the fleet set's buoy of its IALA mark (cardinal, port or starboard + hand, safe water, isolated danger or special mark), standing still with no + heading, and its icon is a disc rather than a chevron. AISStream now + subscribes to aid-to-navigation reports and names each by its kind of mark + (samehkhamis, #0000). diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md index 59077f153..74a9fd50e 100644 --- a/docs/CURRENT-STATE.md +++ b/docs/CURRENT-STATE.md @@ -7430,7 +7430,7 @@ pins and share links already supply complete boxes. 30-second backoff ahead of the current clock are ignored. A smaller rollback can retain a bounded retry delay of up to 30 seconds. - Commercial and military aircraft use the same high-level FLEET model regime: 2D billboards when zoomed out, optional glTF models when closer, controlled by the DISPLAY rail `3D` toggle and `Proximity` / `All` modes. Every model is one of the project's procedural fleet models (`public/models/fleet/`, MIT, 122 GLBs, about 2 MB in all; `public/models/README.md`), chosen per aircraft by `aircraftModelSpec` (`src/data/fleetModels.js`): the first of its ICAO type's callsign rules in `types.json` (`aircraft_callsign`) its callsign matches, else its type's entry, else the model of its `classifyAircraft` class for a type the map lacks, else its ADS-B emitter category's, else the default airliner. It is drawn LIFE SIZE: the type's published length over the model's built length (`src/layers/flights/modelSpec.js`, shared by Flights, Military Flights and Local ADS-B), and a grounded aircraft stands the model's scaled clearance above the ground. An airport ground vehicle (feed type `ZVEH`) is a fire truck (`FIRE…`), pushback tug (`PUSH…`, `TUG…`), van (`DEICER…`, `SQUID…`, `SQB…`) or else a car by its callsign, and a ground station (`GRND`) is an 11.8 m radio mast; these models (catalog category `other`) are drawn at their built size, and such a contact with no altitude stands on the ground instead of at the airborne default (`src/layers/flights/records.js`). `classifyAircraft` still picks the 2D icons. The whole set loads once, up front, when a layer that draws it starts (`loadFleetModelSet`, which logs `[Fleet] N/122 models (X MB) loaded in N ms`); models are built from those bytes, never fetched mid-session, and an aircraft stays its billboard until the set has loaded. Every aircraft model draws its mesh's own colours (`aircraftModelBlend`, `src/data/aircraftModelLighting.js`): Cesium's `ColorBlendMode.HIGHLIGHT` with white, in Flights, Military Flights and Local ADS-B alike; the tracked colour (cyan, or amber in Military Flights) and the emergency red multiply into the mesh, so its paint still shows. IR boost draws them flat white (`MIX` at `1.0`). Under NVG/FLIR (map preset or Cockpit vision) models render unlit flat-white at full alpha and scene fog is disabled (fog otherwise blacks out distant models with the globe hidden); state restores on exit. -- Vessels, Transit and Rail draw fleet models under the same DISPLAY rail `3D` toggle, at the same altitude ceiling, caps and add/keep radii as the aircraft (`FLEET_MODEL_POLICY`, `src/layers/flights/policy.js`; `createFleetModelLayer`, `src/data/fleetModelInstances.js`). A vessel's model follows its AIS ship type and is drawn at its reported length and beam (AIS static dimensions A+B and C+D, now carried on vessel rows as `length` and `beam`), standing at the sea surface, heading by true heading then course. A transit vehicle's model follows its layer mode (bus, tram, subway, rail or ferry; a vehicle of `unknown` mode keeps its icon), a train's its rail category and mode (rail, metro or tram). Neither the transit nor the rail sources carry a GTFS `route_type` or a finer mode (monorail, gondola, funicular, cable car), so the set's models for those and their `transit.elevation` lifts are not reached by any live source today. Both stand on the road or rail top they are drawn on, without the 1.5 m `GROUND_FLOOR_LIFT_M` their icons carry, and are painted in their mode or category colour where the model's `_TINT` attribute marks it. A vessel model is clipped at its waterline (one clipping plane per model, at the model origin's horizontal plane), so its hull below the water never shows through a plain globe, which Cesium does not depth-test models against. Under the NVG/FLIR styles (the Flights `irBoost` parameter) these models render unlit flat white, as aircraft models do. Each vehicle's icon stays the visual until its model is loaded, ready and placed; a model is picked as its icon is, and a vehicle drawn as its model keeps its selection card and its place in the detection overlay. +- Vessels, Transit and Rail draw fleet models under the same DISPLAY rail `3D` toggle, at the same altitude ceiling, caps and add/keep radii as the aircraft (`FLEET_MODEL_POLICY`, `src/layers/flights/policy.js`; `createFleetModelLayer`, `src/data/fleetModelInstances.js`). A vessel's model follows its AIS ship type and is drawn at its reported length and beam (AIS static dimensions A+B and C+D, now carried on vessel rows as `length` and `beam`), standing at the sea surface, heading by true heading then course. An aid to navigation is not a hull: a vessel record whose type names a buoy, beacon, mark, RACON or light, or whose MMSI is an aid-to-navigation station's (`99MIDxxxx`), is `isAidToNavigation` (`src/data/vesselTypes.js`) and is drawn as the set's `buoys` model of the IALA mark its type names (`aidToNavigationModel`, `src/data/fleetModels.js`: cardinal N/E/S/W, port or starboard hand, preferred channel by its side, safe water, isolated danger, special mark; a beacon, light, light vessel, RACON or reference point with no mark of its own is the special mark), else a red can (`DEFAULT_AID_MODEL`), at its built size and facing north whatever heading it reports. Its icon is a bone-white ringed disc instead of a chevron, never rotated. AISStream subscribes to `AidsToNavigationReport` (message 21) by default, and the server names each report's aid type code (0 to 31) as its kind (`aidToNavigationTypeName`: `20` is `Cardinal Mark N`) rather than reading it as a ship type. A transit vehicle's model follows its layer mode (bus, tram, subway, rail or ferry; a vehicle of `unknown` mode keeps its icon), a train's its rail category and mode (rail, metro or tram). Neither the transit nor the rail sources carry a GTFS `route_type` or a finer mode (monorail, gondola, funicular, cable car), so the set's models for those and their `transit.elevation` lifts are not reached by any live source today. Both stand on the road or rail top they are drawn on, without the 1.5 m `GROUND_FLOOR_LIFT_M` their icons carry, and are painted in their mode or category colour where the model's `_TINT` attribute marks it. A vessel model is clipped at its waterline (one clipping plane per model, at the model origin's horizontal plane), so its hull below the water never shows through a plain globe, which Cesium does not depth-test models against. Under the NVG/FLIR styles (the Flights `irBoost` parameter) these models render unlit flat white, as aircraft models do. Each vehicle's icon stays the visual until its model is loaded, ready and placed; a model is picked as its icon is, and a vehicle drawn as its model keeps its selection card and its place in the detection overlay. - **Aircraft models skip Cesium's dynamic environment map (2026-10-24).** Flights, Military Flights and Local ADS-B pass `environmentMapOptions: AIRCRAFT_ENVIRONMENT_MAP_OPTIONS` (`{ enabled: false }`, `src/data/aircraftModelLighting.js`) to every drawn model. Otherwise each `Model` renders the sky around it and reads it back from the GPU (`readPixels`) when it is first placed, and again whenever it moves more than 1 km, the scene's atmosphere settings change, or (under sunlight dynamic lighting) an hour of scene time passes (`DynamicEnvironmentMapManager`, Cesium 1.138). The models are lit from Cesium's default spherical harmonics instead, with no specular environment map, so the sky's model-lighting cube map no longer reaches aircraft. `src/data/aircraftModelLighting.test.mjs` pins the option at every drawn model call; every model is built from the fleet set loaded up front, so there is no separate preload. - The DISPLAY-rail `3D` toggle is the user-facing activation path for both aircraft layers. Their small approved GLBs build their render resources without Cesium's frame-spread job queue, preventing continuous Photorealistic 3D Tiles streaming from starving model readiness; model caps, tracking, camera, and fallback billboards are unchanged. - **The `3D` toggle DEFAULTS ON in `proximity` on a first run.** Proximity is itself the budget — models appear only below `MODEL_ALT_CEIL_M` and only for the nearest `MODEL_MAX` in view — so the default costs nothing at globe scale, and `all` remains a deliberate opt-in. A fresh boot runs NO layer-state restoration (`LayerStateCoordinator.start()` returns early with neither a share payload nor stored state), so four independent initializers decide what a first-run operator sees and must agree: `booleanOption('models3d', 'e', true)` in `src/data/layerState.js`, `_models3dEnabled = true` in BOTH flight layers, `this._models3dEnabled = true` in `src/ui/aircraftDisplay.js`, and the `active` / `visible` classes on `#models3d-toggle` / `#models3d-mode-row` in `index.html`. All four are pinned together in `src/data/layerState.test.mjs`. Explicit state still wins: because the codec omits default-valued options, `models3d: false` is now what travels in a link (`lo=…f.e.0`) and restores OFF at both aircraft layers. **Consequence for returning users:** a stored `gev:layer-state:v2` blob is a FULL options snapshot, so a session that wrote one before this change carries `models3d:false` and keeps 3D off until the operator flips it (or clears the key) — the durable snapshot is treated as the recipient's own state, by design. diff --git a/public/models/README.md b/public/models/README.md index 49d22b4c9..3f97820d3 100644 --- a/public/models/README.md +++ b/public/models/README.md @@ -19,6 +19,12 @@ How the layers use them: type's published length (a vessel to its reported AIS length and beam), so every model is drawn life size. Ground objects, balloons and obstacles in the `other` category are drawn at the size they are built. +- An aid to navigation (a vessel record whose type names a buoy, beacon, IALA + mark, RACON or light, or whose MMSI is an aid station's `99MIDxxxx`) is + drawn as the `buoys` model of its mark (cardinal north, east, south or west, + port or starboard hand, safe water, isolated danger, special mark), a red + can when its type names no mark, at its built size and with no heading + (`vesselModelSpec`, `aidToNavigationModel`). - An aircraft model's origin is its axis; it stands that model's scaled clearance above the ground. A ship's origin is its waterline, and a transit or rail vehicle's the road or rail top (a monorail or gondola is raised by diff --git a/scripts/package-boundaries.json b/scripts/package-boundaries.json index 541968ed7..2242d7b2c 100644 --- a/scripts/package-boundaries.json +++ b/scripts/package-boundaries.json @@ -251,6 +251,7 @@ "src/data/adsbLolFallback.js", "src/data/aisStreamAdapter.js", "src/data/aisWatchdog.js", + "src/data/vesselTypes.js", "src/sources/httpBody.js", "src/i18n/marker.js", "server/providers/acartia.js", @@ -1514,6 +1515,7 @@ "exports": ["./layers/flights"], "modules": [ "src/data/fleetModels.js", + "src/data/vesselTypes.js", "src/data/fleetTrailAnchors.js", "src/data/fleetModelInstances.js", "src/data/headingDegrees.js", @@ -1593,6 +1595,7 @@ "src/layers/flights/modelSpec.js", "src/layers/flights/policy.js", "src/data/fleetModels.js", + "src/data/vesselTypes.js", "src/data/fleetTrailAnchors.js", "src/data/fleetModelInstances.js", "src/data/headingDegrees.js", @@ -4817,6 +4820,7 @@ "src/data/aircraftClass.js", "src/data/aircraftEmergency.js", "src/data/fleetModels.js", + "src/data/vesselTypes.js", "src/data/fleetTrailAnchors.js" ], "external": [] @@ -5207,6 +5211,7 @@ "exports": ["./layers/transit/standalone"], "modules": [ "src/data/fleetModels.js", + "src/data/vesselTypes.js", "src/data/aircraftClass.js", "src/i18n/marker.js", "src/data/fleetModelInstances.js", @@ -5299,6 +5304,7 @@ "modules": [ "src/i18n/marker.js", "src/data/fleetModels.js", + "src/data/vesselTypes.js", "src/data/fleetModelInstances.js", "src/data/aircraftClass.js", "src/data/aircraftModelLighting.js", diff --git a/server/providers/vessels/ais-live.js b/server/providers/vessels/ais-live.js index cb1dd36b0..e525763ef 100644 --- a/server/providers/vessels/ais-live.js +++ b/server/providers/vessels/ais-live.js @@ -27,6 +27,8 @@ const AISSTREAM_DEFAULT_MESSAGE_TYPES = [ 'ExtendedClassBPositionReport', 'ShipStaticData', 'StaticDataReport', + // Buoys, beacons and other aids to navigation (AIS message 21). + 'AidsToNavigationReport', ]; // Watchdog budgets (policy lives in src/data/aisWatchdog.js). Silence is // REPORTED quickly and ACTED ON slowly: a dead feed must read as dead within diff --git a/server/providers/vessels/ais-store.js b/server/providers/vessels/ais-store.js index c18a43d85..d3c38059e 100644 --- a/server/providers/vessels/ais-store.js +++ b/server/providers/vessels/ais-store.js @@ -1,4 +1,5 @@ import { isRecognizedAisEnvelope } from '../../../src/data/aisStreamAdapter.js'; +import { aidToNavigationTypeName } from '../../../src/data/vesselTypes.js'; export const AISSTREAM_CACHE_MAX = 50000; export const AISSTREAM_STALE_MS = 30 * 60 * 1000; // Per-MMSI recent-path ring buffers (PRD WS-F F3). Float32 lat/lon (~1m @@ -118,7 +119,12 @@ export function ingestAisStreamEnvelope(envelope) { name: vesselNameFromAis(metadata, message, staticData) || `MMSI ${mmsi}`, mmsi, imo: stringValue(message.ImoNumber ?? message.IMO ?? staticData.imo), - type: vesselTypeFromAis(message, staticData), + // An aid-to-navigation report's type is the kind of aid (0 to 31), not + // a ship type: it is carried as the aid's name ("Cardinal Mark N"). + type: + messageType === 'AidsToNavigationReport' + ? aidToNavigationTypeName(message.Type) + : vesselTypeFromAis(message, staticData), destination: stringValue(message.Destination ?? staticData.destination), length: staticData.length ?? null, beam: staticData.beam ?? null, diff --git a/src/data/aisStreamSentinels.test.mjs b/src/data/aisStreamSentinels.test.mjs index 93569fc97..9890a4277 100644 --- a/src/data/aisStreamSentinels.test.mjs +++ b/src/data/aisStreamSentinels.test.mjs @@ -316,3 +316,29 @@ test('a Class B report carries its dimensions in part B', () => { assert.equal(row.length, 12); assert.equal(row.beam, 4); }); + +test('an aid-to-navigation report is a row named by its kind of aid, not a ship type', () => { + assert.equal( + ingestAisStreamEnvelope({ + MessageType: 'AidsToNavigationReport', + Message: { + AidsToNavigationReport: { + UserID: 993672001, + Type: 20, + Name: 'SF APPROACH N', + }, + }, + MetaData: { + MMSI: '993672001', + latitude: 37.79, + longitude: -122.52, + time_utc: '2026-09-17 20:00:00.000000000 +0000 UTC', + }, + }), + true, + ); + const row = rowFor('993672001'); + assert.equal(row.type, 'Cardinal Mark N'); + assert.equal(row.name, 'SF APPROACH N'); + assert.equal(row.speed, null); +}); diff --git a/src/data/fleetModels.js b/src/data/fleetModels.js index 6b436bae6..6c4081324 100644 --- a/src/data/fleetModels.js +++ b/src/data/fleetModels.js @@ -11,6 +11,9 @@ * vehicle's road or rail top), and is drawn life size: a type's published * length over the model's built length is its scale. * + * An aid to navigation (a buoy, beacon, mark, RACON or light) is drawn as + * the set's buoy of its IALA mark, by the mark its type names. + * * The resolvers are plain functions over the parsed JSON; `loadFleetModelSet` * fetches the JSON and every GLB once, up front, so no model is fetched * mid-session. @@ -18,6 +21,7 @@ import { classifyAircraft } from './aircraftClass.js'; import { FLEET_TRAIL_ANCHORS } from './fleetTrailAnchors.js'; +import { isAidToNavigation } from './vesselTypes.js'; /** Where the model set is served, relative to the application base. */ export const FLEET_MODEL_BASE = '/models/fleet/'; @@ -84,6 +88,44 @@ const TEXT_SHIP_TYPES = [ [/pleasure|yacht/i, 37], ]; +/** + * The buoy an aid to navigation is drawn as, by the mark its type names + * ("Cardinal Mark N", "Beacon, Port hand", "Safe Water"): the first pattern + * that matches. Beacons, lights, RACONs and reference points with no mark of + * their own are the special mark. + */ +const AID_MODELS = [ + [/cardinal\b.*\bn(orth)?$/i, 'buoy_cardinal_north'], + [/cardinal\b.*\be(ast)?$/i, 'buoy_cardinal_east'], + [/cardinal\b.*\bs(outh)?$/i, 'buoy_cardinal_south'], + [/cardinal\b.*\bw(est)?$/i, 'buoy_cardinal_west'], + [/isolated danger/i, 'buoy_isolated_danger'], + [/safe water/i, 'buoy_safe_water'], + [/port hand/i, 'buoy_lateral_port'], + [/starboard hand/i, 'buoy_lateral_starboard'], + [/special mark|light vessel|lanby/i, 'buoy_special'], + [ + /^(beacon|light\b|leading light|racon|reference point|navigation aid)/i, + 'buoy_special', + ], +]; + +/** The buoy an aid to navigation whose type names no mark is drawn as. */ +export const DEFAULT_AID_MODEL = 'can_red'; + +/** + * The buoy model of an aid to navigation's type, else undefined when the + * type names no mark. + * @param {string|null} [type] + * @returns {string|undefined} + */ +export function aidToNavigationModel(type) { + const text = String(type ?? '').trim(); + for (const [pattern, model] of AID_MODELS) + if (pattern.test(text)) return model; + return undefined; +} + /** * The model for an aircraft of ICAO type `type` (A320, B738, R44), ADS-B * emitter category `category` and callsign `callsign`: the first of the @@ -397,13 +439,26 @@ export function aircraftModelSpec( /** * The model a vessel is drawn with, from its AIS ship type (a code or a text - * family), reported length and beam (metres) and name. + * family), reported length and beam (metres) and name. An aid to navigation + * ({@link isAidToNavigation}: its type names a buoy, beacon, mark, RACON or + * light, or its MMSI is an aid's) is the buoy of its mark + * ({@link aidToNavigationModel}), else {@link DEFAULT_AID_MODEL}, drawn as + * built and flagged `fixed`: it has no heading to turn to. * @param {{catalog: object, types: object}} set - * @param {{type?: string|number|null, length?: number|null, - * beam?: number|null, name?: string|null}} vessel - * @returns {object} {@link fleetModelSpec} + * @param {{type?: string|number|null, mmsi?: string|number|null, + * length?: number|null, beam?: number|null, name?: string|null}} vessel + * @returns {object} {@link fleetModelSpec}, with `fixed` for an aid */ -export function vesselModelSpec(set, { type, length, beam, name } = {}) { +export function vesselModelSpec(set, { type, mmsi, length, beam, name } = {}) { + if (isAidToNavigation({ type, mmsi })) { + const model = aidToNavigationModel(type); + const known = model && set.catalog[model] ? model : DEFAULT_AID_MODEL; + if (set.catalog[known]) + return Object.freeze({ + ...fleetModelSpec(set, known, null), + fixed: true, + }); + } // A beam counts only beside a reported length: a vessel drawn at its type's // typical length keeps the model's proportions. const reported = hullLength(length ?? undefined); @@ -460,6 +515,8 @@ export function namedFleetModels(types) { transit.default[0], ...Object.keys(transit.elevation), ...Object.values(CLASS_MODELS), + ...AID_MODELS.map(([, model]) => model), + DEFAULT_AID_MODEL, ]); } diff --git a/src/data/fleetModels.test.mjs b/src/data/fleetModels.test.mjs index f9ef47bc6..66ff49f3a 100644 --- a/src/data/fleetModels.test.mjs +++ b/src/data/fleetModels.test.mjs @@ -4,7 +4,9 @@ import fs from 'node:fs'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; import { + DEFAULT_AID_MODEL, FLEET_MODEL_BASE, + aidToNavigationModel, aircraftModelSpec, aisShipTypeCode, emitterCategory, @@ -381,6 +383,58 @@ test('vessel specs read AIS codes and text families, stretched to the reported b assert.equal(unknown.scale, 1); }); +test('aids to navigation are the buoy of the mark their type names', () => { + const cases = [ + ['Cardinal Mark N', 'buoy_cardinal_north'], + ['Beacon, Cardinal E', 'buoy_cardinal_east'], + ['Cardinal Mark S', 'buoy_cardinal_south'], + ['Beacon, Cardinal W', 'buoy_cardinal_west'], + ['Port Hand Mark', 'buoy_lateral_port'], + ['Beacon, Port hand', 'buoy_lateral_port'], + ['Starboard Hand Mark', 'buoy_lateral_starboard'], + ['Preferred Channel Starboard hand', 'buoy_lateral_starboard'], + ['Safe Water', 'buoy_safe_water'], + ['Isolated danger', 'buoy_isolated_danger'], + ['Beacon, Special Mark', 'buoy_special'], + ['Special Mark', 'buoy_special'], + ['Light Vessel / LANBY / Rigs', 'buoy_special'], + ['RACON', 'buoy_special'], + ['Light, with Sectors', 'buoy_special'], + ['Reference point', 'buoy_special'], + ['Navigation aid', 'buoy_special'], + ]; + for (const [type, model] of cases) { + assert.equal(aidToNavigationModel(type), model, type); + assert.ok(catalog[model], model); + const spec = vesselModelSpec(set, { type, mmsi: '993672001' }); + assert.equal(spec.model, model, type); + assert.equal(spec.category, 'buoys', type); + assert.equal(spec.fixed, true, type); + // A buoy is drawn as built, whatever length the report gives. + assert.equal(spec.scale, 1, type); + } + assert.equal( + vesselModelSpec(set, { type: 'Safe Water', length: 120, beam: 30 }).scale, + 1, + ); + // An aid of no stated kind, known only by its MMSI, is the default can. + assert.ok(catalog[DEFAULT_AID_MODEL]); + const unnamed = vesselModelSpec(set, { type: '', mmsi: '993660123' }); + assert.equal(unnamed.model, DEFAULT_AID_MODEL); + assert.equal(unnamed.fixed, true); + assert.equal(aidToNavigationModel('Fixed structure off shore'), undefined); + // Vessels, including those that work on buoys, keep their hulls. + for (const vessel of [ + { type: 'Buoy Tender', mmsi: '366999001', length: 60 }, + { type: '70', mmsi: '366999002' }, + { type: 'Tug', mmsi: '' }, + ]) { + const spec = vesselModelSpec(set, vessel); + assert.notEqual(spec.category, 'buoys', vessel.type); + assert.equal(spec.fixed, undefined, vessel.type); + } +}); + test('transit specs: rail category and mode, then route type, then mode, then the default', () => { assert.deepEqual(resolveTransit(types, { railCategory: 'national' }), { model: 'intercity', diff --git a/src/data/vesselTypes.js b/src/data/vesselTypes.js index 550f4596b..addaf8572 100644 --- a/src/data/vesselTypes.js +++ b/src/data/vesselTypes.js @@ -45,3 +45,82 @@ export function normalizeVesselType(type) { if (NUMERIC_TYPE_SPECIALS[code]) return NUMERIC_TYPE_SPECIALS[code]; return NUMERIC_TYPE_FAMILIES[Math.floor(code / 10)] || 'OTHER'; } + +/** + * The kind of aid to navigation an AIS aid-to-navigation report (message 21) + * names by its type code, 0 to 31 (ITU-R M.1371, IALA marks): beacons and + * floating marks by their cardinal quadrant, lateral side, safe water, + * isolated danger or special mark, and the lights, RACONs and reference + * points around them. Code 0 names no kind. + */ +const AID_TYPE_NAMES = Object.freeze([ + 'Navigation aid', + 'Reference point', + 'RACON', + 'Fixed structure off shore', + 'Emergency wreck marking buoy', + 'Light, without sectors', + 'Light, with sectors', + 'Leading light front', + 'Leading light rear', + 'Beacon, Cardinal N', + 'Beacon, Cardinal E', + 'Beacon, Cardinal S', + 'Beacon, Cardinal W', + 'Beacon, Port hand', + 'Beacon, Starboard hand', + 'Beacon, Preferred channel port hand', + 'Beacon, Preferred channel starboard hand', + 'Beacon, Isolated danger', + 'Beacon, Safe water', + 'Beacon, Special mark', + 'Cardinal Mark N', + 'Cardinal Mark E', + 'Cardinal Mark S', + 'Cardinal Mark W', + 'Port hand Mark', + 'Starboard hand Mark', + 'Preferred Channel Port hand', + 'Preferred Channel Starboard hand', + 'Isolated danger', + 'Safe Water', + 'Special Mark', + 'Light Vessel / LANBY / Rigs', +]); + +/** + * The kind an AIS aid-to-navigation type code names ("19" → "Beacon, Special + * mark"); "Navigation aid" for code 0 and for a code outside 0 to 31. + * @param {string|number|null|undefined} code + * @returns {string} + */ +export function aidToNavigationTypeName(code) { + const text = String(code ?? '').trim(); + const index = /^\d+$/.test(text) ? Number(text) : -1; + return AID_TYPE_NAMES[index] ?? AID_TYPE_NAMES[0]; +} + +/** + * Words a vessel type uses for an aid to navigation. A vessel that works on + * one ("Buoy Tender", "Buoy-Laying Vessel") is a ship underway, not a mark on + * the water. + */ +const AID_TYPE_TEXT = + /navaid|\baton\b|aids? to nav|nav(igation)? aid|racon|lighthouse|lightship|light vessel|reference point|hand mark|cardinal|safe water|preferred channel|isolated danger|special mark|beacon|buoy/i; +const AID_WORKER_TEXT = /tender|laying/i; + +/** ITU MID 99: the MMSI of an AIS aid-to-navigation station (99MIDxxxx). */ +const AID_MMSI = /^99\d{7}$/; + +/** + * Whether a vessel record is an aid to navigation (a buoy, beacon, mark, + * RACON or light) rather than a vessel: its type names one, or its MMSI is + * an aid-to-navigation station's. A numeric AIS ship type never names one. + * @param {{type?: string|number|null, mmsi?: string|number|null}} vessel + * @returns {boolean} + */ +export function isAidToNavigation({ type, mmsi } = {}) { + const text = String(type ?? '').trim(); + if (AID_TYPE_TEXT.test(text) && !AID_WORKER_TEXT.test(text)) return true; + return AID_MMSI.test(String(mmsi ?? '').trim()); +} diff --git a/src/data/vesselTypes.test.mjs b/src/data/vesselTypes.test.mjs new file mode 100644 index 000000000..ee8f1d511 --- /dev/null +++ b/src/data/vesselTypes.test.mjs @@ -0,0 +1,47 @@ +import test from 'node:test'; +import assert from 'node:assert/strict'; +import { aidToNavigationTypeName, isAidToNavigation } from './vesselTypes.js'; + +test('an aid-to-navigation type code names its kind of aid', () => { + assert.equal(aidToNavigationTypeName(20), 'Cardinal Mark N'); + assert.equal(aidToNavigationTypeName('13'), 'Beacon, Port hand'); + assert.equal(aidToNavigationTypeName(2), 'RACON'); + assert.equal(aidToNavigationTypeName(29), 'Safe Water'); + assert.equal(aidToNavigationTypeName(31), 'Light Vessel / LANBY / Rigs'); + // Code 0, a code past 31 and no code name no kind. + for (const code of [0, 32, -1, '', null, undefined, 'x']) + assert.equal(aidToNavigationTypeName(code), 'Navigation aid', code); +}); + +test('aids to navigation are known by their type, else their MMSI', () => { + for (const type of [ + 'Beacon, Special Mark', + 'Cardinal Mark N', + 'Port Hand Mark', + 'Starboard Hand Mark', + 'Safe Water', + 'Isolated danger', + 'Preferred Channel Port hand', + 'RACON', + 'Light Vessel / LANBY / Rigs', + 'Reference point', + 'Navigation aid', + 'AtoN', + 'Lighthouse', + 'Buoy', + ]) + assert.equal(isAidToNavigation({ type, mmsi: '' }), true, type); + // AIS aid-to-navigation stations are numbered 99MIDxxxx. + assert.equal(isAidToNavigation({ type: '', mmsi: '993672001' }), true); + assert.equal(isAidToNavigation({ type: '0', mmsi: ' 992351234 ' }), true); + for (const vessel of [ + { type: 'Buoy Tender', mmsi: '366999001' }, + { type: 'Buoy-Laying Vessel', mmsi: '' }, + { type: '70', mmsi: '366999002' }, + { type: '0', mmsi: '' }, + { type: 'Cargo', mmsi: '99' }, + { type: 'Passenger', mmsi: '9936720011' }, + {}, + ]) + assert.equal(isAidToNavigation(vessel), false, JSON.stringify(vessel)); +}); diff --git a/src/layers/vessels/ownership.test.mjs b/src/layers/vessels/ownership.test.mjs index 92c4ec493..643991e9f 100644 --- a/src/layers/vessels/ownership.test.mjs +++ b/src/layers/vessels/ownership.test.mjs @@ -515,3 +515,27 @@ test('AIS feed rows stay keyed by their MMSI', async () => { ['235000001', '235000001'], ); }); + +test('an aid to navigation is drawn as a disc, a vessel as its chevron', async () => { + const aid = { + ...observation('993672001'), + mmsi: '993672001', + type: 'Port Hand Mark', + speedMps: 0, + }; + const ship = { ...observation('366999002'), type: 'Cargo' }; + const { layer, primitives } = setup({ + async getSnapshot() { + return snapshot([aid, ship]); + }, + }); + await layer.update(); + const svgOf = (id) => { + const primitive = [...primitives].find((p) => p.id?.id === id); + assert.ok(primitive, id); + return atob(primitive.image.split(',')[1]); + }; + assert.match(svgOf('993672001'), / + ` + : ``; const svg = ` - + ${shape} `; const icon = 'data:image/svg+xml;base64,' + btoa(svg); @@ -265,13 +281,14 @@ export function createRendering({ let item = modelItems.get(record.id); if (!item || item.record !== record) item = { record, pickId: record, tint: null, modelOwnsVisual: false }; - const specKey = `${record.type}|${record.length}|${record.beam}|${record.name}`; + const specKey = `${record.type}|${record.mmsi}|${record.length}|${record.beam}|${record.name}`; if (item.specKey !== specKey) { item.specKey = specKey; item.spec = vesselModelSpec(set, record); } item.position = getVisual(record).waterline; - item.headingDeg = vesselCourseDeg(record); + // An aid to navigation is a fixed mark: it does not turn to a heading. + item.headingDeg = item.spec?.fixed ? 0 : vesselCourseDeg(record); item.show = record.id !== state.cockpitSubjectId; return item; } From 6c7fe48f40efbd1320d5bb344f328c21b4d5aab4 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Sat, 14 Nov 2026 10:02:59 -0800 Subject: [PATCH 02/30] Show an aid to navigation's kind, not a speed or heading MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A buoy's card, selected card and HUD readout showed "0.0KT · 135°" from whatever its source reported. A fixed mark has neither, so they now show its kind alone, whole ("CARDINAL MARK N", which the 14-character type cut read as "CARDINAL MARK "), in the bone white of its disc. isAidToNavigation now knows every kind an aid report names ("Light, with sectors", "Fixed structure off shore" had no aid word), leaves out a "Buoy Layer" as it does a tender, and matches each type text once: the vessel layer asks per vessel on its rotation pass, which now skips the aid discs it never turns. Aid rows no longer cost ships their place: aisStreamRows lists every vessel ahead of every aid, so the layer's 12,000-row request never drops a ship for a buoy, and vessels_in_area (and the brief built on it) counts ships only. An aid's name runs on into its NameExtension. --- changelog.d/0000-buoy-models.md | 8 ++-- docs/CURRENT-STATE.md | 2 +- server/providers/vessels/ais-store.js | 46 ++++++++++++++----- src/data/aisLiveVessels.test.mjs | 38 ++++++++++++++++ src/data/aisStreamSentinels.test.mjs | 46 +++++++++++++++++++ src/data/vesselLabels.js | 9 ++++ src/data/vesselTypes.js | 42 +++++++++++++---- src/data/vesselTypes.test.mjs | 9 ++++ src/i18n/locales/ar.json | 1 + src/i18n/locales/de.json | 1 + src/i18n/locales/es.json | 1 + src/i18n/locales/fr.json | 1 + src/i18n/locales/he.json | 1 + src/i18n/locales/it.json | 1 + src/i18n/locales/ja.json | 1 + src/i18n/locales/pt.json | 1 + src/i18n/locales/ru.json | 1 + src/i18n/locales/sv.json | 1 + src/i18n/locales/uk.json | 1 + src/i18n/locales/zh-CN.json | 1 + src/i18n/locales/zh-Hant.json | 1 + src/layers/vessels/cards.js | 65 ++++++++++++++++++--------- src/layers/vessels/rendering.js | 9 ++-- src/tools/queries/maritime.js | 10 ++++- src/tools/queries/maritime.test.mjs | 41 +++++++++++++++++ 25 files changed, 289 insertions(+), 49 deletions(-) diff --git a/changelog.d/0000-buoy-models.md b/changelog.d/0000-buoy-models.md index a41fd3957..656a93374 100644 --- a/changelog.d/0000-buoy-models.md +++ b/changelog.d/0000-buoy-models.md @@ -2,6 +2,8 @@ light or mark from the vessel feed (or any AIS station numbered 99MIDxxxx) is now the fleet set's buoy of its IALA mark (cardinal, port or starboard hand, safe water, isolated danger or special mark), standing still with no - heading, and its icon is a disc rather than a chevron. AISStream now - subscribes to aid-to-navigation reports and names each by its kind of mark - (samehkhamis, #0000). + heading, and its icon is a disc rather than a chevron. Its card and readout + show its kind of mark with no speed or heading. AISStream now subscribes to + aid-to-navigation reports and names each by its kind of mark and its full + name; the feed lists every ship ahead of any aid, and `vessels_in_area` + counts ships only (samehkhamis, #0000). diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md index 74a9fd50e..0b301991b 100644 --- a/docs/CURRENT-STATE.md +++ b/docs/CURRENT-STATE.md @@ -7430,7 +7430,7 @@ pins and share links already supply complete boxes. 30-second backoff ahead of the current clock are ignored. A smaller rollback can retain a bounded retry delay of up to 30 seconds. - Commercial and military aircraft use the same high-level FLEET model regime: 2D billboards when zoomed out, optional glTF models when closer, controlled by the DISPLAY rail `3D` toggle and `Proximity` / `All` modes. Every model is one of the project's procedural fleet models (`public/models/fleet/`, MIT, 122 GLBs, about 2 MB in all; `public/models/README.md`), chosen per aircraft by `aircraftModelSpec` (`src/data/fleetModels.js`): the first of its ICAO type's callsign rules in `types.json` (`aircraft_callsign`) its callsign matches, else its type's entry, else the model of its `classifyAircraft` class for a type the map lacks, else its ADS-B emitter category's, else the default airliner. It is drawn LIFE SIZE: the type's published length over the model's built length (`src/layers/flights/modelSpec.js`, shared by Flights, Military Flights and Local ADS-B), and a grounded aircraft stands the model's scaled clearance above the ground. An airport ground vehicle (feed type `ZVEH`) is a fire truck (`FIRE…`), pushback tug (`PUSH…`, `TUG…`), van (`DEICER…`, `SQUID…`, `SQB…`) or else a car by its callsign, and a ground station (`GRND`) is an 11.8 m radio mast; these models (catalog category `other`) are drawn at their built size, and such a contact with no altitude stands on the ground instead of at the airborne default (`src/layers/flights/records.js`). `classifyAircraft` still picks the 2D icons. The whole set loads once, up front, when a layer that draws it starts (`loadFleetModelSet`, which logs `[Fleet] N/122 models (X MB) loaded in N ms`); models are built from those bytes, never fetched mid-session, and an aircraft stays its billboard until the set has loaded. Every aircraft model draws its mesh's own colours (`aircraftModelBlend`, `src/data/aircraftModelLighting.js`): Cesium's `ColorBlendMode.HIGHLIGHT` with white, in Flights, Military Flights and Local ADS-B alike; the tracked colour (cyan, or amber in Military Flights) and the emergency red multiply into the mesh, so its paint still shows. IR boost draws them flat white (`MIX` at `1.0`). Under NVG/FLIR (map preset or Cockpit vision) models render unlit flat-white at full alpha and scene fog is disabled (fog otherwise blacks out distant models with the globe hidden); state restores on exit. -- Vessels, Transit and Rail draw fleet models under the same DISPLAY rail `3D` toggle, at the same altitude ceiling, caps and add/keep radii as the aircraft (`FLEET_MODEL_POLICY`, `src/layers/flights/policy.js`; `createFleetModelLayer`, `src/data/fleetModelInstances.js`). A vessel's model follows its AIS ship type and is drawn at its reported length and beam (AIS static dimensions A+B and C+D, now carried on vessel rows as `length` and `beam`), standing at the sea surface, heading by true heading then course. An aid to navigation is not a hull: a vessel record whose type names a buoy, beacon, mark, RACON or light, or whose MMSI is an aid-to-navigation station's (`99MIDxxxx`), is `isAidToNavigation` (`src/data/vesselTypes.js`) and is drawn as the set's `buoys` model of the IALA mark its type names (`aidToNavigationModel`, `src/data/fleetModels.js`: cardinal N/E/S/W, port or starboard hand, preferred channel by its side, safe water, isolated danger, special mark; a beacon, light, light vessel, RACON or reference point with no mark of its own is the special mark), else a red can (`DEFAULT_AID_MODEL`), at its built size and facing north whatever heading it reports. Its icon is a bone-white ringed disc instead of a chevron, never rotated. AISStream subscribes to `AidsToNavigationReport` (message 21) by default, and the server names each report's aid type code (0 to 31) as its kind (`aidToNavigationTypeName`: `20` is `Cardinal Mark N`) rather than reading it as a ship type. A transit vehicle's model follows its layer mode (bus, tram, subway, rail or ferry; a vehicle of `unknown` mode keeps its icon), a train's its rail category and mode (rail, metro or tram). Neither the transit nor the rail sources carry a GTFS `route_type` or a finer mode (monorail, gondola, funicular, cable car), so the set's models for those and their `transit.elevation` lifts are not reached by any live source today. Both stand on the road or rail top they are drawn on, without the 1.5 m `GROUND_FLOOR_LIFT_M` their icons carry, and are painted in their mode or category colour where the model's `_TINT` attribute marks it. A vessel model is clipped at its waterline (one clipping plane per model, at the model origin's horizontal plane), so its hull below the water never shows through a plain globe, which Cesium does not depth-test models against. Under the NVG/FLIR styles (the Flights `irBoost` parameter) these models render unlit flat white, as aircraft models do. Each vehicle's icon stays the visual until its model is loaded, ready and placed; a model is picked as its icon is, and a vehicle drawn as its model keeps its selection card and its place in the detection overlay. +- Vessels, Transit and Rail draw fleet models under the same DISPLAY rail `3D` toggle, at the same altitude ceiling, caps and add/keep radii as the aircraft (`FLEET_MODEL_POLICY`, `src/layers/flights/policy.js`; `createFleetModelLayer`, `src/data/fleetModelInstances.js`). A vessel's model follows its AIS ship type and is drawn at its reported length and beam (AIS static dimensions A+B and C+D, now carried on vessel rows as `length` and `beam`), standing at the sea surface, heading by true heading then course. An aid to navigation is not a hull: a vessel record whose type names a buoy, beacon, mark, RACON or light, or whose MMSI is an aid-to-navigation station's (`99MIDxxxx`), is `isAidToNavigation` (`src/data/vesselTypes.js`) and is drawn as the set's `buoys` model of the IALA mark its type names (`aidToNavigationModel`, `src/data/fleetModels.js`: cardinal N/E/S/W, port or starboard hand, preferred channel by its side, safe water, isolated danger, special mark; a beacon, light, light vessel, RACON or reference point with no mark of its own is the special mark), else a red can (`DEFAULT_AID_MODEL`), at its built size and facing north whatever heading it reports. A type is an aid's when it is one of the 32 kinds an aid report names or uses a word for one (buoy, beacon, cardinal, safe water, RACON, lighthouse and so on); a vessel that works on aids (`Buoy Tender`, `Buoy Layer`) is not one. Its icon is a bone-white ringed disc (`AID_TO_NAVIGATION_STYLE`, `src/data/vesselLabels.js`) instead of a chevron, never rotated, and its card, selected card and HUD readout (`src/layers/vessels/cards.js`) show its kind alone, whole, in that colour: no speed or heading, since a fixed mark has neither. AISStream subscribes to `AidsToNavigationReport` (message 21) by default, and the server names each report's aid type code (0 to 31) as its kind (`aidToNavigationTypeName`: `20` is `Cardinal Mark N`) rather than reading it as a ship type, and its name runs on into the report's `NameExtension`. `aisStreamRows` (`server/providers/vessels/ais-store.js`) puts every vessel ahead of every aid, so a capped request (the layer asks for 12,000 rows) never gives up a ship for a buoy. The `vessels_in_area` tool (and the brief built on it) counts ships only: it leaves aids out of its rows, counts, breakdowns and speed stats. A transit vehicle's model follows its layer mode (bus, tram, subway, rail or ferry; a vehicle of `unknown` mode keeps its icon), a train's its rail category and mode (rail, metro or tram). Neither the transit nor the rail sources carry a GTFS `route_type` or a finer mode (monorail, gondola, funicular, cable car), so the set's models for those and their `transit.elevation` lifts are not reached by any live source today. Both stand on the road or rail top they are drawn on, without the 1.5 m `GROUND_FLOOR_LIFT_M` their icons carry, and are painted in their mode or category colour where the model's `_TINT` attribute marks it. A vessel model is clipped at its waterline (one clipping plane per model, at the model origin's horizontal plane), so its hull below the water never shows through a plain globe, which Cesium does not depth-test models against. Under the NVG/FLIR styles (the Flights `irBoost` parameter) these models render unlit flat white, as aircraft models do. Each vehicle's icon stays the visual until its model is loaded, ready and placed; a model is picked as its icon is, and a vehicle drawn as its model keeps its selection card and its place in the detection overlay. - **Aircraft models skip Cesium's dynamic environment map (2026-10-24).** Flights, Military Flights and Local ADS-B pass `environmentMapOptions: AIRCRAFT_ENVIRONMENT_MAP_OPTIONS` (`{ enabled: false }`, `src/data/aircraftModelLighting.js`) to every drawn model. Otherwise each `Model` renders the sky around it and reads it back from the GPU (`readPixels`) when it is first placed, and again whenever it moves more than 1 km, the scene's atmosphere settings change, or (under sunlight dynamic lighting) an hour of scene time passes (`DynamicEnvironmentMapManager`, Cesium 1.138). The models are lit from Cesium's default spherical harmonics instead, with no specular environment map, so the sky's model-lighting cube map no longer reaches aircraft. `src/data/aircraftModelLighting.test.mjs` pins the option at every drawn model call; every model is built from the fleet set loaded up front, so there is no separate preload. - The DISPLAY-rail `3D` toggle is the user-facing activation path for both aircraft layers. Their small approved GLBs build their render resources without Cesium's frame-spread job queue, preventing continuous Photorealistic 3D Tiles streaming from starving model readiness; model caps, tracking, camera, and fallback billboards are unchanged. - **The `3D` toggle DEFAULTS ON in `proximity` on a first run.** Proximity is itself the budget — models appear only below `MODEL_ALT_CEIL_M` and only for the nearest `MODEL_MAX` in view — so the default costs nothing at globe scale, and `all` remains a deliberate opt-in. A fresh boot runs NO layer-state restoration (`LayerStateCoordinator.start()` returns early with neither a share payload nor stored state), so four independent initializers decide what a first-run operator sees and must agree: `booleanOption('models3d', 'e', true)` in `src/data/layerState.js`, `_models3dEnabled = true` in BOTH flight layers, `this._models3dEnabled = true` in `src/ui/aircraftDisplay.js`, and the `active` / `visible` classes on `#models3d-toggle` / `#models3d-mode-row` in `index.html`. All four are pinned together in `src/data/layerState.test.mjs`. Explicit state still wins: because the codec omits default-valued options, `models3d: false` is now what travels in a link (`lo=…f.e.0`) and restores OFF at both aircraft layers. **Consequence for returning users:** a stored `gev:layer-state:v2` blob is a FULL options snapshot, so a session that wrote one before this change carries `models3d:false` and keeps 3D off until the operator flips it (or clears the key) — the durable snapshot is treated as the recipient's own state, by design. diff --git a/server/providers/vessels/ais-store.js b/server/providers/vessels/ais-store.js index d3c38059e..e6e8b53d7 100644 --- a/server/providers/vessels/ais-store.js +++ b/server/providers/vessels/ais-store.js @@ -1,5 +1,8 @@ import { isRecognizedAisEnvelope } from '../../../src/data/aisStreamAdapter.js'; -import { aidToNavigationTypeName } from '../../../src/data/vesselTypes.js'; +import { + aidToNavigationTypeName, + isAidToNavigation, +} from '../../../src/data/vesselTypes.js'; export const AISSTREAM_CACHE_MAX = 50000; export const AISSTREAM_STALE_MS = 30 * 60 * 1000; // Per-MMSI recent-path ring buffers (PRD WS-F F3). Float32 lat/lon (~1m @@ -113,18 +116,21 @@ export function ingestAisStreamEnvelope(envelope) { if (!Number.isFinite(lat) || !Number.isFinite(lon)) return true; const staticData = _aisStreamStatic.get(mmsi) || {}; + const aidReport = messageType === 'AidsToNavigationReport'; _aisStreamVessels.set(mmsi, { lat, lon, - name: vesselNameFromAis(metadata, message, staticData) || `MMSI ${mmsi}`, + name: + (aidReport && aidNameFromAis(message)) || + vesselNameFromAis(metadata, message, staticData) || + `MMSI ${mmsi}`, mmsi, imo: stringValue(message.ImoNumber ?? message.IMO ?? staticData.imo), // An aid-to-navigation report's type is the kind of aid (0 to 31), not // a ship type: it is carried as the aid's name ("Cardinal Mark N"). - type: - messageType === 'AidsToNavigationReport' - ? aidToNavigationTypeName(message.Type) - : vesselTypeFromAis(message, staticData), + type: aidReport + ? aidToNavigationTypeName(message.Type) + : vesselTypeFromAis(message, staticData), destination: stringValue(message.Destination ?? staticData.destination), length: staticData.length ?? null, beam: staticData.beam ?? null, @@ -282,6 +288,15 @@ function vesselNameFromAis(metadata, message, staticData = {}) { ); } +/** + * An aid's whole name: an aid-to-navigation report carries the first 20 + * characters in `Name` and the rest, up to 14 more, in `NameExtension`. + */ +function aidNameFromAis(message) { + const name = stringValue(message.Name); + return name ? stringValue(name + stringValue(message.NameExtension)) : ''; +} + function vesselTypeFromAis(message, staticData = {}) { return stringValue( message.Type ?? @@ -291,14 +306,25 @@ function vesselTypeFromAis(message, staticData = {}) { ); } +/** + * The current rows, newest first, with every vessel ahead of every aid to + * navigation: a capped request never gives up a ship for a buoy. + */ export function aisStreamRows(maxRows) { const cutoff = Date.now() - AISSTREAM_STALE_MS; - const rows = []; + const vessels = []; + const aids = []; for (const row of _aisStreamVessels.values()) { - if (row._updatedAt >= cutoff) rows.push(row); + if (row._updatedAt >= cutoff) + (isAidToNavigation(row) ? aids : vessels).push(row); } - rows.sort((a, b) => b._updatedAt - a._updatedAt); - return rows.slice(0, maxRows).map(({ _updatedAt, ...row }) => row); + const newestFirst = (a, b) => b._updatedAt - a._updatedAt; + vessels.sort(newestFirst); + if (vessels.length < maxRows) aids.sort(newestFirst); + return vessels + .concat(aids) + .slice(0, maxRows) + .map(({ _updatedAt, ...row }) => row); } function pruneAisStreamCache() { diff --git a/src/data/aisLiveVessels.test.mjs b/src/data/aisLiveVessels.test.mjs index e427a5412..5cfb68add 100644 --- a/src/data/aisLiveVessels.test.mjs +++ b/src/data/aisLiveVessels.test.mjs @@ -1882,3 +1882,41 @@ test('detection objects name the vessel card their callout gives way to', () => _setVesselStateForTest({ enabled: false }); } }); + +test('an aid to navigation card shows its kind, never a speed or heading', () => { + const aid = makeRecord({ + name: 'SF APPROACH N', + mmsi: '993672001', + type: 'Cardinal Mark N', + speed: 0, + course: 135, + heading: 135, + }); + const card = buildVesselCard(aid); + assert.deepEqual(card.details, ['CARDINAL MARK N']); + assert.equal(card.accent, '217, 210, 192'); + const selected = buildSelectedVesselCard(aid); + assert.equal(selected.details[0], 'CARDINAL MARK N'); + assert.equal(selected.accent, '217, 210, 192'); + // Known only by its MMSI, an aid is named as one. + const unnamed = buildSelectedVesselCard({ ...aid, type: '' }); + assert.equal(unnamed.details[0], 'AID TO NAVIGATION'); + assert.deepEqual(buildVesselCard({ ...aid, type: '' }).details, []); +}); + +test('the HUD of a selected aid to navigation shows no speed or heading', () => { + const harness = installWireHarness(undefined, { selectedRecord: null }); + try { + Object.assign(harness.record, { + type: 'Port hand Mark', + speed: 0, + heading: 135, + course: 135, + }); + assert.equal(aisLiveVesselsLayer.selectById(harness.record.mmsi), true); + assert.match(harness.hud.readout.text, /\nPort hand Mark\n/); + assert.doesNotMatch(harness.hud.readout.text, /SPD|HDG|KT/); + } finally { + harness.cleanup(); + } +}); diff --git a/src/data/aisStreamSentinels.test.mjs b/src/data/aisStreamSentinels.test.mjs index 9890a4277..bb93020c4 100644 --- a/src/data/aisStreamSentinels.test.mjs +++ b/src/data/aisStreamSentinels.test.mjs @@ -342,3 +342,49 @@ test('an aid-to-navigation report is a row named by its kind of aid, not a ship assert.equal(row.name, 'SF APPROACH N'); assert.equal(row.speed, null); }); + +test("an aid's name runs on into its name extension", () => { + ingestAisStreamEnvelope({ + MessageType: 'AidsToNavigationReport', + Message: { + AidsToNavigationReport: { + UserID: 993672002, + Type: 13, + Name: 'SAN FRANCISCO MAIN S', + NameExtension: 'HIP CHANNEL 2', + }, + }, + MetaData: { + MMSI: '993672002', + ShipName: 'SAN FRANCISCO MAIN S', + latitude: 37.79, + longitude: -122.52, + time_utc: '2026-09-17 20:00:00.000000000 +0000 UTC', + }, + }); + assert.equal(rowFor('993672002').name, 'SAN FRANCISCO MAIN SHIP CHANNEL 2'); +}); + +test('a capped row request keeps every vessel ahead of aids to navigation', () => { + // The aid reports last, so it is the newest row. + ingestAisStreamEnvelope(positionReport('244060901', { Sog: 3 })); + ingestAisStreamEnvelope({ + MessageType: 'AidsToNavigationReport', + Message: { AidsToNavigationReport: { UserID: 993672003, Type: 24 } }, + MetaData: { + MMSI: '993672003', + latitude: 37.79, + longitude: -122.52, + time_utc: '2026-09-17 20:00:00.000000000 +0000 UTC', + }, + }); + const rows = aisStreamRows(50000); + const firstAid = rows.findIndex((row) => row.mmsi.startsWith('99')); + const lastVessel = rows.findLastIndex((row) => !row.mmsi.startsWith('99')); + assert.ok(firstAid > lastVessel, `${firstAid} > ${lastVessel}`); + const vesselCount = + rows.length - rows.filter((row) => row.mmsi.startsWith('99')).length; + assert.ok( + aisStreamRows(vesselCount).every((row) => !row.mmsi.startsWith('99')), + ); +}); diff --git a/src/data/vesselLabels.js b/src/data/vesselLabels.js index 0a8a164f7..3a237f53b 100644 --- a/src/data/vesselLabels.js +++ b/src/data/vesselLabels.js @@ -46,6 +46,15 @@ const TYPE_STYLES = [ ]; const DEFAULT_STYLE = { css: '#39d5ff', accent: '57, 213, 255' }; +/** + * An aid to navigation's disc and card accent: a bone white apart from every + * ship type's colour. + */ +export const AID_TO_NAVIGATION_STYLE = Object.freeze({ + css: '#d9d2c0', + accent: '217, 210, 192', +}); + // Card text for the type tokens above. The tokens stay English: TYPE_STYLES // and tests match on them. const TYPE_DISPLAY_KEYS = Object.freeze({ diff --git a/src/data/vesselTypes.js b/src/data/vesselTypes.js index addaf8572..5b9dd22b1 100644 --- a/src/data/vesselTypes.js +++ b/src/data/vesselTypes.js @@ -100,27 +100,53 @@ export function aidToNavigationTypeName(code) { return AID_TYPE_NAMES[index] ?? AID_TYPE_NAMES[0]; } +/** Every kind {@link aidToNavigationTypeName} names, lowercased. */ +const AID_TYPE_NAME_SET = new Set( + AID_TYPE_NAMES.map((name) => name.toLowerCase()), +); + /** * Words a vessel type uses for an aid to navigation. A vessel that works on - * one ("Buoy Tender", "Buoy-Laying Vessel") is a ship underway, not a mark on - * the water. + * one ("Buoy Tender", "Buoy-Laying Vessel", "Buoy Layer") is a ship underway, + * not a mark on the water. */ const AID_TYPE_TEXT = /navaid|\baton\b|aids? to nav|nav(igation)? aid|racon|lighthouse|lightship|light vessel|reference point|hand mark|cardinal|safe water|preferred channel|isolated danger|special mark|beacon|buoy/i; -const AID_WORKER_TEXT = /tender|laying/i; +const AID_WORKER_TEXT = /tender|lay(ing|er)\b/i; /** ITU MID 99: the MMSI of an AIS aid-to-navigation station (99MIDxxxx). */ const AID_MMSI = /^99\d{7}$/; +/** + * Whether each type text seen names an aid. Vessel layers ask per vessel on + * their draw passes, and a feed uses few distinct type texts, so each is + * matched once; the memo is bounded against a feed of free-form types. + */ +const AID_TYPE_MEMO = new Map(); +const AID_TYPE_MEMO_MAX = 1024; + +function typeNamesAid(text) { + let aid = AID_TYPE_MEMO.get(text); + if (aid !== undefined) return aid; + aid = + AID_TYPE_NAME_SET.has(text.toLowerCase()) || + (AID_TYPE_TEXT.test(text) && !AID_WORKER_TEXT.test(text)); + if (AID_TYPE_MEMO.size >= AID_TYPE_MEMO_MAX) AID_TYPE_MEMO.clear(); + AID_TYPE_MEMO.set(text, aid); + return aid; +} + /** * Whether a vessel record is an aid to navigation (a buoy, beacon, mark, - * RACON or light) rather than a vessel: its type names one, or its MMSI is - * an aid-to-navigation station's. A numeric AIS ship type never names one. + * RACON or light) rather than a vessel: its type is one of the kinds an aid + * report names or uses a word for one, or its MMSI is an aid-to-navigation + * station's. A numeric AIS ship type never names one. * @param {{type?: string|number|null, mmsi?: string|number|null}} vessel * @returns {boolean} */ export function isAidToNavigation({ type, mmsi } = {}) { - const text = String(type ?? '').trim(); - if (AID_TYPE_TEXT.test(text) && !AID_WORKER_TEXT.test(text)) return true; - return AID_MMSI.test(String(mmsi ?? '').trim()); + const text = typeof type === 'string' ? type.trim() : String(type ?? ''); + if (text && typeNamesAid(text)) return true; + if (mmsi === null || mmsi === undefined || mmsi === '') return false; + return AID_MMSI.test(typeof mmsi === 'string' ? mmsi.trim() : String(mmsi)); } diff --git a/src/data/vesselTypes.test.mjs b/src/data/vesselTypes.test.mjs index ee8f1d511..3a7e3ca2d 100644 --- a/src/data/vesselTypes.test.mjs +++ b/src/data/vesselTypes.test.mjs @@ -29,6 +29,11 @@ test('aids to navigation are known by their type, else their MMSI', () => { 'AtoN', 'Lighthouse', 'Buoy', + // Every kind an aid report names is an aid, whatever its MMSI. + 'Light, with sectors', + 'Leading light rear', + 'Fixed structure off shore', + 'Emergency wreck marking buoy', ]) assert.equal(isAidToNavigation({ type, mmsi: '' }), true, type); // AIS aid-to-navigation stations are numbered 99MIDxxxx. @@ -37,6 +42,10 @@ test('aids to navigation are known by their type, else their MMSI', () => { for (const vessel of [ { type: 'Buoy Tender', mmsi: '366999001' }, { type: 'Buoy-Laying Vessel', mmsi: '' }, + { type: 'Buoy Layer', mmsi: '' }, + { type: 'Lighter', mmsi: '' }, + { type: 'Flight deck', mmsi: '' }, + { type: 70, mmsi: 366999002 }, { type: '70', mmsi: '366999002' }, { type: '0', mmsi: '' }, { type: 'Cargo', mmsi: '99' }, diff --git a/src/i18n/locales/ar.json b/src/i18n/locales/ar.json index 8adc01b0e..0eeb41a7c 100644 --- a/src/i18n/locales/ar.json +++ b/src/i18n/locales/ar.json @@ -776,6 +776,7 @@ "TANKER": "ناقلة", "OTHER": "أخرى", "VESSEL": "سفينة", + "AID TO NAVIGATION": "مساعدة ملاحية", "POS: LIVE": "الموضع: مباشر", "POS: {time}Z": "الموضع: {time}Z", "AIS: --": "AIS: --", diff --git a/src/i18n/locales/de.json b/src/i18n/locales/de.json index 4753051cc..bc9280d70 100644 --- a/src/i18n/locales/de.json +++ b/src/i18n/locales/de.json @@ -416,6 +416,7 @@ "AIS: {name}": "AIS: {name}", "{type} SPD: {speed} HDG: {heading}": "{type} SPD: {speed} HDG: {heading}", "VESSEL": "SCHIFF", + "AID TO NAVIGATION": "SEEZEICHEN", "POS: LIVE": "POS: LIVE", "POS: {time}Z": "POS: {time}Z", "awaiting first AIS position…": "warten auf erste AIS-Position…", diff --git a/src/i18n/locales/es.json b/src/i18n/locales/es.json index 1c3fd8247..829ac7ea6 100644 --- a/src/i18n/locales/es.json +++ b/src/i18n/locales/es.json @@ -650,6 +650,7 @@ "TANKER": "PETROLERO", "OTHER": "OTRO", "VESSEL": "BUQUE", + "AID TO NAVIGATION": "AYUDA A LA NAVEGACIÓN", "POS: LIVE": "POS: EN VIVO", "POS: {time}Z": "POS: {time}Z", "AIS: --": "AIS: --", diff --git a/src/i18n/locales/fr.json b/src/i18n/locales/fr.json index 23fd088a3..a4d3a831f 100644 --- a/src/i18n/locales/fr.json +++ b/src/i18n/locales/fr.json @@ -1291,6 +1291,7 @@ "AIS: {name}": "AIS : {name}", "{type} SPD: {speed} HDG: {heading}": "{type} SPD : {speed} HDG : {heading}", "VESSEL": "NAVIRE", + "AID TO NAVIGATION": "AIDE À LA NAVIGATION", "{speed}KT": "{speed} ND", "{heading}DEG": "{heading}°", "POS: LIVE": "POS : DIRECT", diff --git a/src/i18n/locales/he.json b/src/i18n/locales/he.json index 2140be34e..f27f4279b 100644 --- a/src/i18n/locales/he.json +++ b/src/i18n/locales/he.json @@ -1149,6 +1149,7 @@ "AIS: {name}": "AIS: {name}", "{type} SPD: {speed} HDG: {heading}": "{type} SPD: {speed} HDG: {heading}", "VESSEL": "אונייה", + "AID TO NAVIGATION": "עזר ניווט", "{speed}KT": "{speed} קשר", "{heading}DEG": "{heading}°", "POS: LIVE": "POS: חי", diff --git a/src/i18n/locales/it.json b/src/i18n/locales/it.json index 6f3fef7dc..9ee245256 100644 --- a/src/i18n/locales/it.json +++ b/src/i18n/locales/it.json @@ -1291,6 +1291,7 @@ "AIS: {name}": "AIS: {name}", "{type} SPD: {speed} HDG: {heading}": "{type} VEL: {speed} HDG: {heading}", "VESSEL": "NAVE", + "AID TO NAVIGATION": "AIUTO ALLA NAVIGAZIONE", "{speed}KT": "{speed}KT", "{heading}DEG": "{heading}°", "POS: LIVE": "POS: LIVE", diff --git a/src/i18n/locales/ja.json b/src/i18n/locales/ja.json index 6aeb580ac..488f7b81e 100644 --- a/src/i18n/locales/ja.json +++ b/src/i18n/locales/ja.json @@ -1253,6 +1253,7 @@ "AIS: {name}": "AIS: {name}", "{type} SPD: {speed} HDG: {heading}": "{type} SPD: {speed} HDG: {heading}", "VESSEL": "船舶", + "AID TO NAVIGATION": "航路標識", "{speed}KT": "{speed} kt", "{heading}DEG": "{heading}°", "POS: LIVE": "POS: ライブ", diff --git a/src/i18n/locales/pt.json b/src/i18n/locales/pt.json index 3cfde1eea..5944dbc6b 100644 --- a/src/i18n/locales/pt.json +++ b/src/i18n/locales/pt.json @@ -1289,6 +1289,7 @@ "AIS: {name}": "AIS: {name}", "{type} SPD: {speed} HDG: {heading}": "{type} SPD: {speed} HDG: {heading}", "VESSEL": "EMBARCAÇÃO", + "AID TO NAVIGATION": "AUXÍLIO À NAVEGAÇÃO", "{speed}KT": "{speed} KT", "{heading}DEG": "{heading}°", "POS: LIVE": "POS: AO VIVO", diff --git a/src/i18n/locales/ru.json b/src/i18n/locales/ru.json index b7f2b42d7..5065907c4 100644 --- a/src/i18n/locales/ru.json +++ b/src/i18n/locales/ru.json @@ -394,6 +394,7 @@ "AIS: {name}": "AIS: {name}", "{type} SPD: {speed} HDG: {heading}": "{type} СКОР: {speed} КУРС: {heading}", "VESSEL": "СУДНО", + "AID TO NAVIGATION": "СРЕДСТВО НАВИГАЦИИ", "AIS: --": "AIS: --", "awaiting first AIS position…": "ожидание первой позиции AIS…", "awaiting usable AIS positions…": "ожидание пригодных позиций AIS…", diff --git a/src/i18n/locales/sv.json b/src/i18n/locales/sv.json index acfd2916d..2eebc0df0 100644 --- a/src/i18n/locales/sv.json +++ b/src/i18n/locales/sv.json @@ -382,6 +382,7 @@ "AIS: {name}": "AIS: {name}", "{type} SPD: {speed} HDG: {heading}": "{type} SPD: {speed} HDG: {heading}", "VESSEL": "FARTYG", + "AID TO NAVIGATION": "SJÖMÄRKE", "POS: LIVE": "POS: LIVE", "POS: {time}Z": "POS: {time}Z", "awaiting first AIS position…": "väntar på första AIS-positionen …", diff --git a/src/i18n/locales/uk.json b/src/i18n/locales/uk.json index 81fb172f5..8face8fd5 100644 --- a/src/i18n/locales/uk.json +++ b/src/i18n/locales/uk.json @@ -1309,6 +1309,7 @@ "AIS: {name}": "AIS: {name}", "{type} SPD: {speed} HDG: {heading}": "{type} ШВИД: {speed} КУРС: {heading}", "VESSEL": "СУДНО", + "AID TO NAVIGATION": "ЗАСІБ НАВІГАЦІЇ", "{speed}KT": "{speed} ВУЗ", "{heading}DEG": "{heading}°", "POS: LIVE": "ПОЗ.: ОНЛАЙН", diff --git a/src/i18n/locales/zh-CN.json b/src/i18n/locales/zh-CN.json index 715c25ace..d8bcb9d63 100644 --- a/src/i18n/locales/zh-CN.json +++ b/src/i18n/locales/zh-CN.json @@ -1229,6 +1229,7 @@ "AIS: {name}": "AIS: {name}", "{type} SPD: {speed} HDG: {heading}": "{type} SPD: {speed} HDG: {heading}", "VESSEL": "船舶", + "AID TO NAVIGATION": "助航标志", "{speed}KT": "{speed} kn", "{heading}DEG": "{heading}°", "POS: LIVE": "POS:实时", diff --git a/src/i18n/locales/zh-Hant.json b/src/i18n/locales/zh-Hant.json index bd2fa477f..cf782e389 100644 --- a/src/i18n/locales/zh-Hant.json +++ b/src/i18n/locales/zh-Hant.json @@ -1224,6 +1224,7 @@ "AIS: {name}": "AIS: {name}", "{type} SPD: {speed} HDG: {heading}": "{type} SPD: {speed} HDG: {heading}", "VESSEL": "船舶", + "AID TO NAVIGATION": "助航標誌", "{speed}KT": "{speed} kn", "{heading}DEG": "{heading}°", "POS: LIVE": "POS:實時", diff --git a/src/layers/vessels/cards.js b/src/layers/vessels/cards.js index 49c0264e2..f8371c372 100644 --- a/src/layers/vessels/cards.js +++ b/src/layers/vessels/cards.js @@ -1,8 +1,10 @@ import { + AID_TO_NAVIGATION_STYLE, accentForVesselType, displayVesselType, normalizeVesselType, } from '../../data/vesselLabels.js'; +import { isAidToNavigation } from '../../data/vesselTypes.js'; import { formatNumber, t } from '../../i18n/index.js'; import { roundHeadingDegrees } from '../../data/headingDegrees.js'; @@ -16,14 +18,18 @@ export function createCards({ function updateSelectedVesselHud(record) { // Pinned vessels missing from recent refreshes get a stale marker const stale = (record.missedRefreshes || 0) > 0; + // An aid to navigation is a fixed mark: it has no speed or heading to show. + const aid = isAidToNavigation(record); services.readouts?.presentSelectedVessel({ text: [ t('AIS: {name}', { name: trimHudValue(record.name, 32) }), - t('{type} SPD: {speed} HDG: {heading}', { - type: trimHudValue(record.type || t('VESSEL'), 24), - speed: formatSpeed(record.speed), - heading: formatHeading(record.heading ?? record.course), - }), + aid + ? trimHudValue(record.type || t('AID TO NAVIGATION'), 24) + : t('{type} SPD: {speed} HDG: {heading}', { + type: trimHudValue(record.type || t('VESSEL'), 24), + speed: formatSpeed(record.speed), + heading: formatHeading(record.heading ?? record.course), + }), `MMSI: ${record.mmsi || '--'} ${formatPositionTime(record)}${stale ? ` · ${t('STALE')}` : ''}`, ].join('\n'), }); @@ -43,20 +49,21 @@ export function createCards({ /** * Card model for an ambient (decluttered-in) vessel — name title plus one * compact type/speed/heading detail line, anchored at the record's current - * rendered position (height-datum caveat: no datum work here). Pure — - * exported for unit tests. + * rendered position (height-datum caveat: no datum work here). An aid to + * navigation's line is its kind alone. Pure — exported for unit tests. * @param {Object} record - Vessel record. * @returns {Object} vesselLabels entry. */ function buildVesselCard(record) { const parts = []; + const aid = isAidToNavigation(record); const type = vesselTypeShort(record); if (type) parts.push(type); - if (record.speed !== null && record.speed !== undefined) + if (!aid && record.speed !== null && record.speed !== undefined) parts.push(formatSpeed(record.speed)); const direction = record.heading ?? record.course; - if (Number.isFinite(direction)) + if (!aid && Number.isFinite(direction)) parts.push(`${roundHeadingDegrees(direction)}°`); return { id: vesselOverlayEntryId(record), @@ -65,7 +72,7 @@ export function createCards({ components.rendering.getVisual(record).billboard?.position || components.rendering.getVisual(record).position, gapPx: 10, - accent: accentForVesselType(record.type), + accent: vesselAccent(record, aid), title: trimHudValue(displayVesselName(record), 26), details: parts.length ? [parts.join(' · ')] : [], selected: false, @@ -76,22 +83,26 @@ export function createCards({ /** * Card model for the click-selected vessel — the full-detail card, drawn last * (on top) and never distance-faded by the overlay. Pinned-but-vanished - * vessels carry a STALE marker (mirrors the HUD readout). Pure — exported - * for unit tests. + * vessels carry a STALE marker (mirrors the HUD readout). An aid to + * navigation shows its kind with no speed or heading. Pure — exported for + * unit tests. * @param {Object} record - Selected vessel record. * @returns {Object} vesselLabels entry. */ function buildSelectedVesselCard(record) { + const aid = isAidToNavigation(record); const direction = record.heading ?? record.course; const details = [ - [ - vesselTypeShort(record) || t('VESSEL'), - formatSpeed(record.speed), - Number.isFinite(direction) - ? `${roundHeadingDegrees(direction)}°` - : '--°', - ].join(' · '), + aid + ? vesselTypeShort(record) || t('AID TO NAVIGATION') + : [ + vesselTypeShort(record) || t('VESSEL'), + formatSpeed(record.speed), + Number.isFinite(direction) + ? `${roundHeadingDegrees(direction)}°` + : '--°', + ].join(' · '), ]; const destination = String(record.destination || '').trim(); if (destination) details.push(`→ ${trimHudValue(destination, 24)}`); @@ -106,7 +117,7 @@ export function createCards({ components.rendering.getVisual(record).billboard?.position || components.rendering.getVisual(record).position, gapPx: 12, - accent: accentForVesselType(record.type), + accent: vesselAccent(record, aid), title: trimHudValue(displayVesselName(record), 32), details, selected: true, @@ -114,6 +125,14 @@ export function createCards({ }; } + /** A card's accent: an aid's disc colour, else its ship type's. */ + + function vesselAccent(record, aid) { + return aid + ? AID_TO_NAVIGATION_STYLE.accent + : accentForVesselType(record.type); + } + /** Stable overlay identity for keyed and source-retained unkeyed rows. */ function vesselOverlayEntryId(record) { @@ -129,9 +148,15 @@ export function createCards({ * Uppercased AIS type for the card (empty string when unknown). Free feed * text is bounded to the card width; a translated type token is a short * catalog word and shows whole, never cut mid-word ("AUXILIAR DE PUERTO"). + * An aid's kind is the whole line, so it keeps the room speed and heading + * would take ("CARDINAL MARK N", not "CARDINAL MARK "). */ function vesselTypeShort(record) { + if (isAidToNavigation(record)) { + const kind = String(record.type || '').trim(); + return kind ? trimHudValue(kind.toUpperCase(), 26) : ''; + } const feedType = normalizeVesselType(record.type); const shown = displayVesselType(record.type); return shown === feedType diff --git a/src/layers/vessels/rendering.js b/src/layers/vessels/rendering.js index 66e4b7cd8..b2c45bedf 100644 --- a/src/layers/vessels/rendering.js +++ b/src/layers/vessels/rendering.js @@ -1,6 +1,7 @@ import * as Cesium from 'cesium'; import { t } from '../../i18n/index.js'; import { + AID_TO_NAVIGATION_STYLE, vesselTypeCss, vesselOverlayCohortLimit, VESSEL_OVERLAY_SOURCE_ID, @@ -30,9 +31,6 @@ import { import { createFleetModelLayer } from '../../data/fleetModelInstances.js'; import { isAidToNavigation } from '../../data/vesselTypes.js'; -/** An aid to navigation's disc: a bone white apart from every ship type's colour. */ -const AID_ICON_CSS = '#d9d2c0'; - /** How often vessels move on as the world clock plays (wall ms). */ const FOLLOW_POSITION_MS = 250; @@ -213,7 +211,7 @@ export function createRendering({ const cssColor = selected ? '#ffffff' : aid - ? AID_ICON_CSS + ? AID_TO_NAVIGATION_STYLE.css : vesselTypeCss(record.type); const key = `${cssColor}:${selected ? 'selected' : 'normal'}:${aid ? 'aid' : 'ship'}`; if (vesselState.shipIconCache.has(key)) @@ -482,7 +480,8 @@ export function createRendering({ visible && record.id !== state.cockpitSubjectId && !visual.modelOwnsVisual; - if (visible && doRotations && scene) { + // An aid's disc is never turned (vesselCourseDeg). + if (visible && doRotations && scene && !isAidToNavigation(record)) { const rot = screenProjectedRotation( scene, visual.position, diff --git a/src/tools/queries/maritime.js b/src/tools/queries/maritime.js index aeb90714f..439721c77 100644 --- a/src/tools/queries/maritime.js +++ b/src/tools/queries/maritime.js @@ -21,7 +21,10 @@ import { thinEvenly, } from '../results.js'; import { roundHeadingDegrees } from '../../data/headingDegrees.js'; -import { normalizeVesselType } from '../../data/vesselTypes.js'; +import { + isAidToNavigation, + normalizeVesselType, +} from '../../data/vesselTypes.js'; const MMSI_SCHEMA = Object.freeze({ type: 'string', @@ -116,7 +119,8 @@ export const vesselsInArea = defineTool({ title: 'Vessels in an area', description: 'Ships currently reported by AIS inside an area, nearest the center ' + - 'first, optionally filtered by vessel type. group_by counts every matched ' + + 'first, optionally filtered by vessel type. Buoys, beacons and other ' + + 'aids to navigation are not ships and are left out. group_by counts every matched ' + 'ship by type or destination, and stats summarizes their speed; both ' + 'cover all matches, not just the rows returned.', inputSchema: { @@ -152,6 +156,8 @@ export const vesselsInArea = defineTool({ const rows = snapshot.records .filter( (record) => + // A buoy or beacon in the feed is not a ship to count. + !isAidToNavigation(record) && areaContains(area, { lat: record.latitude, lon: record.longitude }) && (!wanted || (vesselType(record.type) ?? '').toLowerCase().includes(wanted)), diff --git a/src/tools/queries/maritime.test.mjs b/src/tools/queries/maritime.test.mjs index fa835b5b7..5715a1e4b 100644 --- a/src/tools/queries/maritime.test.mjs +++ b/src/tools/queries/maritime.test.mjs @@ -467,3 +467,44 @@ test('vessels in an area can be counted by destination with a speed summary', as speed_mps: { count: 2, min: 6.2, median: 6.2, mean: 6.2, max: 6.2 }, }); }); + +test('vessels in an area leave out buoys and beacons', async () => { + const withAids = { + ...vessels(), + async getSnapshot() { + return { + records: [ + ...records, + vessel('993672001', 37.8, -122.42, { + name: 'SF APPROACH N', + type: 'Cardinal Mark N', + speedMps: 0, + headingDeg: 135, + }), + vessel('993672002', 37.79, -122.43, { type: '' }), + ], + source: 'AISStream', + observedAtMs: Date.UTC(2026, 0, 1), + freshness: 'current', + }; + }, + }; + const catalog = composeCatalog({ + tools: coreTools, + services: { vessels: withAids }, + }); + const all = await catalog.call('vessels_in_area', { + area: bay, + group_by: 'type', + }); + assert.equal(all.data.total, 2); + assert.equal(all.summary.split(' in ')[0], '2 vessels'); + assert.deepEqual(all.data.rows.map((row) => row.mmsi).sort(), [ + '366999712', + '538001234', + ]); + assert.equal(all.data.breakdown.unknown_count, 0); + assert.ok( + !all.data.breakdown.groups.some((group) => /mark/i.test(group.value)), + ); +}); From 9ae121c7c05d63b7742ed0b0af0524bccd8c1d5a Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Sat, 14 Nov 2026 11:02:14 -0800 Subject: [PATCH 03/30] Number the buoy models changelog fragment for #1733 --- changelog.d/{0000-buoy-models.md => 1733-buoy-models.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename changelog.d/{0000-buoy-models.md => 1733-buoy-models.md} (100%) diff --git a/changelog.d/0000-buoy-models.md b/changelog.d/1733-buoy-models.md similarity index 100% rename from changelog.d/0000-buoy-models.md rename to changelog.d/1733-buoy-models.md From 52507a075569cb5b7868b80c443e972f3a2fd39c Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Sat, 14 Nov 2026 11:07:13 -0800 Subject: [PATCH 04/30] Draw no buoy for a virtual aid to navigation A virtual aid (AIS message 21's VirtualAtoN flag) is a mark broadcast where nothing physical stands, so drawing it as a buoy showed a mark that is not there. The vessel source record now carries `virtual` (false unless a source says true; any source may set it), AISStream sets it from VirtualAtoN, and the vessel layer keeps such an aid's disc: vesselModelSpec returns null for it and the layer gathers no model item for it. Its card, selected card and readout add VIRTUAL after its kind. --- changelog.d/1733-buoy-models.md | 4 +++- docs/CURRENT-STATE.md | 2 +- server/providers/vessels/ais-store.js | 3 +++ src/data/aisLiveVessels.test.mjs | 16 ++++++++++++++++ src/data/aisStreamSentinels.test.mjs | 22 ++++++++++++++++++++++ src/data/fleetModels.js | 15 +++++++++++---- src/data/fleetModels.test.mjs | 9 +++++++++ src/data/vesselTypes.js | 8 +++++--- src/data/vesselTypes.test.mjs | 5 +++++ src/i18n/locales/ar.json | 1 + src/i18n/locales/de.json | 1 + src/i18n/locales/es.json | 1 + src/i18n/locales/fr.json | 1 + src/i18n/locales/he.json | 1 + src/i18n/locales/it.json | 1 + src/i18n/locales/ja.json | 1 + src/i18n/locales/pt.json | 1 + src/i18n/locales/ru.json | 1 + src/i18n/locales/sv.json | 1 + src/i18n/locales/uk.json | 1 + src/i18n/locales/zh-CN.json | 1 + src/i18n/locales/zh-Hant.json | 1 + src/i18n/same-as-english.json | 6 ++++-- src/layers/vessels/cards.js | 14 ++++++++++++-- src/layers/vessels/ingestion.js | 1 + src/layers/vessels/ownership.test.mjs | 23 +++++++++++++++++++++++ src/layers/vessels/records.js | 3 +++ src/layers/vessels/rendering.js | 16 ++++++++++++---- src/sources/live/contract.js | 4 +++- src/sources/live/contract.test.mjs | 12 ++++++++++++ src/sources/live/vessels.js | 2 ++ 31 files changed, 160 insertions(+), 18 deletions(-) diff --git a/changelog.d/1733-buoy-models.md b/changelog.d/1733-buoy-models.md index 656a93374..a2de9e612 100644 --- a/changelog.d/1733-buoy-models.md +++ b/changelog.d/1733-buoy-models.md @@ -6,4 +6,6 @@ show its kind of mark with no speed or heading. AISStream now subscribes to aid-to-navigation reports and names each by its kind of mark and its full name; the feed lists every ship ahead of any aid, and `vessels_in_area` - counts ships only (samehkhamis, #0000). + counts ships only. A virtual aid (a mark broadcast where nothing physical + stands) keeps its disc, is never drawn as a buoy, and its card says it is + virtual; vessel sources may mark any record `virtual` (samehkhamis, #1733). diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md index 0b301991b..fc00c5934 100644 --- a/docs/CURRENT-STATE.md +++ b/docs/CURRENT-STATE.md @@ -7430,7 +7430,7 @@ pins and share links already supply complete boxes. 30-second backoff ahead of the current clock are ignored. A smaller rollback can retain a bounded retry delay of up to 30 seconds. - Commercial and military aircraft use the same high-level FLEET model regime: 2D billboards when zoomed out, optional glTF models when closer, controlled by the DISPLAY rail `3D` toggle and `Proximity` / `All` modes. Every model is one of the project's procedural fleet models (`public/models/fleet/`, MIT, 122 GLBs, about 2 MB in all; `public/models/README.md`), chosen per aircraft by `aircraftModelSpec` (`src/data/fleetModels.js`): the first of its ICAO type's callsign rules in `types.json` (`aircraft_callsign`) its callsign matches, else its type's entry, else the model of its `classifyAircraft` class for a type the map lacks, else its ADS-B emitter category's, else the default airliner. It is drawn LIFE SIZE: the type's published length over the model's built length (`src/layers/flights/modelSpec.js`, shared by Flights, Military Flights and Local ADS-B), and a grounded aircraft stands the model's scaled clearance above the ground. An airport ground vehicle (feed type `ZVEH`) is a fire truck (`FIRE…`), pushback tug (`PUSH…`, `TUG…`), van (`DEICER…`, `SQUID…`, `SQB…`) or else a car by its callsign, and a ground station (`GRND`) is an 11.8 m radio mast; these models (catalog category `other`) are drawn at their built size, and such a contact with no altitude stands on the ground instead of at the airborne default (`src/layers/flights/records.js`). `classifyAircraft` still picks the 2D icons. The whole set loads once, up front, when a layer that draws it starts (`loadFleetModelSet`, which logs `[Fleet] N/122 models (X MB) loaded in N ms`); models are built from those bytes, never fetched mid-session, and an aircraft stays its billboard until the set has loaded. Every aircraft model draws its mesh's own colours (`aircraftModelBlend`, `src/data/aircraftModelLighting.js`): Cesium's `ColorBlendMode.HIGHLIGHT` with white, in Flights, Military Flights and Local ADS-B alike; the tracked colour (cyan, or amber in Military Flights) and the emergency red multiply into the mesh, so its paint still shows. IR boost draws them flat white (`MIX` at `1.0`). Under NVG/FLIR (map preset or Cockpit vision) models render unlit flat-white at full alpha and scene fog is disabled (fog otherwise blacks out distant models with the globe hidden); state restores on exit. -- Vessels, Transit and Rail draw fleet models under the same DISPLAY rail `3D` toggle, at the same altitude ceiling, caps and add/keep radii as the aircraft (`FLEET_MODEL_POLICY`, `src/layers/flights/policy.js`; `createFleetModelLayer`, `src/data/fleetModelInstances.js`). A vessel's model follows its AIS ship type and is drawn at its reported length and beam (AIS static dimensions A+B and C+D, now carried on vessel rows as `length` and `beam`), standing at the sea surface, heading by true heading then course. An aid to navigation is not a hull: a vessel record whose type names a buoy, beacon, mark, RACON or light, or whose MMSI is an aid-to-navigation station's (`99MIDxxxx`), is `isAidToNavigation` (`src/data/vesselTypes.js`) and is drawn as the set's `buoys` model of the IALA mark its type names (`aidToNavigationModel`, `src/data/fleetModels.js`: cardinal N/E/S/W, port or starboard hand, preferred channel by its side, safe water, isolated danger, special mark; a beacon, light, light vessel, RACON or reference point with no mark of its own is the special mark), else a red can (`DEFAULT_AID_MODEL`), at its built size and facing north whatever heading it reports. A type is an aid's when it is one of the 32 kinds an aid report names or uses a word for one (buoy, beacon, cardinal, safe water, RACON, lighthouse and so on); a vessel that works on aids (`Buoy Tender`, `Buoy Layer`) is not one. Its icon is a bone-white ringed disc (`AID_TO_NAVIGATION_STYLE`, `src/data/vesselLabels.js`) instead of a chevron, never rotated, and its card, selected card and HUD readout (`src/layers/vessels/cards.js`) show its kind alone, whole, in that colour: no speed or heading, since a fixed mark has neither. AISStream subscribes to `AidsToNavigationReport` (message 21) by default, and the server names each report's aid type code (0 to 31) as its kind (`aidToNavigationTypeName`: `20` is `Cardinal Mark N`) rather than reading it as a ship type, and its name runs on into the report's `NameExtension`. `aisStreamRows` (`server/providers/vessels/ais-store.js`) puts every vessel ahead of every aid, so a capped request (the layer asks for 12,000 rows) never gives up a ship for a buoy. The `vessels_in_area` tool (and the brief built on it) counts ships only: it leaves aids out of its rows, counts, breakdowns and speed stats. A transit vehicle's model follows its layer mode (bus, tram, subway, rail or ferry; a vehicle of `unknown` mode keeps its icon), a train's its rail category and mode (rail, metro or tram). Neither the transit nor the rail sources carry a GTFS `route_type` or a finer mode (monorail, gondola, funicular, cable car), so the set's models for those and their `transit.elevation` lifts are not reached by any live source today. Both stand on the road or rail top they are drawn on, without the 1.5 m `GROUND_FLOOR_LIFT_M` their icons carry, and are painted in their mode or category colour where the model's `_TINT` attribute marks it. A vessel model is clipped at its waterline (one clipping plane per model, at the model origin's horizontal plane), so its hull below the water never shows through a plain globe, which Cesium does not depth-test models against. Under the NVG/FLIR styles (the Flights `irBoost` parameter) these models render unlit flat white, as aircraft models do. Each vehicle's icon stays the visual until its model is loaded, ready and placed; a model is picked as its icon is, and a vehicle drawn as its model keeps its selection card and its place in the detection overlay. +- Vessels, Transit and Rail draw fleet models under the same DISPLAY rail `3D` toggle, at the same altitude ceiling, caps and add/keep radii as the aircraft (`FLEET_MODEL_POLICY`, `src/layers/flights/policy.js`; `createFleetModelLayer`, `src/data/fleetModelInstances.js`). A vessel's model follows its AIS ship type and is drawn at its reported length and beam (AIS static dimensions A+B and C+D, now carried on vessel rows as `length` and `beam`), standing at the sea surface, heading by true heading then course. An aid to navigation is not a hull: a vessel record whose type names a buoy, beacon, mark, RACON or light, or whose MMSI is an aid-to-navigation station's (`99MIDxxxx`), is `isAidToNavigation` (`src/data/vesselTypes.js`) and is drawn as the set's `buoys` model of the IALA mark its type names (`aidToNavigationModel`, `src/data/fleetModels.js`: cardinal N/E/S/W, port or starboard hand, preferred channel by its side, safe water, isolated danger, special mark; a beacon, light, light vessel, RACON or reference point with no mark of its own is the special mark), else a red can (`DEFAULT_AID_MODEL`), at its built size and facing north whatever heading it reports. A type is an aid's when it is one of the 32 kinds an aid report names or uses a word for one (buoy, beacon, cardinal, safe water, RACON, lighthouse and so on); a vessel that works on aids (`Buoy Tender`, `Buoy Layer`) is not one. Its icon is a bone-white ringed disc (`AID_TO_NAVIGATION_STYLE`, `src/data/vesselLabels.js`) instead of a chevron, never rotated, and its card, selected card and HUD readout (`src/layers/vessels/cards.js`) show its kind alone, whole, in that colour: no speed or heading, since a fixed mark has neither. AISStream subscribes to `AidsToNavigationReport` (message 21) by default, and the server names each report's aid type code (0 to 31) as its kind (`aidToNavigationTypeName`: `20` is `Cardinal Mark N`) rather than reading it as a ship type, and its name runs on into the report's `NameExtension`. A virtual aid (the report's `VirtualAtoN` flag: a mark broadcast where nothing physical stands) carries `virtual: true` on its row, and on its vessel source record (the live-source contract's `virtual`, `src/sources/live/contract.js`, false unless a source says true; any source may set it). It keeps its disc but never gets a model (`vesselModelSpec` returns null for it, and the vessel layer gathers no model item for it), and its card and readout add `VIRTUAL` after its kind. `aisStreamRows` (`server/providers/vessels/ais-store.js`) puts every vessel ahead of every aid, so a capped request (the layer asks for 12,000 rows) never gives up a ship for a buoy. The `vessels_in_area` tool (and the brief built on it) counts ships only: it leaves aids out of its rows, counts, breakdowns and speed stats. A transit vehicle's model follows its layer mode (bus, tram, subway, rail or ferry; a vehicle of `unknown` mode keeps its icon), a train's its rail category and mode (rail, metro or tram). Neither the transit nor the rail sources carry a GTFS `route_type` or a finer mode (monorail, gondola, funicular, cable car), so the set's models for those and their `transit.elevation` lifts are not reached by any live source today. Both stand on the road or rail top they are drawn on, without the 1.5 m `GROUND_FLOOR_LIFT_M` their icons carry, and are painted in their mode or category colour where the model's `_TINT` attribute marks it. A vessel model is clipped at its waterline (one clipping plane per model, at the model origin's horizontal plane), so its hull below the water never shows through a plain globe, which Cesium does not depth-test models against. Under the NVG/FLIR styles (the Flights `irBoost` parameter) these models render unlit flat white, as aircraft models do. Each vehicle's icon stays the visual until its model is loaded, ready and placed; a model is picked as its icon is, and a vehicle drawn as its model keeps its selection card and its place in the detection overlay. - **Aircraft models skip Cesium's dynamic environment map (2026-10-24).** Flights, Military Flights and Local ADS-B pass `environmentMapOptions: AIRCRAFT_ENVIRONMENT_MAP_OPTIONS` (`{ enabled: false }`, `src/data/aircraftModelLighting.js`) to every drawn model. Otherwise each `Model` renders the sky around it and reads it back from the GPU (`readPixels`) when it is first placed, and again whenever it moves more than 1 km, the scene's atmosphere settings change, or (under sunlight dynamic lighting) an hour of scene time passes (`DynamicEnvironmentMapManager`, Cesium 1.138). The models are lit from Cesium's default spherical harmonics instead, with no specular environment map, so the sky's model-lighting cube map no longer reaches aircraft. `src/data/aircraftModelLighting.test.mjs` pins the option at every drawn model call; every model is built from the fleet set loaded up front, so there is no separate preload. - The DISPLAY-rail `3D` toggle is the user-facing activation path for both aircraft layers. Their small approved GLBs build their render resources without Cesium's frame-spread job queue, preventing continuous Photorealistic 3D Tiles streaming from starving model readiness; model caps, tracking, camera, and fallback billboards are unchanged. - **The `3D` toggle DEFAULTS ON in `proximity` on a first run.** Proximity is itself the budget — models appear only below `MODEL_ALT_CEIL_M` and only for the nearest `MODEL_MAX` in view — so the default costs nothing at globe scale, and `all` remains a deliberate opt-in. A fresh boot runs NO layer-state restoration (`LayerStateCoordinator.start()` returns early with neither a share payload nor stored state), so four independent initializers decide what a first-run operator sees and must agree: `booleanOption('models3d', 'e', true)` in `src/data/layerState.js`, `_models3dEnabled = true` in BOTH flight layers, `this._models3dEnabled = true` in `src/ui/aircraftDisplay.js`, and the `active` / `visible` classes on `#models3d-toggle` / `#models3d-mode-row` in `index.html`. All four are pinned together in `src/data/layerState.test.mjs`. Explicit state still wins: because the codec omits default-valued options, `models3d: false` is now what travels in a link (`lo=…f.e.0`) and restores OFF at both aircraft layers. **Consequence for returning users:** a stored `gev:layer-state:v2` blob is a FULL options snapshot, so a session that wrote one before this change carries `models3d:false` and keeps 3D off until the operator flips it (or clears the key) — the durable snapshot is treated as the recipient's own state, by design. diff --git a/server/providers/vessels/ais-store.js b/server/providers/vessels/ais-store.js index e6e8b53d7..6c4d8a57a 100644 --- a/server/providers/vessels/ais-store.js +++ b/server/providers/vessels/ais-store.js @@ -143,6 +143,9 @@ export function ingestAisStreamEnvelope(envelope) { // Use the AIS message's own report time, not server ingest wall-clock — // trail spacing and dead reckoning depend on true fix epochs. last_position_epoch: aisEpochSeconds(metadata.time_utc ?? metadata.TimeUtc), + // A virtual aid is broadcast where nothing physical stands. Only such a + // row carries the field, so ship rows stay their size. + ...(aidReport && message.VirtualAtoN === true && { virtual: true }), _updatedAt: Date.now(), }); diff --git a/src/data/aisLiveVessels.test.mjs b/src/data/aisLiveVessels.test.mjs index 5cfb68add..6608eb055 100644 --- a/src/data/aisLiveVessels.test.mjs +++ b/src/data/aisLiveVessels.test.mjs @@ -1916,7 +1916,23 @@ test('the HUD of a selected aid to navigation shows no speed or heading', () => assert.equal(aisLiveVesselsLayer.selectById(harness.record.mmsi), true); assert.match(harness.hud.readout.text, /\nPort hand Mark\n/); assert.doesNotMatch(harness.hud.readout.text, /SPD|HDG|KT/); + harness.record.virtual = true; + aisLiveVesselsLayer.selectById(harness.record.mmsi); + assert.match(harness.hud.readout.text, /\nPort hand Mark · VIRTUAL\n/); } finally { harness.cleanup(); } }); + +test('a virtual aid to navigation card says it is virtual', () => { + const aid = makeRecord({ + mmsi: '993672001', + type: 'Isolated danger', + virtual: true, + }); + assert.deepEqual(buildVesselCard(aid).details, ['ISOLATED DANGER · VIRTUAL']); + assert.equal( + buildSelectedVesselCard(aid).details[0], + 'ISOLATED DANGER · VIRTUAL', + ); +}); diff --git a/src/data/aisStreamSentinels.test.mjs b/src/data/aisStreamSentinels.test.mjs index bb93020c4..563bf9f65 100644 --- a/src/data/aisStreamSentinels.test.mjs +++ b/src/data/aisStreamSentinels.test.mjs @@ -388,3 +388,25 @@ test('a capped row request keeps every vessel ahead of aids to navigation', () = aisStreamRows(vesselCount).every((row) => !row.mmsi.startsWith('99')), ); }); + +test('a virtual aid to navigation is marked virtual; a real one carries no flag', () => { + const aidReport = (mmsi, VirtualAtoN) => ({ + MessageType: 'AidsToNavigationReport', + Message: { + AidsToNavigationReport: { UserID: Number(mmsi), Type: 28, VirtualAtoN }, + }, + MetaData: { + MMSI: mmsi, + latitude: 37.79, + longitude: -122.52, + time_utc: '2026-09-17 20:00:00.000000000 +0000 UTC', + }, + }); + ingestAisStreamEnvelope(aidReport('993672004', true)); + ingestAisStreamEnvelope(aidReport('993672005', false)); + assert.equal(rowFor('993672004').virtual, true); + assert.equal('virtual' in rowFor('993672005'), false); + // A later real report of the same aid drops the flag. + ingestAisStreamEnvelope(aidReport('993672004', false)); + assert.equal('virtual' in rowFor('993672004'), false); +}); diff --git a/src/data/fleetModels.js b/src/data/fleetModels.js index 6c4081324..69ab2a678 100644 --- a/src/data/fleetModels.js +++ b/src/data/fleetModels.js @@ -443,13 +443,20 @@ export function aircraftModelSpec( * ({@link isAidToNavigation}: its type names a buoy, beacon, mark, RACON or * light, or its MMSI is an aid's) is the buoy of its mark * ({@link aidToNavigationModel}), else {@link DEFAULT_AID_MODEL}, drawn as - * built and flagged `fixed`: it has no heading to turn to. + * built and flagged `fixed`: it has no heading to turn to. A virtual aid + * (`virtual`) is broadcast where nothing physical stands, so it has no model. * @param {{catalog: object, types: object}} set * @param {{type?: string|number|null, mmsi?: string|number|null, - * length?: number|null, beam?: number|null, name?: string|null}} vessel - * @returns {object} {@link fleetModelSpec}, with `fixed` for an aid + * virtual?: boolean, length?: number|null, beam?: number|null, + * name?: string|null}} vessel + * @returns {object|null} {@link fleetModelSpec}, with `fixed` for an aid; + * null for a virtual aid */ -export function vesselModelSpec(set, { type, mmsi, length, beam, name } = {}) { +export function vesselModelSpec( + set, + { type, mmsi, virtual, length, beam, name } = {}, +) { + if (virtual === true) return null; if (isAidToNavigation({ type, mmsi })) { const model = aidToNavigationModel(type); const known = model && set.catalog[model] ? model : DEFAULT_AID_MODEL; diff --git a/src/data/fleetModels.test.mjs b/src/data/fleetModels.test.mjs index 66ff49f3a..d48e744c1 100644 --- a/src/data/fleetModels.test.mjs +++ b/src/data/fleetModels.test.mjs @@ -423,6 +423,15 @@ test('aids to navigation are the buoy of the mark their type names', () => { assert.equal(unnamed.model, DEFAULT_AID_MODEL); assert.equal(unnamed.fixed, true); assert.equal(aidToNavigationModel('Fixed structure off shore'), undefined); + // A virtual aid is broadcast where nothing stands: it keeps its disc. + assert.equal( + vesselModelSpec(set, { + type: 'Cardinal Mark N', + mmsi: '993672001', + virtual: true, + }), + null, + ); // Vessels, including those that work on buoys, keep their hulls. for (const vessel of [ { type: 'Buoy Tender', mmsi: '366999001', length: 60 }, diff --git a/src/data/vesselTypes.js b/src/data/vesselTypes.js index 5b9dd22b1..742187548 100644 --- a/src/data/vesselTypes.js +++ b/src/data/vesselTypes.js @@ -140,11 +140,13 @@ function typeNamesAid(text) { * Whether a vessel record is an aid to navigation (a buoy, beacon, mark, * RACON or light) rather than a vessel: its type is one of the kinds an aid * report names or uses a word for one, or its MMSI is an aid-to-navigation - * station's. A numeric AIS ship type never names one. - * @param {{type?: string|number|null, mmsi?: string|number|null}} vessel + * station's, or it is a virtual aid. A numeric AIS ship type never names one. + * @param {{type?: string|number|null, mmsi?: string|number|null, + * virtual?: boolean}} vessel * @returns {boolean} */ -export function isAidToNavigation({ type, mmsi } = {}) { +export function isAidToNavigation({ type, mmsi, virtual } = {}) { + if (virtual === true) return true; const text = typeof type === 'string' ? type.trim() : String(type ?? ''); if (text && typeNamesAid(text)) return true; if (mmsi === null || mmsi === undefined || mmsi === '') return false; diff --git a/src/data/vesselTypes.test.mjs b/src/data/vesselTypes.test.mjs index 3a7e3ca2d..65816743c 100644 --- a/src/data/vesselTypes.test.mjs +++ b/src/data/vesselTypes.test.mjs @@ -36,6 +36,11 @@ test('aids to navigation are known by their type, else their MMSI', () => { 'Emergency wreck marking buoy', ]) assert.equal(isAidToNavigation({ type, mmsi: '' }), true, type); + // A virtual aid is an aid whatever its type or MMSI. + assert.equal( + isAidToNavigation({ type: '', mmsi: '', virtual: true }), + true, + ); // AIS aid-to-navigation stations are numbered 99MIDxxxx. assert.equal(isAidToNavigation({ type: '', mmsi: '993672001' }), true); assert.equal(isAidToNavigation({ type: '0', mmsi: ' 992351234 ' }), true); diff --git a/src/i18n/locales/ar.json b/src/i18n/locales/ar.json index 0eeb41a7c..44024e10f 100644 --- a/src/i18n/locales/ar.json +++ b/src/i18n/locales/ar.json @@ -777,6 +777,7 @@ "OTHER": "أخرى", "VESSEL": "سفينة", "AID TO NAVIGATION": "مساعدة ملاحية", + "VIRTUAL": "افتراضي", "POS: LIVE": "الموضع: مباشر", "POS: {time}Z": "الموضع: {time}Z", "AIS: --": "AIS: --", diff --git a/src/i18n/locales/de.json b/src/i18n/locales/de.json index bc9280d70..cdb669452 100644 --- a/src/i18n/locales/de.json +++ b/src/i18n/locales/de.json @@ -417,6 +417,7 @@ "{type} SPD: {speed} HDG: {heading}": "{type} SPD: {speed} HDG: {heading}", "VESSEL": "SCHIFF", "AID TO NAVIGATION": "SEEZEICHEN", + "VIRTUAL": "VIRTUELL", "POS: LIVE": "POS: LIVE", "POS: {time}Z": "POS: {time}Z", "awaiting first AIS position…": "warten auf erste AIS-Position…", diff --git a/src/i18n/locales/es.json b/src/i18n/locales/es.json index 829ac7ea6..b0d10ae06 100644 --- a/src/i18n/locales/es.json +++ b/src/i18n/locales/es.json @@ -651,6 +651,7 @@ "OTHER": "OTRO", "VESSEL": "BUQUE", "AID TO NAVIGATION": "AYUDA A LA NAVEGACIÓN", + "VIRTUAL": "VIRTUAL", "POS: LIVE": "POS: EN VIVO", "POS: {time}Z": "POS: {time}Z", "AIS: --": "AIS: --", diff --git a/src/i18n/locales/fr.json b/src/i18n/locales/fr.json index a4d3a831f..ffe522ad9 100644 --- a/src/i18n/locales/fr.json +++ b/src/i18n/locales/fr.json @@ -1292,6 +1292,7 @@ "{type} SPD: {speed} HDG: {heading}": "{type} SPD : {speed} HDG : {heading}", "VESSEL": "NAVIRE", "AID TO NAVIGATION": "AIDE À LA NAVIGATION", + "VIRTUAL": "VIRTUEL", "{speed}KT": "{speed} ND", "{heading}DEG": "{heading}°", "POS: LIVE": "POS : DIRECT", diff --git a/src/i18n/locales/he.json b/src/i18n/locales/he.json index f27f4279b..cfe612894 100644 --- a/src/i18n/locales/he.json +++ b/src/i18n/locales/he.json @@ -1150,6 +1150,7 @@ "{type} SPD: {speed} HDG: {heading}": "{type} SPD: {speed} HDG: {heading}", "VESSEL": "אונייה", "AID TO NAVIGATION": "עזר ניווט", + "VIRTUAL": "וירטואלי", "{speed}KT": "{speed} קשר", "{heading}DEG": "{heading}°", "POS: LIVE": "POS: חי", diff --git a/src/i18n/locales/it.json b/src/i18n/locales/it.json index 9ee245256..e8d939278 100644 --- a/src/i18n/locales/it.json +++ b/src/i18n/locales/it.json @@ -1292,6 +1292,7 @@ "{type} SPD: {speed} HDG: {heading}": "{type} VEL: {speed} HDG: {heading}", "VESSEL": "NAVE", "AID TO NAVIGATION": "AIUTO ALLA NAVIGAZIONE", + "VIRTUAL": "VIRTUALE", "{speed}KT": "{speed}KT", "{heading}DEG": "{heading}°", "POS: LIVE": "POS: LIVE", diff --git a/src/i18n/locales/ja.json b/src/i18n/locales/ja.json index 488f7b81e..8039831d8 100644 --- a/src/i18n/locales/ja.json +++ b/src/i18n/locales/ja.json @@ -1254,6 +1254,7 @@ "{type} SPD: {speed} HDG: {heading}": "{type} SPD: {speed} HDG: {heading}", "VESSEL": "船舶", "AID TO NAVIGATION": "航路標識", + "VIRTUAL": "仮想", "{speed}KT": "{speed} kt", "{heading}DEG": "{heading}°", "POS: LIVE": "POS: ライブ", diff --git a/src/i18n/locales/pt.json b/src/i18n/locales/pt.json index 5944dbc6b..18b6d1dd2 100644 --- a/src/i18n/locales/pt.json +++ b/src/i18n/locales/pt.json @@ -1290,6 +1290,7 @@ "{type} SPD: {speed} HDG: {heading}": "{type} SPD: {speed} HDG: {heading}", "VESSEL": "EMBARCAÇÃO", "AID TO NAVIGATION": "AUXÍLIO À NAVEGAÇÃO", + "VIRTUAL": "VIRTUAL", "{speed}KT": "{speed} KT", "{heading}DEG": "{heading}°", "POS: LIVE": "POS: AO VIVO", diff --git a/src/i18n/locales/ru.json b/src/i18n/locales/ru.json index 5065907c4..b58d78d26 100644 --- a/src/i18n/locales/ru.json +++ b/src/i18n/locales/ru.json @@ -395,6 +395,7 @@ "{type} SPD: {speed} HDG: {heading}": "{type} СКОР: {speed} КУРС: {heading}", "VESSEL": "СУДНО", "AID TO NAVIGATION": "СРЕДСТВО НАВИГАЦИИ", + "VIRTUAL": "ВИРТУАЛЬНЫЙ", "AIS: --": "AIS: --", "awaiting first AIS position…": "ожидание первой позиции AIS…", "awaiting usable AIS positions…": "ожидание пригодных позиций AIS…", diff --git a/src/i18n/locales/sv.json b/src/i18n/locales/sv.json index 2eebc0df0..bd1f25a7e 100644 --- a/src/i18n/locales/sv.json +++ b/src/i18n/locales/sv.json @@ -383,6 +383,7 @@ "{type} SPD: {speed} HDG: {heading}": "{type} SPD: {speed} HDG: {heading}", "VESSEL": "FARTYG", "AID TO NAVIGATION": "SJÖMÄRKE", + "VIRTUAL": "VIRTUELL", "POS: LIVE": "POS: LIVE", "POS: {time}Z": "POS: {time}Z", "awaiting first AIS position…": "väntar på första AIS-positionen …", diff --git a/src/i18n/locales/uk.json b/src/i18n/locales/uk.json index 8face8fd5..9506d0a31 100644 --- a/src/i18n/locales/uk.json +++ b/src/i18n/locales/uk.json @@ -1310,6 +1310,7 @@ "{type} SPD: {speed} HDG: {heading}": "{type} ШВИД: {speed} КУРС: {heading}", "VESSEL": "СУДНО", "AID TO NAVIGATION": "ЗАСІБ НАВІГАЦІЇ", + "VIRTUAL": "ВІРТУАЛЬНИЙ", "{speed}KT": "{speed} ВУЗ", "{heading}DEG": "{heading}°", "POS: LIVE": "ПОЗ.: ОНЛАЙН", diff --git a/src/i18n/locales/zh-CN.json b/src/i18n/locales/zh-CN.json index d8bcb9d63..f34c36028 100644 --- a/src/i18n/locales/zh-CN.json +++ b/src/i18n/locales/zh-CN.json @@ -1230,6 +1230,7 @@ "{type} SPD: {speed} HDG: {heading}": "{type} SPD: {speed} HDG: {heading}", "VESSEL": "船舶", "AID TO NAVIGATION": "助航标志", + "VIRTUAL": "虚拟", "{speed}KT": "{speed} kn", "{heading}DEG": "{heading}°", "POS: LIVE": "POS:实时", diff --git a/src/i18n/locales/zh-Hant.json b/src/i18n/locales/zh-Hant.json index cf782e389..0e01c7773 100644 --- a/src/i18n/locales/zh-Hant.json +++ b/src/i18n/locales/zh-Hant.json @@ -1225,6 +1225,7 @@ "{type} SPD: {speed} HDG: {heading}": "{type} SPD: {speed} HDG: {heading}", "VESSEL": "船舶", "AID TO NAVIGATION": "助航標誌", + "VIRTUAL": "虛擬", "{speed}KT": "{speed} kn", "{heading}DEG": "{heading}°", "POS: LIVE": "POS:實時", diff --git a/src/i18n/same-as-english.json b/src/i18n/same-as-english.json index 1ab9b364f..b8a7eeb61 100644 --- a/src/i18n/same-as-english.json +++ b/src/i18n/same-as-english.json @@ -411,7 +411,8 @@ "MMSI: {id}", "NORAD: {id}", "Regional", - "{datasets} · {tiles} · {packs}" + "{datasets} · {tiles} · {packs}", + "VIRTUAL" ], "fr": [ "1 min/s", @@ -1067,7 +1068,8 @@ "ICAO: {id}", "MMSI: {id}", "NORAD: {id}", - "Regional" + "Regional", + "VIRTUAL" ], "ru": [ "1900–1945", diff --git a/src/layers/vessels/cards.js b/src/layers/vessels/cards.js index f8371c372..f215c6b09 100644 --- a/src/layers/vessels/cards.js +++ b/src/layers/vessels/cards.js @@ -24,7 +24,10 @@ export function createCards({ text: [ t('AIS: {name}', { name: trimHudValue(record.name, 32) }), aid - ? trimHudValue(record.type || t('AID TO NAVIGATION'), 24) + ? aidKind( + trimHudValue(record.type || t('AID TO NAVIGATION'), 24), + record, + ) : t('{type} SPD: {speed} HDG: {heading}', { type: trimHudValue(record.type || t('VESSEL'), 24), speed: formatSpeed(record.speed), @@ -60,6 +63,7 @@ export function createCards({ const aid = isAidToNavigation(record); const type = vesselTypeShort(record); if (type) parts.push(type); + if (record.virtual === true) parts.push(t('VIRTUAL')); if (!aid && record.speed !== null && record.speed !== undefined) parts.push(formatSpeed(record.speed)); const direction = record.heading ?? record.course; @@ -95,7 +99,7 @@ export function createCards({ const direction = record.heading ?? record.course; const details = [ aid - ? vesselTypeShort(record) || t('AID TO NAVIGATION') + ? aidKind(vesselTypeShort(record) || t('AID TO NAVIGATION'), record) : [ vesselTypeShort(record) || t('VESSEL'), formatSpeed(record.speed), @@ -125,6 +129,12 @@ export function createCards({ }; } + /** An aid's kind, marked virtual when nothing physical stands there. */ + + function aidKind(kind, record) { + return record.virtual === true ? `${kind} · ${t('VIRTUAL')}` : kind; + } + /** A card's accent: an aid's disc colour, else its ship type's. */ function vesselAccent(record, aid) { diff --git a/src/layers/vessels/ingestion.js b/src/layers/vessels/ingestion.js index c291c8e35..2eb2d34f0 100644 --- a/src/layers/vessels/ingestion.js +++ b/src/layers/vessels/ingestion.js @@ -218,6 +218,7 @@ export function createIngestion({ speed: record.speedMps == null ? null : record.speedMps / 0.514444, course: record.courseDeg, heading: record.headingDeg, + virtual: record.virtual === true, last_position_epoch: record.observedAtMs == null ? null : record.observedAtMs / 1000, last_position_UTC: diff --git a/src/layers/vessels/ownership.test.mjs b/src/layers/vessels/ownership.test.mjs index 643991e9f..cffd22dbd 100644 --- a/src/layers/vessels/ownership.test.mjs +++ b/src/layers/vessels/ownership.test.mjs @@ -536,6 +536,29 @@ test('an aid to navigation is drawn as a disc, a vessel as its chevron', async ( return atob(primitive.image.split(',')[1]); }; assert.match(svgOf('993672001'), / [...primitives].find((p) => p.id?.id === id).id; + assert.equal(recordOf('993672001').virtual, false); + assert.equal(recordOf('366999002').virtual, false); assert.doesNotMatch(svgOf('993672001'), / { + const aid = { + ...observation('993672009'), + mmsi: '993672009', + type: 'Isolated danger', + virtual: true, + }; + const { layer, primitives } = setup({ + async getSnapshot() { + return snapshot([aid]); + }, + }); + await layer.update(); + const primitive = [...primitives].find((p) => p.id?.id === '993672009'); + assert.ok(primitive); + assert.equal(primitive.id.virtual, true); + assert.match(atob(primitive.image.split(',')[1]), / Date: Sat, 14 Nov 2026 12:03:12 -0800 Subject: [PATCH 05/30] Draw transit vehicles as trolleybuses, cable cars, funiculars, gondolas and monorails The transit layer knew five modes, so a trolleybus drew as a bus, a funicular as a train and a coach as a city bus. The GTFS basic route types are now modes of their own (trolleybus, cable_tram, monorail, funicular, aerial_lift), each with an icon, colour, detection tier, card word, voice name, speed ceiling and fleet model. A vehicle record may carry its route's GTFS route_type as routeType. It settles the mode after the feed's fleet hint and before its route hint, and picks the finer model (a coach for 200, a high-speed set for 101) when the type is a kind of the vehicle's mode. Retained history classifies epochs through transitModeFor too, so trails join the live vehicle. Route hints from each operator's routes.txt: Prague's trolleybus lines (51-59, 232, 275) and Petrin funicular, and the trams, trolleybuses and metro lines of Bucharest, Cluj-Napoca and Turin. A feed may also name route corrections that outrank the route type: Le Havre's routes.txt types its funicular (8-FUNI) as a bus, so it is corrected to a funicular. --- changelog.d/0000-transit-route-type-models.md | 10 + docs/CURRENT-STATE.md | 30 ++- server/providers/transitHistory.test.mjs | 22 ++ src/data/fleetModels.test.mjs | 33 +++ src/data/transitFeeds.js | 253 ++++++++++++++++-- src/data/transitFeeds.test.mjs | 122 ++++++++- src/data/transitIcons.js | 81 +++++- src/data/transitIcons.test.mjs | 10 +- src/data/transitPresetStyle.js | 12 +- src/data/transitProxy.js | 1 + src/i18n/locales/ar.json | 7 +- src/i18n/locales/de.json | 7 +- src/i18n/locales/es.json | 7 +- src/i18n/locales/fr.json | 7 +- src/i18n/locales/he.json | 7 +- src/i18n/locales/it.json | 7 +- src/i18n/locales/ja.json | 7 +- src/i18n/locales/pt.json | 7 +- src/i18n/locales/ru.json | 7 +- src/i18n/locales/sv.json | 7 +- src/i18n/locales/uk.json | 7 +- src/i18n/locales/zh-CN.json | 7 +- src/i18n/locales/zh-Hant.json | 7 +- src/i18n/same-as-english.json | 4 + src/layers/transit/ingestion.js | 13 +- src/layers/transit/movement.js | 5 + src/layers/transit/policy.js | 15 ++ src/layers/transit/rendering.js | 10 +- src/layers/transit/trails.js | 11 +- src/overlays/worldOverlayTokens.js | 20 ++ src/sources/transitHistoryStore.js | 13 +- src/voice/layerManifest.js | 13 +- 32 files changed, 708 insertions(+), 61 deletions(-) create mode 100644 changelog.d/0000-transit-route-type-models.md diff --git a/changelog.d/0000-transit-route-type-models.md b/changelog.d/0000-transit-route-type-models.md new file mode 100644 index 000000000..463820354 --- /dev/null +++ b/changelog.d/0000-transit-route-type-models.md @@ -0,0 +1,10 @@ +- Draw transit vehicles as their kind, not one of five: trolleybuses, cable + cars, funiculars, gondolas and monorails are modes of their own, with their + own icon, colour, card word and fleet model. A vehicle record may carry its + route's GTFS `route_type` (`routeType`), which settles its mode before the + feed's route hints and picks the finer model (a coach for 200, a high-speed + set for 101). Prague's trolleybuses and Petřín funicular, and Bucharest, + Cluj and Turin's trams, trolleybuses and metro lines, now read as such from + the route ids in each operator's routes.txt. Le Havre's funicular, which its + routes.txt types as a bus, is a named correction that outranks the route + type (samehkhamis, #0000). diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md index fc00c5934..4b578d178 100644 --- a/docs/CURRENT-STATE.md +++ b/docs/CURRENT-STATE.md @@ -5868,7 +5868,26 @@ Helsinki, the Netherlands, Norway, South East Queensland, Rio de Janeiro Ontario — Toronto (TTC surface vehicles; the subway publishes no positions), MiWay, Hamilton HSR, Durham Region, YRT/Viva, Guelph, Burlington, Barrie and Kingston. Mode silhouettes -identify buses, trams, subways, trains, ferries and unclassified vehicles. +identify buses, trolleybuses, trams, cable cars, subways, monorails, trains, +funiculars, gondolas (aerial lifts), ferries and unclassified vehicles. + +A vehicle's mode comes from, in order: the feed's fleet-number hint +(`vehicleMode`, which knows a bus standing in on a streetcar route); the feed's +correction for a route its own routes.txt mistypes (`routeCorrections`: Le +Havre's funicular `8-FUNI`, which LiA's routes.txt types as a bus); the GTFS +`route_type` of its route, when its record carries one as `routeType` (basic +0–12 or extended 100–1799, each extended type taken as the basic mode it is a +kind of: 200 coach is a bus, 101 high-speed is rail, 405 is a monorail); the +feed's route-id hint (`routeMode`); and the feed's default (`transitModeFor`, +`src/data/transitFeeds.js`). The GTFS-Realtime decoder carries no route type, so +a record from the bundled proxy is classified by the hints alone. Route hints +read from each operator's routes.txt cover Prague's trolleybus lines and Petřín +funicular, and Bucharest, Cluj-Napoca and Turin's trams, trolleybuses and metro +lines (and Turin's Sassi–Superga rack tramway, typed a funicular in its +routes.txt). Le Havre's funicular is a correction, not read from routes.txt: its +route hint and its correction both say funicular. Vilnius publishes no route ids in its positions, so +its trolleybuses read as buses. Retained history classifies its epochs the same +way, so a trail joins the live vehicle. Retained transit history uses the same outlier quarantine as live observations and preserves the active live bracket. Rejected reports do not publish route or mode @@ -5934,9 +5953,10 @@ External halos are 1/1.5 px in normal, 1.25/1.25 px in CRT and 2/2 px in sensors final unpadded display size. Each mode has an outline with a front (a nose, a bow or a chamfered cab) for a vehicle with a known course and a symmetric outline for one without, which would otherwise sit at rotation 0 and point -north; a vehicle switches to the pointed glyph when a course arrives. Six modes, two sizes, three -profiles and the two outlines cap the raster cache at 72 variants. Normal mode colours are bus `#5EF08A`, tram -`#FFC24A`, subway `#FF4538`, rail `#D9A6FF`, ferry `#5FD6FF`, and unknown +north; a vehicle switches to the pointed glyph when a course arrives. Eleven modes, two sizes, three +profiles and the two outlines cap the raster cache at 132 variants. Normal mode colours are bus `#5EF08A`, +trolleybus `#B6F04A`, tram `#FFC24A`, cable car `#FF8F4A`, subway `#FF4538`, monorail `#FF6FB8`, rail +`#D9A6FF`, funicular `#E8C98A`, gondola `#7FA8FF`, ferry `#5FD6FF`, and unknown `#D8DDE5`. Selection keeps the mode colour. Sensors reuse each normal silhouette's exact outer path, filled opaque white without interior panel lines, with an opaque `#05080C` halo. Only the external padding grows; the unpadded silhouette remains @@ -7430,7 +7450,7 @@ pins and share links already supply complete boxes. 30-second backoff ahead of the current clock are ignored. A smaller rollback can retain a bounded retry delay of up to 30 seconds. - Commercial and military aircraft use the same high-level FLEET model regime: 2D billboards when zoomed out, optional glTF models when closer, controlled by the DISPLAY rail `3D` toggle and `Proximity` / `All` modes. Every model is one of the project's procedural fleet models (`public/models/fleet/`, MIT, 122 GLBs, about 2 MB in all; `public/models/README.md`), chosen per aircraft by `aircraftModelSpec` (`src/data/fleetModels.js`): the first of its ICAO type's callsign rules in `types.json` (`aircraft_callsign`) its callsign matches, else its type's entry, else the model of its `classifyAircraft` class for a type the map lacks, else its ADS-B emitter category's, else the default airliner. It is drawn LIFE SIZE: the type's published length over the model's built length (`src/layers/flights/modelSpec.js`, shared by Flights, Military Flights and Local ADS-B), and a grounded aircraft stands the model's scaled clearance above the ground. An airport ground vehicle (feed type `ZVEH`) is a fire truck (`FIRE…`), pushback tug (`PUSH…`, `TUG…`), van (`DEICER…`, `SQUID…`, `SQB…`) or else a car by its callsign, and a ground station (`GRND`) is an 11.8 m radio mast; these models (catalog category `other`) are drawn at their built size, and such a contact with no altitude stands on the ground instead of at the airborne default (`src/layers/flights/records.js`). `classifyAircraft` still picks the 2D icons. The whole set loads once, up front, when a layer that draws it starts (`loadFleetModelSet`, which logs `[Fleet] N/122 models (X MB) loaded in N ms`); models are built from those bytes, never fetched mid-session, and an aircraft stays its billboard until the set has loaded. Every aircraft model draws its mesh's own colours (`aircraftModelBlend`, `src/data/aircraftModelLighting.js`): Cesium's `ColorBlendMode.HIGHLIGHT` with white, in Flights, Military Flights and Local ADS-B alike; the tracked colour (cyan, or amber in Military Flights) and the emergency red multiply into the mesh, so its paint still shows. IR boost draws them flat white (`MIX` at `1.0`). Under NVG/FLIR (map preset or Cockpit vision) models render unlit flat-white at full alpha and scene fog is disabled (fog otherwise blacks out distant models with the globe hidden); state restores on exit. -- Vessels, Transit and Rail draw fleet models under the same DISPLAY rail `3D` toggle, at the same altitude ceiling, caps and add/keep radii as the aircraft (`FLEET_MODEL_POLICY`, `src/layers/flights/policy.js`; `createFleetModelLayer`, `src/data/fleetModelInstances.js`). A vessel's model follows its AIS ship type and is drawn at its reported length and beam (AIS static dimensions A+B and C+D, now carried on vessel rows as `length` and `beam`), standing at the sea surface, heading by true heading then course. An aid to navigation is not a hull: a vessel record whose type names a buoy, beacon, mark, RACON or light, or whose MMSI is an aid-to-navigation station's (`99MIDxxxx`), is `isAidToNavigation` (`src/data/vesselTypes.js`) and is drawn as the set's `buoys` model of the IALA mark its type names (`aidToNavigationModel`, `src/data/fleetModels.js`: cardinal N/E/S/W, port or starboard hand, preferred channel by its side, safe water, isolated danger, special mark; a beacon, light, light vessel, RACON or reference point with no mark of its own is the special mark), else a red can (`DEFAULT_AID_MODEL`), at its built size and facing north whatever heading it reports. A type is an aid's when it is one of the 32 kinds an aid report names or uses a word for one (buoy, beacon, cardinal, safe water, RACON, lighthouse and so on); a vessel that works on aids (`Buoy Tender`, `Buoy Layer`) is not one. Its icon is a bone-white ringed disc (`AID_TO_NAVIGATION_STYLE`, `src/data/vesselLabels.js`) instead of a chevron, never rotated, and its card, selected card and HUD readout (`src/layers/vessels/cards.js`) show its kind alone, whole, in that colour: no speed or heading, since a fixed mark has neither. AISStream subscribes to `AidsToNavigationReport` (message 21) by default, and the server names each report's aid type code (0 to 31) as its kind (`aidToNavigationTypeName`: `20` is `Cardinal Mark N`) rather than reading it as a ship type, and its name runs on into the report's `NameExtension`. A virtual aid (the report's `VirtualAtoN` flag: a mark broadcast where nothing physical stands) carries `virtual: true` on its row, and on its vessel source record (the live-source contract's `virtual`, `src/sources/live/contract.js`, false unless a source says true; any source may set it). It keeps its disc but never gets a model (`vesselModelSpec` returns null for it, and the vessel layer gathers no model item for it), and its card and readout add `VIRTUAL` after its kind. `aisStreamRows` (`server/providers/vessels/ais-store.js`) puts every vessel ahead of every aid, so a capped request (the layer asks for 12,000 rows) never gives up a ship for a buoy. The `vessels_in_area` tool (and the brief built on it) counts ships only: it leaves aids out of its rows, counts, breakdowns and speed stats. A transit vehicle's model follows its layer mode (bus, tram, subway, rail or ferry; a vehicle of `unknown` mode keeps its icon), a train's its rail category and mode (rail, metro or tram). Neither the transit nor the rail sources carry a GTFS `route_type` or a finer mode (monorail, gondola, funicular, cable car), so the set's models for those and their `transit.elevation` lifts are not reached by any live source today. Both stand on the road or rail top they are drawn on, without the 1.5 m `GROUND_FLOOR_LIFT_M` their icons carry, and are painted in their mode or category colour where the model's `_TINT` attribute marks it. A vessel model is clipped at its waterline (one clipping plane per model, at the model origin's horizontal plane), so its hull below the water never shows through a plain globe, which Cesium does not depth-test models against. Under the NVG/FLIR styles (the Flights `irBoost` parameter) these models render unlit flat white, as aircraft models do. Each vehicle's icon stays the visual until its model is loaded, ready and placed; a model is picked as its icon is, and a vehicle drawn as its model keeps its selection card and its place in the detection overlay. +- Vessels, Transit and Rail draw fleet models under the same DISPLAY rail `3D` toggle, at the same altitude ceiling, caps and add/keep radii as the aircraft (`FLEET_MODEL_POLICY`, `src/layers/flights/policy.js`; `createFleetModelLayer`, `src/data/fleetModelInstances.js`). A vessel's model follows its AIS ship type and is drawn at its reported length and beam (AIS static dimensions A+B and C+D, now carried on vessel rows as `length` and `beam`), standing at the sea surface, heading by true heading then course. An aid to navigation is not a hull: a vessel record whose type names a buoy, beacon, mark, RACON or light, or whose MMSI is an aid-to-navigation station's (`99MIDxxxx`), is `isAidToNavigation` (`src/data/vesselTypes.js`) and is drawn as the set's `buoys` model of the IALA mark its type names (`aidToNavigationModel`, `src/data/fleetModels.js`: cardinal N/E/S/W, port or starboard hand, preferred channel by its side, safe water, isolated danger, special mark; a beacon, light, light vessel, RACON or reference point with no mark of its own is the special mark), else a red can (`DEFAULT_AID_MODEL`), at its built size and facing north whatever heading it reports. A type is an aid's when it is one of the 32 kinds an aid report names or uses a word for one (buoy, beacon, cardinal, safe water, RACON, lighthouse and so on); a vessel that works on aids (`Buoy Tender`, `Buoy Layer`) is not one. Its icon is a bone-white ringed disc (`AID_TO_NAVIGATION_STYLE`, `src/data/vesselLabels.js`) instead of a chevron, never rotated, and its card, selected card and HUD readout (`src/layers/vessels/cards.js`) show its kind alone, whole, in that colour: no speed or heading, since a fixed mark has neither. AISStream subscribes to `AidsToNavigationReport` (message 21) by default, and the server names each report's aid type code (0 to 31) as its kind (`aidToNavigationTypeName`: `20` is `Cardinal Mark N`) rather than reading it as a ship type, and its name runs on into the report's `NameExtension`. A virtual aid (the report's `VirtualAtoN` flag: a mark broadcast where nothing physical stands) carries `virtual: true` on its row, and on its vessel source record (the live-source contract's `virtual`, `src/sources/live/contract.js`, false unless a source says true; any source may set it). It keeps its disc but never gets a model (`vesselModelSpec` returns null for it, and the vessel layer gathers no model item for it), and its card and readout add `VIRTUAL` after its kind. `aisStreamRows` (`server/providers/vessels/ais-store.js`) puts every vessel ahead of every aid, so a capped request (the layer asks for 12,000 rows) never gives up a ship for a buoy. The `vessels_in_area` tool (and the brief built on it) counts ships only: it leaves aids out of its rows, counts, breakdowns and speed stats. A transit vehicle's model follows its route's GTFS `route_type` when its record carries one and that type is a kind of the vehicle's mode (`types.json` `transit.route_types`: 200 a coach, 101 a high-speed set, 106 a regional DMU, 710 a double-decker), else its layer mode (`transit.modes`: bus, trolleybus, tram, cable car, subway, monorail, rail, funicular, gondola or ferry; a vehicle of `unknown` mode keeps its icon); a fleet hint that overrules the route (a bus on a tram route) leaves the type unused. A monorail and a gondola are raised by their `transit.elevation` lifts. A train's model follows its rail category and mode (rail, metro or tram). The bundled GTFS-Realtime proxy carries no route type, so its vehicles draw their mode's model; a source that adds `routeType` reaches the finer ones. Both stand on the road or rail top they are drawn on, without the 1.5 m `GROUND_FLOOR_LIFT_M` their icons carry, and are painted in their mode or category colour where the model's `_TINT` attribute marks it. A vessel model is clipped at its waterline (one clipping plane per model, at the model origin's horizontal plane), so its hull below the water never shows through a plain globe, which Cesium does not depth-test models against. Under the NVG/FLIR styles (the Flights `irBoost` parameter) these models render unlit flat white, as aircraft models do. Each vehicle's icon stays the visual until its model is loaded, ready and placed; a model is picked as its icon is, and a vehicle drawn as its model keeps its selection card and its place in the detection overlay. - **Aircraft models skip Cesium's dynamic environment map (2026-10-24).** Flights, Military Flights and Local ADS-B pass `environmentMapOptions: AIRCRAFT_ENVIRONMENT_MAP_OPTIONS` (`{ enabled: false }`, `src/data/aircraftModelLighting.js`) to every drawn model. Otherwise each `Model` renders the sky around it and reads it back from the GPU (`readPixels`) when it is first placed, and again whenever it moves more than 1 km, the scene's atmosphere settings change, or (under sunlight dynamic lighting) an hour of scene time passes (`DynamicEnvironmentMapManager`, Cesium 1.138). The models are lit from Cesium's default spherical harmonics instead, with no specular environment map, so the sky's model-lighting cube map no longer reaches aircraft. `src/data/aircraftModelLighting.test.mjs` pins the option at every drawn model call; every model is built from the fleet set loaded up front, so there is no separate preload. - The DISPLAY-rail `3D` toggle is the user-facing activation path for both aircraft layers. Their small approved GLBs build their render resources without Cesium's frame-spread job queue, preventing continuous Photorealistic 3D Tiles streaming from starving model readiness; model caps, tracking, camera, and fallback billboards are unchanged. - **The `3D` toggle DEFAULTS ON in `proximity` on a first run.** Proximity is itself the budget — models appear only below `MODEL_ALT_CEIL_M` and only for the nearest `MODEL_MAX` in view — so the default costs nothing at globe scale, and `all` remains a deliberate opt-in. A fresh boot runs NO layer-state restoration (`LayerStateCoordinator.start()` returns early with neither a share payload nor stored state), so four independent initializers decide what a first-run operator sees and must agree: `booleanOption('models3d', 'e', true)` in `src/data/layerState.js`, `_models3dEnabled = true` in BOTH flight layers, `this._models3dEnabled = true` in `src/ui/aircraftDisplay.js`, and the `active` / `visible` classes on `#models3d-toggle` / `#models3d-mode-row` in `index.html`. All four are pinned together in `src/data/layerState.test.mjs`. Explicit state still wins: because the codec omits default-valued options, `models3d: false` is now what travels in a link (`lo=…f.e.0`) and restores OFF at both aircraft layers. **Consequence for returning users:** a stored `gev:layer-state:v2` blob is a FULL options snapshot, so a session that wrote one before this change carries `models3d:false` and keeps 3D off until the operator flips it (or clears the key) — the durable snapshot is treated as the recipient's own state, by design. diff --git a/server/providers/transitHistory.test.mjs b/server/providers/transitHistory.test.mjs index 551fee7a7..aeed8308a 100644 --- a/server/providers/transitHistory.test.mjs +++ b/server/providers/transitHistory.test.mjs @@ -202,3 +202,25 @@ test('a feed fleet-number mode outranks its route mode in the epoch context', (t assert.equal(h.get('ttc', '4507', 100000).epochs[0].mode, 'tram'); assert.equal(h.get('ttc', 'x1', 100000).epochs[0].mode, 'tram'); }); +test('the epoch mode is the live mode: a route type, else hints, else the default', (t) => { + const h = history(t); + const pid = { + id: 'pid', + historyRetention: true, + defaultMode: 'bus', + routeMode: (route) => (route === 'L22' ? 'tram' : 'unknown'), + }; + h.ingest( + pid, + [ + row(100000, 'a', { routeId: 'L58', routeType: 11 }), + row(100000, 'b', { routeId: 'L22' }), + row(100000, 'c', { routeId: 'L9999' }), + ], + 100000, + ); + assert.equal(h.get('pid', 'a', 100000).epochs[0].mode, 'trolleybus'); + assert.equal(h.get('pid', 'b', 100000).epochs[0].mode, 'tram'); + // A hint that knows nothing leaves the default, as the live layer does. + assert.equal(h.get('pid', 'c', 100000).epochs[0].mode, 'bus'); +}); diff --git a/src/data/fleetModels.test.mjs b/src/data/fleetModels.test.mjs index d48e744c1..315c53746 100644 --- a/src/data/fleetModels.test.mjs +++ b/src/data/fleetModels.test.mjs @@ -25,6 +25,7 @@ import { vesselModelSpec, } from './fleetModels.js'; import { FLEET_TRAIL_ANCHORS } from './fleetTrailAnchors.js'; +import { TRANSIT_MODES } from './transitFeeds.js'; import { centrelineSegments, distanceToSurface, @@ -444,6 +445,38 @@ test('aids to navigation are the buoy of the mark their type names', () => { } }); +test('every transit mode but unknown draws its own model, and a route type a finer one', () => { + for (const mode of TRANSIT_MODES.filter((m) => m !== 'unknown')) { + assert.ok(types.transit.modes[mode], `${mode} has a model`); + assert.equal( + resolveTransit(types, { mode }).model, + types.transit.modes[mode][0], + ); + } + for (const [mode, model] of [ + ['trolleybus', 'trolleybus'], + ['cable_tram', 'cable_tram'], + ['aerial_lift', 'gondola'], + ['funicular', 'funicular'], + ['monorail', 'monorail'], + ]) + assert.equal(resolveTransit(types, { mode }).model, model, mode); + // A route type outranks the mode: a coach and a high-speed set are still + // the bus and rail modes. + for (const [routeType, mode, model] of [ + [200, 'bus', 'coach'], + [101, 'rail', 'high_speed'], + [106, 'rail', 'regional_dmu'], + [710, 'bus', 'double_decker'], + ]) + assert.equal(resolveTransit(types, { routeType, mode }).model, model); + // A type the table lacks falls back to the mode. + assert.equal( + resolveTransit(types, { routeType: 300, mode: 'rail' }).model, + 'commuter_emu', + ); +}); + test('transit specs: rail category and mode, then route type, then mode, then the default', () => { assert.deepEqual(resolveTransit(types, { railCategory: 'national' }), { model: 'intercity', diff --git a/src/data/transitFeeds.js b/src/data/transitFeeds.js index 42f399d77..3e9f9cebc 100644 --- a/src/data/transitFeeds.js +++ b/src/data/transitFeeds.js @@ -29,12 +29,21 @@ import { RIO_ROUTE_NAMES } from './rioRouteNames.js'; * node:test. No Cesium, no Node built-ins. */ -/** Transit modes the layer colors. `routeMode` hints refine a feed's default. */ +/** + * Transit modes the layer colors: the GTFS basic route types, by name. A + * vehicle's GTFS `route_type` settles its mode when its record carries one; + * otherwise `routeMode` hints refine a feed's default. + */ export const TRANSIT_MODES = Object.freeze([ 'bus', + 'trolleybus', 'tram', + 'cable_tram', 'subway', + 'monorail', 'rail', + 'funicular', + 'aerial_lift', 'ferry', 'unknown', ]); @@ -42,13 +51,81 @@ export const TRANSIT_MODES = Object.freeze([ /** Per-mode icon used in labels and the selection card. */ export const TRANSIT_MODE_ICON = Object.freeze({ bus: '🚌', + trolleybus: '🚎', tram: '🚊', + cable_tram: '🚋', subway: '🚇', + monorail: '🚝', rail: '🚆', + funicular: '🚞', + aerial_lift: '🚡', ferry: '⛴️', unknown: '🚏', }); +/** The basic GTFS route types (0–7, 11, 12) by mode. */ +const BASIC_ROUTE_TYPE_MODES = Object.freeze({ + 0: 'tram', + 1: 'subway', + 2: 'rail', + 3: 'bus', + 4: 'ferry', + 5: 'cable_tram', + 6: 'aerial_lift', + 7: 'funicular', + 11: 'trolleybus', + 12: 'monorail', +}); + +/** + * A GTFS `route_type` as an integer: a basic type (0–12) or an extended one + * (100–1799), as a number or its decimal text. Null for anything else. + * @param {unknown} value + * @returns {number|null} + */ +export function transitRouteType(value) { + const n = + typeof value === 'number' + ? value + : typeof value === 'string' && /^\d{1,4}$/.test(value.trim()) + ? Number(value.trim()) + : NaN; + return Number.isInteger(n) && n >= 0 && n < 1800 ? n : null; +} + +/** + * The mode of a GTFS `route_type`: the basic types, and the extended ones + * mapped to the basic mode they are a kind of (a coach, 200, is a bus; a + * high-speed train, 101, is rail; 405 is a monorail). Air, taxi and other + * services, and a value GTFS does not define, are `unknown`. + * @param {unknown} routeType + * @returns {string} One of TRANSIT_MODES. + */ +export function transitModeOfRouteType(routeType) { + const n = transitRouteType(routeType); + if (n === null) return 'unknown'; + if (n < 100) return BASIC_ROUTE_TYPE_MODES[n] ?? 'unknown'; + if (n === 405) return 'monorail'; + const family = Math.floor(n / 100); + return ( + { + 1: 'rail', // railway + 2: 'bus', // coach + 3: 'rail', // suburban railway + 4: 'subway', // urban railway + 5: 'subway', // metro + 6: 'subway', // underground + 7: 'bus', + 8: 'trolleybus', + 9: 'tram', + 10: 'ferry', // water transport + 12: 'ferry', // ferry + 13: 'aerial_lift', + 14: 'funicular', + }[family] ?? 'unknown' + ); +} + /** * MBTA route ids are human-readable and mode-typed: rapid-transit lines carry * colour names, commuter rail is prefixed `CR-`, ferries `Boat-`, buses are @@ -443,7 +520,7 @@ const liaRouteLabel = routeIdPattern(/^8-0*(\w.*)$/); function liaRouteMode(routeId) { if (!routeId) return 'unknown'; const line = liaRouteLabel(routeId); - if (line === 'FUNI') return 'rail'; + if (line === 'FUNI') return 'funicular'; return /^[AB]$/.test(line) ? 'tram' : 'bus'; } @@ -474,6 +551,7 @@ function astuceRouteLabel(routeId) { * Prague PID route ids are `L` plus a number whose range says what runs it, * per PID's GTFS routes.txt (data.pid.cz, checked 2026-11-09): 1–99 trams * (50–59 trolleybuses, 49 the Petřín funicular `LD`), 100–990 buses (the + * trolleybus routes 232 and 275 among them, GTFS route type 11; the * 800s are the X replacement lines, `L803` is X3), 991–993 metro A–C, * 1000s and 1100s the S and R trains (`L1004` is S4, `L1109` R9), the rest * of 1200–1399 other trains, 1700s town buses, 1800s the P ferries, and from @@ -487,10 +565,11 @@ function pidRoute(routeId) { if (!match) return { mode: 'unknown', label: routeId }; const n = Number(match[1]); // i18n-ignore: line code, as signed - if (n === 49) return { mode: 'rail', label: 'LD' }; - if (n >= 50 && n <= 59) return { mode: 'bus', label: String(n) }; + if (n === 49) return { mode: 'funicular', label: 'LD' }; + if (n >= 50 && n <= 59) return { mode: 'trolleybus', label: String(n) }; if (n < 100) return { mode: 'tram', label: String(n) }; if (n >= 800 && n < 900) return { mode: 'bus', label: `X${n - 800}` }; + if (n === 232 || n === 275) return { mode: 'trolleybus', label: String(n) }; if (n < 991) return { mode: 'bus', label: String(n) }; // i18n-ignore: metro line letters, as signed if (n <= 993) return { mode: 'subway', label: 'ABC'[n - 991] }; @@ -512,6 +591,102 @@ function pidRouteLabel(routeId) { return pidRoute(routeId).label; } +/** + * A feed's route hint from its static GTFS routes.txt: the route ids of + * every mode but `bus`, which is everything else. + * @param {Record} idsByMode + * @returns {(routeId: string|null) => string} + */ +function routeModeTable(idsByMode) { + const modes = new Map( + Object.entries(idsByMode).flatMap(([mode, ids]) => + ids.map((id) => [id, mode]), + ), + ); + return (routeId) => (routeId ? (modes.get(routeId) ?? 'bus') : 'unknown'); +} + +/** + * Bucharest TPBI by route id, from its routes.txt (checked 2026-11-14): the + * trams (route type 0), metro lines M1–M5 (1) and trolleybuses (11); every + * other route is a bus. Realtime route ids are the static ones. + */ +const tpbiRouteMode = routeModeTable({ + tram: [ + '54', + '55', + '57', + '61', + '63', + '65', + '66', + '67', + '68', + '69', + '70', + '814', + '915', + '1013', + ], + subway: ['968', '969', '970', '971', '999'], + trolleybus: [ + '72', + '73', + '74', + '75', + '76', + '78', + '81', + '83', + '84', + '85', + '86', + '87', + '247', + '910', + '916', + '924', + '925', + ], +}); + +/** + * Cluj-Napoca CTP by route id, from its routes.txt (checked 2026-11-14): the + * trams 100–102L (route type 0) and the trolleybuses (11). + */ +const ctpClujRouteMode = routeModeTable({ + tram: ['2', '3', '4', '5'], + trolleybus: [ + '1', + '10', + '14', + '15', + '22', + '36', + '49', + '53', + '54', + '55', + '117', + '119', + '120', + '153', + '166', + '187', + ], +}); + +/** + * Turin GTT by route id, from its routes.txt (checked 2026-11-14): the trams + * (route type 0), metro M1, and the Sassi–Superga rack tramway `79U`, which + * the file types as a funicular (7). + */ +const gttRouteMode = routeModeTable({ + tram: ['3U', '4U', '7U', '9U', '10U', '13U', '15U', '16CDU', '16CSU'], + subway: ['METROU'], + funicular: ['79U'], +}); + /** * Bordeaux TBM tram and boat lines by route id, from TBM's static GTFS * routes.txt (checked 2026-11-09): the trams are numbered ids, not letters. @@ -571,6 +746,7 @@ function transitFeed(fields) { * url: string, headers?: Record, * license: string, licenseUrl: string, attribution: string, * defaultMode: string, routeMode?: (routeId: string|null) => string, + * routeCorrections?: Readonly>, * speedUnit?: 'km/h', refreshMs?: number, sourceUrl?: string, * creditDated?: boolean, * }>>} @@ -579,6 +755,9 @@ function transitFeed(fields) { * stretches the proxy's cache for an upstream that rate-limits below one * request per 15 s TTL. `sourceUrl` and `creditDated` add a link and a date * to the credit for licences that ask for them (`transitFeedCredit`). + * `routeCorrections` names the routes whose `route_type` the operator's own + * routes.txt gets wrong, `route_id` to the mode they really are; a correction + * outranks the route type, which would otherwise outrank the route hint. */ export const TRANSIT_FEED_REGISTRY = Object.freeze([ Object.freeze({ @@ -1264,6 +1443,7 @@ export const TRANSIT_FEED_REGISTRY = Object.freeze([ note: 'Keyless public endpoint from the metropolitan transport authority; no licence found. Same basis as Metro Transit and OVapi.', }, defaultMode: 'bus', + routeMode: tpbiRouteMode, }), transitFeed({ id: 'roma-mobilita', @@ -1296,6 +1476,7 @@ export const TRANSIT_FEED_REGISTRY = Object.freeze([ note: 'Official keyless endpoint; no licence found. Same basis as Metro Transit and OVapi. Route ids append `U` for urban lines.', }, defaultMode: 'bus', + routeMode: gttRouteMode, routeLabel: gttRouteLabel, }), transitFeed({ @@ -1401,6 +1582,7 @@ export const TRANSIT_FEED_REGISTRY = Object.freeze([ note: 'Keyless; no licence found. Same basis as Metro Transit and OVapi.', }, defaultMode: 'bus', + routeMode: ctpClujRouteMode, }), transitFeed({ id: 'ctp-iasi', @@ -1567,6 +1749,8 @@ export const TRANSIT_FEED_REGISTRY = Object.freeze([ defaultMode: 'bus', routeLabel: liaRouteLabel, routeMode: liaRouteMode, + // LiA's routes.txt types the funicular (`8-FUNI`) as a bus (3). + routeCorrections: Object.freeze({ '8-FUNI': 'funicular' }), }), transitFeed({ id: 'filbleu-tours', @@ -1664,54 +1848,89 @@ export function transitFeedsInRange(lat, lon, slackKm = 0) { } /** - * The feed's own hint for a vehicle: its fleet number when the feed maps - * those (`vehicleMode`), else its route (`routeMode`). Null when neither knows. + * What settles a vehicle's mode, most specific first: the feed's fleet hint + * (`vehicleMode`, which knows a bus standing in on a tram route), else the + * feed's correction for a route its routes.txt mistypes (`routeCorrections`), + * else the GTFS `route_type` of its route when the record carries one, else + * the feed's route hint (`routeMode`). Null when none of them knows. * @param {object} feed Registry entry. * @param {string|null} routeId * @param {string|null} vehicleId + * @param {unknown} routeType GTFS `route_type`, when the record has one. * @returns {string|null} */ -function hintedMode(feed, routeId, vehicleId) { +function hintedMode(feed, routeId, vehicleId, routeType) { const byVehicle = typeof feed?.vehicleMode === 'function' ? feed.vehicleMode(vehicleId) : null; if (byVehicle && byVehicle !== 'unknown') return byVehicle; + const corrections = feed?.routeCorrections; + if (routeId && corrections && Object.hasOwn(corrections, routeId)) + return corrections[routeId]; + const byType = transitModeOfRouteType(routeType); + if (byType !== 'unknown') return byType; return typeof feed?.routeMode === 'function' ? feed.routeMode(routeId) : null; } /** - * Mode for a vehicle: the feed's fleet or route hint when it has one, else - * its default. + * Mode for a vehicle: its fleet hint, route type or route hint when one + * knows ({@link hintedMode}), else its feed's default. * @param {object} feed Registry entry. * @param {string|null} routeId GTFS route_id from the vehicle's trip. * @param {string|null} [vehicleId] GTFS-RT vehicle id. + * @param {unknown} [routeType] GTFS `route_type` of the route, when known. * @returns {string} One of TRANSIT_MODES. */ -export function transitModeFor(feed, routeId, vehicleId = null) { - const hinted = hintedMode(feed, routeId, vehicleId); +export function transitModeFor( + feed, + routeId, + vehicleId = null, + routeType = null, +) { + const hinted = hintedMode(feed, routeId, vehicleId, routeType); const mode = hinted && hinted !== 'unknown' ? hinted : feed?.defaultMode || 'unknown'; return TRANSIT_MODES.includes(mode) ? mode : 'unknown'; } /** - * Whether the mode came from the route id rather than the feed's default. A - * default is a guess about a fleet — TransLink's is "bus" while it publishes - * rail in the same feed — so a consumer judging physical plausibility must - * not hold a defaulted vehicle to a bus's limits. + * Whether the mode came from the vehicle, its route type or its route id + * rather than the feed's default. A default is a guess about a fleet — + * TransLink's is "bus" while it publishes rail in the same feed — so a + * consumer judging physical plausibility must not hold a defaulted vehicle + * to a bus's limits. * @param {object} feed Registry entry. * @param {string|null} routeId * @param {string|null} [vehicleId] + * @param {unknown} [routeType] * @returns {boolean} */ -export function transitModeResolved(feed, routeId, vehicleId = null) { - const hinted = hintedMode(feed, routeId, vehicleId); +export function transitModeResolved( + feed, + routeId, + vehicleId = null, + routeType = null, +) { + const hinted = hintedMode(feed, routeId, vehicleId, routeType); return ( Boolean(hinted) && hinted !== 'unknown' && TRANSIT_MODES.includes(hinted) ); } +/** + * The route type a vehicle's model is chosen by: its record's, when that type + * is a kind of the mode it was given. A fleet hint can overrule the route (a + * bus on a tram route), and then the route's type does not describe it. + * @param {string} mode The vehicle's mode ({@link transitModeFor}). + * @param {unknown} routeType + * @returns {number|null} + */ +export function transitModelRouteType(mode, routeType) { + const n = transitRouteType(routeType); + return n !== null && transitModeOfRouteType(n) === mode ? n : null; +} + /** * The route as a rider would say it. Most feeds publish that already, so this * is identity for them; a feed that publishes internal keys supplies its own diff --git a/src/data/transitFeeds.test.mjs b/src/data/transitFeeds.test.mjs index 75a902728..37ad82a56 100644 --- a/src/data/transitFeeds.test.mjs +++ b/src/data/transitFeeds.test.mjs @@ -11,9 +11,13 @@ import { haversineKm, publicTransitCatalog, transitFeedsInRange, + TRANSIT_MODE_ICON, transitModeFor, + transitModeOfRouteType, transitModeResolved, + transitModelRouteType, transitRouteLabel, + transitRouteType, } from './transitFeeds.js'; import { RIO_ROUTE_NAMES } from './rioRouteNames.js'; @@ -729,8 +733,9 @@ test('Prague route-id ranges give metro, trains, ferries and trolleybuses their transitRouteLabel(feed, routeId), ]; assert.deepEqual(read('L22'), ['tram', '22']); - assert.deepEqual(read('L58'), ['bus', '58'], 'trolleybus'); - assert.deepEqual(read('L49'), ['rail', 'LD'], 'Petřín funicular'); + assert.deepEqual(read('L58'), ['trolleybus', '58']); + assert.deepEqual(read('L275'), ['trolleybus', '275'], 'route type 11'); + assert.deepEqual(read('L49'), ['funicular', 'LD'], 'Petřín funicular'); assert.deepEqual(read('L135'), ['bus', '135']); assert.deepEqual(read('L803'), ['bus', 'X3']); assert.deepEqual(read('L991'), ['subway', 'A']); @@ -767,7 +772,7 @@ test('Rouen Métro and Calypso are not buses; Le Havre reads its own ids', () => assert.equal(transitModeFor(feed, 'TCAR:93'), 'bus'); assert.equal(transitRouteLabel(feed, 'TAE:F'), 'F'); const lia = getTransitFeed('lia-le-havre'); - assert.equal(transitModeFor(lia, '8-FUNI'), 'rail'); + assert.equal(transitModeFor(lia, '8-FUNI'), 'funicular'); assert.equal(transitRouteLabel(lia, '8-C3'), 'C3'); assert.equal(transitRouteLabel(lia, '8-09'), '9'); assert.equal(transitRouteLabel(lia, '8-A'), 'A'); @@ -778,3 +783,114 @@ test('data.gov.my feeds ask the proxy for no more than its 4 a minute', () => { assert.ok(getTransitFeed(id).refreshMs >= 30_000, id); } }); + +test('a GTFS route type names its mode, basic and extended alike', () => { + for (const [routeType, mode] of [ + [0, 'tram'], + [1, 'subway'], + [2, 'rail'], + [3, 'bus'], + [4, 'ferry'], + [5, 'cable_tram'], + [6, 'aerial_lift'], + [7, 'funicular'], + [11, 'trolleybus'], + [12, 'monorail'], + [101, 'rail'], + [106, 'rail'], + [200, 'bus'], + [300, 'rail'], + [401, 'subway'], + [405, 'monorail'], + [702, 'bus'], + [800, 'trolleybus'], + [900, 'tram'], + [1000, 'ferry'], + [1200, 'ferry'], + [1300, 'aerial_lift'], + [1400, 'funicular'], + ['11', 'trolleybus'], + ]) + assert.equal(transitModeOfRouteType(routeType), mode, String(routeType)); + // Air, taxi and other services, and values GTFS does not define. + for (const other of [8, 1100, 1500, 1700, 1800, -1, 2.5, '', 'tram', null]) + assert.equal(transitModeOfRouteType(other), 'unknown', String(other)); + assert.equal(transitRouteType(' 200 '), 200); + assert.equal(transitRouteType('2e2'), null); +}); + +test('every mode has an icon, and every mode a route type names is a mode', () => { + for (const mode of TRANSIT_MODES) assert.ok(TRANSIT_MODE_ICON[mode], mode); + for (let routeType = 0; routeType < 1800; routeType++) + assert.ok(TRANSIT_MODES.includes(transitModeOfRouteType(routeType))); +}); + +test('a route type settles the mode before a route hint or the default', () => { + const mbta = getTransitFeed('mbta'); + // The hint calls every numbered MBTA route a bus; a route type is finer. + assert.equal(transitModeFor(mbta, '71'), 'bus'); + assert.equal(transitModeFor(mbta, '71', 'y1', 11), 'trolleybus'); + assert.equal(transitModeResolved(mbta, '71', 'y1', 11), true); + // A default-only feed is resolved by a route type alone. + const durham = getTransitFeed('durham-region'); + assert.equal(transitModeResolved(durham, '915', 'b1'), false); + assert.equal(transitModeFor(durham, '915', 'b1', 200), 'bus'); + assert.equal(transitModeResolved(durham, '915', 'b1', 200), true); + // A type that names no mode leaves the hints in charge. + assert.equal(transitModeFor(mbta, 'Red', null, 1700), 'subway'); + assert.equal(transitModeFor(mbta, 'Red', null, 'x'), 'subway'); +}); + +test('a fleet hint outranks the route type, and then the type picks no model', () => { + const ttc = getTransitFeed('ttc-toronto'); + // A bus standing in on the 501 streetcar route (route type 0). + const mode = transitModeFor(ttc, '501', '8400', 0); + assert.equal(mode, 'bus'); + assert.equal(transitModelRouteType(mode, 0), null); + assert.equal(transitModelRouteType('tram', 0), 0); + assert.equal(transitModelRouteType('bus', 200), 200, 'a coach is a bus'); + assert.equal(transitModelRouteType('bus', null), null); +}); + +test('a route correction outranks a mistyped route type, and only for its route', () => { + const lia = getTransitFeed('lia-le-havre'); + // LiA's routes.txt types the funicular as a bus (3). + assert.equal(transitModeFor(lia, '8-FUNI', null, 3), 'funicular'); + assert.equal(transitModeResolved(lia, '8-FUNI', null, 3), true); + // A correction is a mode, so the bus type picks no model for it. + assert.equal(transitModelRouteType('funicular', 3), null); + // Every other route still takes its route type. + assert.equal(transitModeFor(lia, '8-A', null, 0), 'tram'); + assert.equal(transitModeFor(lia, '8-C3', null, 3), 'bus'); + assert.equal(transitModeFor(lia, null, null, 3), 'bus'); + // Corrections are narrow: a few named routes, each to a known mode. + for (const feed of TRANSIT_FEED_REGISTRY) { + if (!feed.routeCorrections) continue; + assert.ok(Object.isFrozen(feed.routeCorrections), feed.id); + for (const [route, mode] of Object.entries(feed.routeCorrections)) { + assert.ok(TRANSIT_MODES.includes(mode), `${feed.id} ${route}`); + assert.notEqual(mode, 'unknown', `${feed.id} ${route}`); + } + } + // An inherited key is not a correction. + assert.equal(transitModeFor(lia, 'toString', null, 3), 'bus'); +}); + +// Route ids as each realtime feed and its operator's routes.txt carried them +// on 2026-11-14. +test('Bucharest, Cluj and Turin route ids give trams, trolleybuses and a funicular', () => { + const mode = (id, routeId) => transitModeFor(getTransitFeed(id), routeId); + assert.equal(mode('tpbi-bucuresti', '85'), 'trolleybus', 'line 74'); + assert.equal(mode('tpbi-bucuresti', '1013'), 'tram', 'line 4'); + assert.equal(mode('tpbi-bucuresti', '968'), 'subway', 'M1'); + assert.equal(mode('tpbi-bucuresti', '828'), 'bus'); + assert.equal(mode('tpbi-bucuresti', 'PV1_407'), 'bus'); + assert.equal(mode('ctp-cluj', '1'), 'trolleybus'); + assert.equal(mode('ctp-cluj', '2'), 'tram', 'line 100'); + assert.equal(mode('ctp-cluj', '6'), 'bus', 'line 19'); + assert.equal(mode('gtt-torino', '79U'), 'funicular', 'Sassi–Superga'); + assert.equal(mode('gtt-torino', '16CDU'), 'tram'); + assert.equal(mode('gtt-torino', 'METROU'), 'subway'); + assert.equal(mode('gtt-torino', '6U'), 'bus'); + assert.equal(mode('gtt-torino', null), 'bus', 'no route: the default'); +}); diff --git a/src/data/transitIcons.js b/src/data/transitIcons.js index c6ad963e1..deb82656c 100644 --- a/src/data/transitIcons.js +++ b/src/data/transitIcons.js @@ -21,7 +21,9 @@ import { * at the ~18 px the fleet renders at, by shape and not only by colour: a bus is * short and blunt, a tram is long and slender with articulation joints, a metro * car is squared off, a mainline train has a tapered nose, and a ferry is a - * hull with a bow. + * hull with a bow. A trolleybus trails its two poles, a cable car is a short + * single car, a monorail the slimmest bullet, a funicular hangs off its rope, + * and a gondola is a cabin on its cable. * * Interior detail is drawn with the same dark hairline as the edge — windscreen * lines, articulation joints, a deck line — because a solid dark panel would @@ -103,6 +105,49 @@ const HEADING_BODIES = { fill="white" ${STROKE}/> `, + // ── Trolleybus: a bus a little narrower, trailing the two trolley poles + // that reach back to its wires. Body and poles are one outline, so no + // edge is drawn across the body. + trolleybus: ` + + `, + + // ── Cable car (street cable railway): a short single car, under half a + // tram, with open platforms at both ends. + cable_tram: ` + + + `, + + // ── Monorail: the slimmest train in the set, a rounded bullet nose over + // its beam. + monorail: ` + + `, + + // ── Funicular: a squat car hauled by the rope at its upper end. + funicular: ` + + + `, + + // ── Gondola (aerial lift): a cabin hung on the cable that runs through + // it; the cabin's nose is its front. + aerial_lift: ` + `, + // ── Unknown: a plain marker with a nose and nothing else, so an // unclassified vehicle never pretends to be a mode it is not. unknown: ` @@ -146,6 +191,40 @@ const NEUTRAL_BODIES = { fill="white" ${STROKE}/> `, + trolleybus: ` + `, + + cable_tram: ` + + + `, + + monorail: ` + + `, + + funicular: ` + + + `, + + aerial_lift: ` + `, + unknown: ` { +test('every variant retains the specified final halo at both display sizes', async () => { const { presetSpriteScale, presetSpriteOutlinePx } = await import('./transitPresetStyle.js'); for (const kind of TRANSIT_ICON_KINDS) { @@ -97,7 +97,8 @@ test('all 72 variants retain the specified final halo at both display sizes', as } for (let i = 0; i < 100; i++) transitIcon('invalid', i, { haloScreenPx: i, screenPx: i }); - assert.equal(transitIconCacheSize(), 72); + // Every kind at two sizes, three profiles, with and without a course. + assert.equal(transitIconCacheSize(), TRANSIT_ICON_KINDS.length * 12); }); test('every mono raster preserves the normal silhouette mask and aspect at CRT display size', async () => { @@ -197,6 +198,11 @@ test('sensor raster halo stays dark across its screen-space band on a white roof subway: 11.5, rail: 10.5, ferry: 12.5, + trolleybus: 15, + cable_tram: 11, + monorail: 8.5, + funicular: 11, + aerial_lift: 12, unknown: 10, }; for (const selected of [false, true]) { diff --git a/src/data/transitPresetStyle.js b/src/data/transitPresetStyle.js index 5996d4d97..cfb39053a 100644 --- a/src/data/transitPresetStyle.js +++ b/src/data/transitPresetStyle.js @@ -60,9 +60,14 @@ const SPRITE_STYLE = Object.freeze({ outlinePx: 1.25, rgbaByMode: Object.freeze({ bus: Object.freeze([0, 255, 102, 1]), + trolleybus: Object.freeze([170, 255, 0, 1]), tram: Object.freeze([255, 179, 0, 1]), + cable_tram: Object.freeze([255, 120, 0, 1]), subway: Object.freeze([255, 59, 48, 1]), + monorail: Object.freeze([255, 64, 170, 1]), rail: Object.freeze([215, 139, 255, 1]), + funicular: Object.freeze([255, 214, 140, 1]), + aerial_lift: Object.freeze([90, 140, 255, 1]), ferry: Object.freeze([58, 208, 255, 1]), unknown: Object.freeze([255, 255, 255, 1]), }), @@ -72,9 +77,14 @@ const SPRITE_STYLE = Object.freeze({ /** Modes with a bracket tier of their own. */ const TIER_MODES = Object.freeze([ 'bus', + 'trolleybus', 'tram', + 'cable_tram', 'subway', + 'monorail', 'rail', + 'funicular', + 'aerial_lift', 'ferry', 'unknown', ]); @@ -128,7 +138,7 @@ export function presetSpriteOutlinePx(styleName, selected = false) { /** * Detection-overlay tier key for a transit mode. Every theme's `tiers` - * table carries these six, so the bracket colour is per mode in every + * table carries one per mode, so the bracket colour is per mode in every * preset. Unlike traffic, transit sets its tier keyless as well: the feeds * are keyless, and there is no separate keyless experience to keep * byte-identical. diff --git a/src/data/transitProxy.js b/src/data/transitProxy.js index 6b328e5a5..e601a592d 100644 --- a/src/data/transitProxy.js +++ b/src/data/transitProxy.js @@ -19,6 +19,7 @@ import { decodeVehiclePositions, } from './gtfsRealtime.js'; import { getTransitFeed } from './transitFeeds.js'; +export { transitModeFor, transitRouteType } from './transitFeeds.js'; /** Fresh window: a snapshot younger than this is served without refetching. */ export const TRANSIT_PROXY_TTL_MS = 15_000; diff --git a/src/i18n/locales/ar.json b/src/i18n/locales/ar.json index 44024e10f..ebdc0ef99 100644 --- a/src/i18n/locales/ar.json +++ b/src/i18n/locales/ar.json @@ -3962,5 +3962,10 @@ "Reset view reloads the app without the view restored from the address bar.": "تعيد «إعادة ضبط العرض» تحميل التطبيق دون العرض المستعاد من شريط العنوان.", "Reload": "إعادة التحميل", "Retry": "إعادة المحاولة", - "Reset view": "إعادة ضبط العرض" + "Reset view": "إعادة ضبط العرض", + "Trolleybus": "ترولي باص", + "Cable car": "ترام كابلي", + "Monorail": "قطار أحادي السكة", + "Funicular": "قطار جبلي مائل", + "Gondola": "تلفريك" } diff --git a/src/i18n/locales/de.json b/src/i18n/locales/de.json index cdb669452..c1bf7dd2a 100644 --- a/src/i18n/locales/de.json +++ b/src/i18n/locales/de.json @@ -3614,5 +3614,10 @@ "Reset view reloads the app without the view restored from the address bar.": "Ansicht zurücksetzen lädt die App ohne die aus der Adressleiste wiederhergestellte Ansicht neu.", "Reload": "Neu laden", "Retry": "Erneut versuchen", - "Reset view": "Ansicht zurücksetzen" + "Reset view": "Ansicht zurücksetzen", + "Trolleybus": "Oberleitungsbus", + "Cable car": "Kabelstraßenbahn", + "Monorail": "Einschienenbahn", + "Funicular": "Standseilbahn", + "Gondola": "Gondelbahn" } diff --git a/src/i18n/locales/es.json b/src/i18n/locales/es.json index b0d10ae06..1ba3bc810 100644 --- a/src/i18n/locales/es.json +++ b/src/i18n/locales/es.json @@ -3701,5 +3701,10 @@ "Reset view reloads the app without the view restored from the address bar.": "Restablecer la vista recarga la app sin la vista restaurada desde la barra de direcciones.", "Reload": "Recargar", "Retry": "Reintentar", - "Reset view": "Restablecer la vista" + "Reset view": "Restablecer la vista", + "Trolleybus": "Trolebús", + "Cable car": "Tranvía de cable", + "Monorail": "Monorraíl", + "Funicular": "Funicular", + "Gondola": "Góndola" } diff --git a/src/i18n/locales/fr.json b/src/i18n/locales/fr.json index ffe522ad9..cb82ee62b 100644 --- a/src/i18n/locales/fr.json +++ b/src/i18n/locales/fr.json @@ -3701,5 +3701,10 @@ "Reset view reloads the app without the view restored from the address bar.": "Réinitialiser la vue recharge l’app sans la vue restaurée depuis la barre d’adresse.", "Reload": "Recharger", "Retry": "Réessayer", - "Reset view": "Réinitialiser la vue" + "Reset view": "Réinitialiser la vue", + "Trolleybus": "Trolleybus", + "Cable car": "Tramway à câble", + "Monorail": "Monorail", + "Funicular": "Funiculaire", + "Gondola": "Télécabine" } diff --git a/src/i18n/locales/he.json b/src/i18n/locales/he.json index cfe612894..80943335a 100644 --- a/src/i18n/locales/he.json +++ b/src/i18n/locales/he.json @@ -3701,5 +3701,10 @@ "Reset view reloads the app without the view restored from the address bar.": "\"איפוס תצוגה\" טוען מחדש את האפליקציה בלי התצוגה ששוחזרה משורת הכתובת.", "Reload": "טען מחדש", "Retry": "נסה שוב", - "Reset view": "איפוס תצוגה" + "Reset view": "איפוס תצוגה", + "Trolleybus": "טרוליבוס", + "Cable car": "חשמלית כבלים", + "Monorail": "מונורייל", + "Funicular": "פוניקולר", + "Gondola": "רכבל" } diff --git a/src/i18n/locales/it.json b/src/i18n/locales/it.json index e8d939278..d68693f31 100644 --- a/src/i18n/locales/it.json +++ b/src/i18n/locales/it.json @@ -3701,5 +3701,10 @@ "Reset view reloads the app without the view restored from the address bar.": "Ripristina vista ricarica l’app senza la vista ripristinata dalla barra degli indirizzi.", "Reload": "Ricarica", "Retry": "Riprova", - "Reset view": "Ripristina vista" + "Reset view": "Ripristina vista", + "Trolleybus": "Filobus", + "Cable car": "Tram a fune", + "Monorail": "Monorotaia", + "Funicular": "Funicolare", + "Gondola": "Cabinovia" } diff --git a/src/i18n/locales/ja.json b/src/i18n/locales/ja.json index 8039831d8..6c36c71ce 100644 --- a/src/i18n/locales/ja.json +++ b/src/i18n/locales/ja.json @@ -3527,5 +3527,10 @@ "Reset view reloads the app without the view restored from the address bar.": "「ビューをリセット」は、アドレスバーから復元したビューを使わずにアプリを再読み込みします。", "Reload": "再読み込み", "Retry": "再試行", - "Reset view": "ビューをリセット" + "Reset view": "ビューをリセット", + "Trolleybus": "トロリーバス", + "Cable car": "ケーブルトラム", + "Monorail": "モノレール", + "Funicular": "ケーブルカー", + "Gondola": "ゴンドラ" } diff --git a/src/i18n/locales/pt.json b/src/i18n/locales/pt.json index 18b6d1dd2..8864f6d22 100644 --- a/src/i18n/locales/pt.json +++ b/src/i18n/locales/pt.json @@ -3701,5 +3701,10 @@ "Reset view reloads the app without the view restored from the address bar.": "Redefinir vista recarrega o app sem a vista restaurada da barra de endereços.", "Reload": "Recarregar", "Retry": "Tentar novamente", - "Reset view": "Redefinir vista" + "Reset view": "Redefinir vista", + "Trolleybus": "Trólebus", + "Cable car": "Bonde a cabo", + "Monorail": "Monotrilho", + "Funicular": "Funicular", + "Gondola": "Teleférico" } diff --git a/src/i18n/locales/ru.json b/src/i18n/locales/ru.json index b58d78d26..37c6db315 100644 --- a/src/i18n/locales/ru.json +++ b/src/i18n/locales/ru.json @@ -3788,5 +3788,10 @@ "Reset view reloads the app without the view restored from the address bar.": "«Сбросить вид» перезагружает приложение без вида, восстановленного из адресной строки.", "Reload": "Перезагрузить", "Retry": "Повторить", - "Reset view": "Сбросить вид" + "Reset view": "Сбросить вид", + "Trolleybus": "Троллейбус", + "Cable car": "Канатный трамвай", + "Monorail": "Монорельс", + "Funicular": "Фуникулёр", + "Gondola": "Канатная дорога" } diff --git a/src/i18n/locales/sv.json b/src/i18n/locales/sv.json index bd1f25a7e..b1c9887e3 100644 --- a/src/i18n/locales/sv.json +++ b/src/i18n/locales/sv.json @@ -3614,5 +3614,10 @@ "Reset view reloads the app without the view restored from the address bar.": "”Återställ vy” laddar om appen utan vyn som återställdes från adressfältet.", "Reload": "Ladda om", "Retry": "Försök igen", - "Reset view": "Återställ vy" + "Reset view": "Återställ vy", + "Trolleybus": "Trådbuss", + "Cable car": "Kabelspårvagn", + "Monorail": "Enskensbana", + "Funicular": "Bergbana", + "Gondola": "Kabinbana" } diff --git a/src/i18n/locales/uk.json b/src/i18n/locales/uk.json index 9506d0a31..f59df5624 100644 --- a/src/i18n/locales/uk.json +++ b/src/i18n/locales/uk.json @@ -3788,5 +3788,10 @@ "Reset view reloads the app without the view restored from the address bar.": "«Скинути вигляд» перезавантажує застосунок без вигляду, відновленого з адресного рядка.", "Reload": "Перезавантажити", "Retry": "Повторити", - "Reset view": "Скинути вигляд" + "Reset view": "Скинути вигляд", + "Trolleybus": "Тролейбус", + "Cable car": "Канатний трамвай", + "Monorail": "Монорейка", + "Funicular": "Фунікулер", + "Gondola": "Канатна дорога" } diff --git a/src/i18n/locales/zh-CN.json b/src/i18n/locales/zh-CN.json index f34c36028..2c4b5e9df 100644 --- a/src/i18n/locales/zh-CN.json +++ b/src/i18n/locales/zh-CN.json @@ -3527,5 +3527,10 @@ "Reset view reloads the app without the view restored from the address bar.": "“重置视图”会重新加载应用,不使用从地址栏恢复的视图。", "Reload": "重新加载", "Retry": "重试", - "Reset view": "重置视图" + "Reset view": "重置视图", + "Trolleybus": "无轨电车", + "Cable car": "缆索电车", + "Monorail": "单轨列车", + "Funicular": "缆索铁路", + "Gondola": "缆车" } diff --git a/src/i18n/locales/zh-Hant.json b/src/i18n/locales/zh-Hant.json index 0e01c7773..c9f352964 100644 --- a/src/i18n/locales/zh-Hant.json +++ b/src/i18n/locales/zh-Hant.json @@ -3527,5 +3527,10 @@ "Reset view reloads the app without the view restored from the address bar.": "「重置視圖」會重新加載應用,不使用從地址欄恢復的視圖。", "Reload": "重新加載", "Retry": "重試", - "Reset view": "重置視圖" + "Reset view": "重置視圖", + "Trolleybus": "無軌電車", + "Cable car": "纜索電車", + "Monorail": "單軌列車", + "Funicular": "纜索鐵路", + "Gondola": "纜車" } diff --git a/src/i18n/same-as-english.json b/src/i18n/same-as-english.json index b8a7eeb61..e95d5afc4 100644 --- a/src/i18n/same-as-english.json +++ b/src/i18n/same-as-english.json @@ -291,6 +291,7 @@ "FOV {value}°", "FT", "Folk", + "Funicular", "Funk", "GEO", "GOOGLE STREET VIEW", @@ -501,6 +502,7 @@ "MINI", "MISSION", "MM", + "Monorail", "MSG/S", "Metal", "Minimal", @@ -571,6 +573,7 @@ "TAGS · {tags}", "TEMP", "TLE", + "Trolleybus", "TYPE", "Tallinn", "Techno", @@ -950,6 +953,7 @@ "FOV {value}°", "FT", "Folk", + "Funicular", "Funk", "GEO", "GOOGLE STREET VIEW", diff --git a/src/layers/transit/ingestion.js b/src/layers/transit/ingestion.js index 3f5669c65..33723fef9 100644 --- a/src/layers/transit/ingestion.js +++ b/src/layers/transit/ingestion.js @@ -16,6 +16,7 @@ import { import { transitModeFor, transitModeResolved, + transitModelRouteType, } from '../../data/transitFeeds.js'; import { attachFloorToPlace, @@ -222,12 +223,19 @@ export function createIngestion({ state, services, parts, source }) { for (const record of records) { if (isStaleVehicleFix(record, now, fetchedAt)) continue; const key = transitVehicleKey(feed.id, record.id); - const mode = transitModeFor(feed, record.routeId, record.id); + const mode = transitModeFor( + feed, + record.routeId, + record.id, + record.routeType, + ); const modeInferred = !transitModeResolved( feed, record.routeId, record.id, + record.routeType, ); + const routeType = transitModelRouteType(mode, record.routeType); // A stamp ahead of the fetch is a clock fault; the fetch time bounds it. const stamped = vehicleReportTimeMs(record, fetchedAt); const reportAt = @@ -267,6 +275,7 @@ export function createIngestion({ state, services, parts, source }) { continue; } if (entry.mode !== mode) parts.rendering.paintMode(entry, mode); + entry.routeType = routeType; entry.modeInferred = modeInferred; updatePlayback(entry, now, monoNow); parts.rendering.schedulePlayback(entry); @@ -320,6 +329,8 @@ export function createIngestion({ state, services, parts, source }) { feedId: feed.id, marker: null, mode, + // The GTFS route type its model is chosen by, when it has one. + routeType, modeInferred, heightM: prior === null ? 0 : prior, heightCell: height.cell, diff --git a/src/layers/transit/movement.js b/src/layers/transit/movement.js index 2c9a61dcd..8202d7a56 100644 --- a/src/layers/transit/movement.js +++ b/src/layers/transit/movement.js @@ -11,9 +11,14 @@ import { } from '../../data/contactPlayback.js'; const MODE_MAX_SPEED_MPS = Object.freeze({ bus: 36, // ~130 km/h — a coach on a motorway + trolleybus: 28, // ~100 km/h — wired to the street tram: 28, // ~100 km/h — interurban light rail + cable_tram: 12, // ~43 km/h — the cable runs at a walking-pace multiple subway: 42, // ~150 km/h + monorail: 42, // ~150 km/h rail: 111, // ~400 km/h — high-speed services exist on some feeds + funicular: 16, // ~58 km/h — the fastest lines + aerial_lift: 15, // ~54 km/h — the fastest gondolas and trams ferry: 25, // ~90 km/h — fast catamarans unknown: 56, // ~200 km/h }); diff --git a/src/layers/transit/policy.js b/src/layers/transit/policy.js index eabe5df4a..a74d1bc16 100644 --- a/src/layers/transit/policy.js +++ b/src/layers/transit/policy.js @@ -189,9 +189,14 @@ export const SELECTED_CARD_REFRESH_MS = 250; /** Mode palette: distinct at a glance, none reused by flights (white/cyan), military (amber), or vessels. */ export const TRANSIT_MODE_COLORS = Object.freeze({ bus: '#5EF08A', + trolleybus: '#B6F04A', tram: '#FFC24A', + cable_tram: '#FF8F4A', subway: '#FF4538', + monorail: '#FF6FB8', rail: '#D9A6FF', + funicular: '#E8C98A', + aerial_lift: '#7FA8FF', ferry: '#5FD6FF', unknown: '#D8DDE5', }); @@ -526,9 +531,14 @@ const UNDERGROUND_MODES = new Set(['subway']); /** The mode in plain words, for a card a person reads rather than scans. */ const TRANSIT_MODE_WORD = Object.freeze({ bus: msg('Bus'), + trolleybus: msg('Trolleybus'), tram: msg('Tram'), + cable_tram: msg('Cable car'), subway: msg('Subway'), + monorail: msg('Monorail'), rail: msg('Train'), + funicular: msg('Funicular'), + aerial_lift: msg('Gondola'), ferry: msg('Ferry'), unknown: msg('Transit vehicle'), }); @@ -536,9 +546,14 @@ const TRANSIT_MODE_WORD = Object.freeze({ /** Short, fixed-width mode word for the detection card's class field. */ const TRANSIT_MODE_ABBR = Object.freeze({ bus: 'BUS', + trolleybus: 'TROLLEY', tram: 'TRAM', + cable_tram: 'CABLE', subway: 'METRO', + monorail: 'MONO', rail: 'RAIL', + funicular: 'FUNI', + aerial_lift: 'GONDOLA', ferry: 'FERRY', unknown: 'TRANSIT', }); diff --git a/src/layers/transit/rendering.js b/src/layers/transit/rendering.js index 058aa3a5d..8a1b19635 100644 --- a/src/layers/transit/rendering.js +++ b/src/layers/transit/rendering.js @@ -531,9 +531,15 @@ export function createRendering({ state, services, parts }) { groundLiftM, }; } - if (item.mode !== entry.mode) { + if (item.mode !== entry.mode || item.routeType !== entry.routeType) { item.mode = entry.mode; - item.spec = transitModelSpec(set, { mode: entry.mode }); + item.routeType = entry.routeType; + // The route type picks the finer model (a coach, a high-speed set); + // the mode is the fallback for a type the model table lacks. + item.spec = transitModelSpec(set, { + routeType: entry.routeType, + mode: entry.mode, + }); item.tint = MODE_CESIUM_COLORS[entry.mode] || MODE_CESIUM_COLORS.unknown; } diff --git a/src/layers/transit/trails.js b/src/layers/transit/trails.js index 4080766ee..315b2ece8 100644 --- a/src/layers/transit/trails.js +++ b/src/layers/transit/trails.js @@ -8,16 +8,9 @@ import { } from '../../data/contactPlayback.js'; import { createContactTrailRenderer } from '../../data/contactTrailRenderer.js'; import { fixDistanceM } from './movement.js'; +import { TRANSIT_MODE_COLORS } from './policy.js'; import { transitStyleProfile } from '../../data/transitPresetStyle.js'; -const MODE_COLOR = { - bus: '#5EF08A', - tram: '#FFC24A', - subway: '#FF4538', - rail: '#D9A6FF', - ferry: '#5FD6FF', - unknown: '#D8DDE5', -}; // Final Cesium batching uses 3,152 bytes per two-lane edge. // The 1,278-instance body plus 64 bytes/instance reserve stays below 2 MiB. export const TRAIL_VERTEX_LIMIT = 640; @@ -41,7 +34,7 @@ export function createTrails({ state, services, parts, source }) { renderer?.setStyle( transitStyleProfile(state._stylePreset) === 'mono' ? '#FFFFFF' - : MODE_COLOR[selected?.mode] || MODE_COLOR.unknown, + : TRANSIT_MODE_COLORS[selected?.mode] || TRANSIT_MODE_COLORS.unknown, ); } function releaseSelectionGeometry(entry) { diff --git a/src/overlays/worldOverlayTokens.js b/src/overlays/worldOverlayTokens.js index c03383148..895ba9ac7 100644 --- a/src/overlays/worldOverlayTokens.js +++ b/src/overlays/worldOverlayTokens.js @@ -139,9 +139,14 @@ export const DETECTION_THEME_MAP = Object.freeze({ veh_free: '#00ff66', veh_nodata: '#c9c9c9', transit_bus: '#5EF08A', + transit_trolleybus: '#B6F04A', transit_tram: '#FFC24A', + transit_cable_tram: '#FF8F4A', transit_subway: '#FF4538', + transit_monorail: '#FF6FB8', transit_rail: '#D9A6FF', + transit_funicular: '#E8C98A', + transit_aerial_lift: '#7FA8FF', transit_ferry: '#5FD6FF', transit_unknown: '#D8DDE5', }, @@ -169,9 +174,14 @@ export const DETECTION_THEME_MAP = Object.freeze({ veh_free: '#45d8ff', veh_nodata: '#dcdcdc', transit_bus: '#5EF08A', + transit_trolleybus: '#B6F04A', transit_tram: '#FFC24A', + transit_cable_tram: '#FF8F4A', transit_subway: '#FF4538', + transit_monorail: '#FF6FB8', transit_rail: '#D9A6FF', + transit_funicular: '#E8C98A', + transit_aerial_lift: '#7FA8FF', transit_ferry: '#5FD6FF', transit_unknown: '#D8DDE5', }, @@ -199,9 +209,14 @@ export const DETECTION_THEME_MAP = Object.freeze({ veh_free: '#2ecc71', veh_nodata: '#d8d8d8', transit_bus: '#5EF08A', + transit_trolleybus: '#B6F04A', transit_tram: '#FFC24A', + transit_cable_tram: '#FF8F4A', transit_subway: '#FF4538', + transit_monorail: '#FF6FB8', transit_rail: '#D9A6FF', + transit_funicular: '#E8C98A', + transit_aerial_lift: '#7FA8FF', transit_ferry: '#5FD6FF', transit_unknown: '#D8DDE5', }, @@ -229,9 +244,14 @@ export const DETECTION_THEME_MAP = Object.freeze({ veh_free: '#2ecc71', veh_nodata: '#c9c9c9', transit_bus: '#5EF08A', + transit_trolleybus: '#B6F04A', transit_tram: '#FFC24A', + transit_cable_tram: '#FF8F4A', transit_subway: '#FF4538', + transit_monorail: '#FF6FB8', transit_rail: '#D9A6FF', + transit_funicular: '#E8C98A', + transit_aerial_lift: '#7FA8FF', transit_ferry: '#5FD6FF', transit_unknown: '#D8DDE5', }, diff --git a/src/sources/transitHistoryStore.js b/src/sources/transitHistoryStore.js index cf82835c1..b53082e27 100644 --- a/src/sources/transitHistoryStore.js +++ b/src/sources/transitHistoryStore.js @@ -1,3 +1,4 @@ +import { transitModeFor } from '../data/transitFeeds.js'; import { validTransitIdentifier } from './transitHistory.js'; export { validTransitIdentifier } from './transitHistory.js'; /** Bounded, process-local operator position history. No upstream or scene access. */ @@ -328,12 +329,12 @@ export function createTransitHistory({ t > now + 10000 ) continue; - const byVehicle = feed.vehicleMode?.(record.id); - const mode = - (byVehicle !== 'unknown' && byVehicle) || - feed.routeMode?.(record.routeId) || - feed.defaultMode || - 'unknown'; + const mode = transitModeFor( + feed, + record.routeId, + record.id, + record.routeType, + ); const context = contextOf(record, mode); if (!context) continue; const key = `${feed.id}\u0000${record.id}`; diff --git a/src/voice/layerManifest.js b/src/voice/layerManifest.js index 189ee8e44..60cda6f25 100644 --- a/src/voice/layerManifest.js +++ b/src/voice/layerManifest.js @@ -302,7 +302,18 @@ const layers = [ }, { id: 'transit', - aliases: ['buses', 'trains', 'public transit', 'trams', 'subway'], + aliases: [ + 'buses', + 'trains', + 'public transit', + 'trams', + 'subway', + 'trolleybus', + 'gondola', + 'cable car', + 'funicular', + 'monorail', + ], context: false, query: { fields: { From 96cefa28b34f067211e9b2d933824610acf6dd12 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Sat, 14 Nov 2026 12:03:54 -0800 Subject: [PATCH 06/30] Number the transit route type changelog fragment for #1734 --- ...t-route-type-models.md => 1734-transit-route-type-models.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename changelog.d/{0000-transit-route-type-models.md => 1734-transit-route-type-models.md} (96%) diff --git a/changelog.d/0000-transit-route-type-models.md b/changelog.d/1734-transit-route-type-models.md similarity index 96% rename from changelog.d/0000-transit-route-type-models.md rename to changelog.d/1734-transit-route-type-models.md index 463820354..f451376e3 100644 --- a/changelog.d/0000-transit-route-type-models.md +++ b/changelog.d/1734-transit-route-type-models.md @@ -7,4 +7,4 @@ Cluj and Turin's trams, trolleybuses and metro lines, now read as such from the route ids in each operator's routes.txt. Le Havre's funicular, which its routes.txt types as a bus, is a named correction that outranks the route - type (samehkhamis, #0000). + type (samehkhamis, #1734). From dd152231090799c29ef106440eb41ef97b52f1eb Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Sat, 14 Nov 2026 12:22:30 -0800 Subject: [PATCH 07/30] Class only PID's trolleybus lines as trolleybuses, and name the new modes in the plural for voice PID's routes.txt types lines 51, 52, 53, 58, 59, 232 and 275 as trolleybuses (route type 11); the rest of 50 to 59 stay buses, as before. Voice now also knows trolleybuses, gondolas, cable cars, funiculars and monorails. --- src/data/transitFeeds.js | 8 ++++++-- src/data/transitFeeds.test.mjs | 1 + src/voice/layerManifest.js | 5 +++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/data/transitFeeds.js b/src/data/transitFeeds.js index 3e9f9cebc..0f6844c65 100644 --- a/src/data/transitFeeds.js +++ b/src/data/transitFeeds.js @@ -547,6 +547,9 @@ function astuceRouteLabel(routeId) { return ASTUCE_ROUTES[routeId ?? '']?.label ?? astuceNetworkLabel(routeId); } +/** PID trolleybus lines: route_type 11 in PID's routes.txt (checked 2026-11-14). */ +const PID_TROLLEYBUS_LINES = new Set([51, 52, 53, 58, 59, 232, 275]); + /** * Prague PID route ids are `L` plus a number whose range says what runs it, * per PID's GTFS routes.txt (data.pid.cz, checked 2026-11-09): 1–99 trams @@ -566,10 +569,11 @@ function pidRoute(routeId) { const n = Number(match[1]); // i18n-ignore: line code, as signed if (n === 49) return { mode: 'funicular', label: 'LD' }; - if (n >= 50 && n <= 59) return { mode: 'trolleybus', label: String(n) }; + if (PID_TROLLEYBUS_LINES.has(n)) + return { mode: 'trolleybus', label: String(n) }; + if (n >= 50 && n <= 59) return { mode: 'bus', label: String(n) }; if (n < 100) return { mode: 'tram', label: String(n) }; if (n >= 800 && n < 900) return { mode: 'bus', label: `X${n - 800}` }; - if (n === 232 || n === 275) return { mode: 'trolleybus', label: String(n) }; if (n < 991) return { mode: 'bus', label: String(n) }; // i18n-ignore: metro line letters, as signed if (n <= 993) return { mode: 'subway', label: 'ABC'[n - 991] }; diff --git a/src/data/transitFeeds.test.mjs b/src/data/transitFeeds.test.mjs index 37ad82a56..85a3a8243 100644 --- a/src/data/transitFeeds.test.mjs +++ b/src/data/transitFeeds.test.mjs @@ -734,6 +734,7 @@ test('Prague route-id ranges give metro, trains, ferries and trolleybuses their ]; assert.deepEqual(read('L22'), ['tram', '22']); assert.deepEqual(read('L58'), ['trolleybus', '58']); + assert.deepEqual(read('L55'), ['bus', '55'], 'not a PID trolleybus line'); assert.deepEqual(read('L275'), ['trolleybus', '275'], 'route type 11'); assert.deepEqual(read('L49'), ['funicular', 'LD'], 'Petřín funicular'); assert.deepEqual(read('L135'), ['bus', '135']); diff --git a/src/voice/layerManifest.js b/src/voice/layerManifest.js index 60cda6f25..52cb0f90f 100644 --- a/src/voice/layerManifest.js +++ b/src/voice/layerManifest.js @@ -309,10 +309,15 @@ const layers = [ 'trams', 'subway', 'trolleybus', + 'trolleybuses', 'gondola', + 'gondolas', 'cable car', + 'cable cars', 'funicular', + 'funiculars', 'monorail', + 'monorails', ], context: false, query: { From 7ee047961b7a57f920b3ef79e84c18f74ab02a11 Mon Sep 17 00:00:00 2001 From: Manjunath Paparaju Date: Fri, 13 Nov 2026 10:31:52 +0530 Subject: [PATCH 08/30] Move Visual to the left rail and let panels sit at the screen edge The left rail holds Data Layers, Utilities, Authoring and Visual; the right rail holds Context, CCTV and Street Level. A button in each panel header moves that side's panels to the screen edge, with the rail as a row above them, and scrolling at a screen edge steps through a rail's panels. An open right panel starts just under the HUD readouts, and Context and CCTV take the column's full height. The right rail stays level with the left column's top whichever left panel is open, in both layouts. Co-authored-by: Sameh Khamis --- src/ui/kit/UiPanel.vue | 2 + src/ui/kit/UiPanelEdge.vue | 39 ++++++ src/ui/leftPanelRail.js | 7 ++ src/ui/panelEdge.js | 40 ++++++ src/ui/panelLayoutController.js | 9 +- src/ui/panelMeasurement.js | 13 +- src/ui/panelRailCatalog.js | 2 +- src/ui/railEdgeScroll.js | 207 ++++++++++++++++++++++++++++++++ src/ui/rightPanelRail.js | 52 ++++++-- src/ui/shellLifecycle.test.mjs | 4 +- src/ui/styles/credits.css | 50 ++++++++ src/ui/styles/left-tools.css | 167 ++++++++++++++++++++++++++ src/ui/styles/panel-edge.css | 92 ++++++++++++++ src/ui/styles/rail-edge.css | 102 ++++++++++++++++ src/ui/styles/rail-split.css | 192 +++++++++++++++++++++++++++++ src/ui/styles/shell-spacing.css | 33 +++++ 16 files changed, 999 insertions(+), 12 deletions(-) create mode 100644 src/ui/kit/UiPanelEdge.vue create mode 100644 src/ui/panelEdge.js create mode 100644 src/ui/railEdgeScroll.js create mode 100644 src/ui/styles/credits.css create mode 100644 src/ui/styles/left-tools.css create mode 100644 src/ui/styles/panel-edge.css create mode 100644 src/ui/styles/rail-edge.css create mode 100644 src/ui/styles/rail-split.css create mode 100644 src/ui/styles/shell-spacing.css diff --git a/src/ui/kit/UiPanel.vue b/src/ui/kit/UiPanel.vue index 5421fc699..f16adc385 100644 --- a/src/ui/kit/UiPanel.vue +++ b/src/ui/kit/UiPanel.vue @@ -1,5 +1,6 @@ + + diff --git a/src/ui/leftPanelRail.js b/src/ui/leftPanelRail.js index ca11a8149..0b3e7ee2f 100644 --- a/src/ui/leftPanelRail.js +++ b/src/ui/leftPanelRail.js @@ -60,6 +60,7 @@ export function layoutLeftPanelRail({ stack.style.removeProperty('--left-stack-safe-bottom'); stack.style.removeProperty('--left-stack-centered-height'); stack.style.removeProperty('--panel-rail-offset'); + stack.style.removeProperty('--panel-rail-lift'); stack.classList.remove('layout-exclusive'); stack.dataset.layoutMode = 'mobile'; settleSideAccordion({ panels, enabled: false, onCollapse }); @@ -286,6 +287,12 @@ export function layoutLeftPanelRail({ if (stack.style.getPropertyValue('--panel-rail-offset') !== railOffset) { stack.style.setProperty('--panel-rail-offset', railOffset); } + // How far the column can rise before it meets the HUD readout, so the rail + // and any open panel sit just under it, whether or not a panel is open. + const railLift = `${(topPinned ? 0 : Math.min(0, obstacleSafeTop - layoutTop)).toFixed(1)}px`; + if (stack.style.getPropertyValue('--panel-rail-lift') !== railLift) { + stack.style.setProperty('--panel-rail-lift', railLift); + } stack.style.removeProperty('--left-stack-centered-height'); for (const panel of panels) panel.style.removeProperty('--left-panel-allocated-height'); diff --git a/src/ui/panelEdge.js b/src/ui/panelEdge.js new file mode 100644 index 000000000..a3cb7c750 --- /dev/null +++ b/src/ui/panelEdge.js @@ -0,0 +1,40 @@ +import { ref } from 'vue'; + +// Panels can slide over their rail to the screen edge, one setting per side: +// the left column moves onto the left rail, the right column onto the right +// rail. Each panel header has the switch (UiPanelEdge); the choice is kept +// for the next visit and shows as a body class the stylesheet reads. +const KEY = 'gev.panelEdge'; +function read() { + try { + const saved = JSON.parse(globalThis.localStorage?.getItem(KEY) || '{}'); + return { left: saved.left === true, right: saved.right === true }; + } catch { + return { left: false, right: false }; + } +} + +export const panelEdge = ref(read()); + +function apply() { + const body = globalThis.document?.body; + if (!body) return; + body.classList.toggle('panels-edge-left', panelEdge.value.left); + body.classList.toggle('panels-edge-right', panelEdge.value.right); +} +apply(); + +/** Which side a panel element sits on, from the column it is in. */ +export function panelSide(element) { + return element?.closest?.('#right-context-rail, #cockpit-utility-controls') ? 'right' : 'left'; +} + +export function togglePanelEdge(side) { + panelEdge.value = { ...panelEdge.value, [side]: !panelEdge.value[side] }; + try { + globalThis.localStorage?.setItem(KEY, JSON.stringify(panelEdge.value)); + } catch { + // Without storage the choice lasts for this visit. + } + apply(); +} diff --git a/src/ui/panelLayoutController.js b/src/ui/panelLayoutController.js index d5de96647..22242c54f 100644 --- a/src/ui/panelLayoutController.js +++ b/src/ui/panelLayoutController.js @@ -189,7 +189,11 @@ export class PanelLayoutController { const stack = this._rightPanelStack; if (!stack || !this._ppToggles) return; - stack.prepend(this._ppToggles); + // Visual (presets and display settings) is the last panel of the left + // column, after the other tools, and opens from the left rail like them. + if (typeof this._leftPanelStack?.append === 'function') + this._leftPanelStack.append(this._ppToggles); + else stack.prepend(this._ppToggles); const globalContextPanel = document.getElementById('global-context-panel'); for (const panel of [ this._cctvPanel, @@ -201,6 +205,9 @@ export class PanelLayoutController { if (!panel) continue; stack.insertBefore(panel, globalContextPanel); } + // Context leads the right column: it is the panel for whatever is picked, + // and the camera panels follow it. + if (globalContextPanel) stack.prepend(globalContextPanel); if (typeof ResizeObserver !== 'undefined') { this._rightStackResizeObserver = new ResizeObserver(() => { this._scheduleRightPanelLayout(); diff --git a/src/ui/panelMeasurement.js b/src/ui/panelMeasurement.js index dcd9de464..86be6f95c 100644 --- a/src/ui/panelMeasurement.js +++ b/src/ui/panelMeasurement.js @@ -6,9 +6,20 @@ * @returns {number} Natural height in CSS pixels. */ export function measurePanelNaturalHeight(panel, getComputedStyle) { - const inner = [...panel.children].find( + const content = [...panel.children].filter( (child) => !child.classList.contains('panel-glow'), ); + // A panel built as a header row and a body (Visual) scrolls as a whole, so + // its full scroll height is its natural height. + if (content.length > 1) { + const panelStyle = getComputedStyle(panel); + return Math.ceil( + panel.scrollHeight + + (parseFloat(panelStyle.borderTopWidth) || 0) + + (parseFloat(panelStyle.borderBottomWidth) || 0), + ); + } + const inner = content[0]; if (!inner) return Math.ceil( panel.scrollHeight || panel.getBoundingClientRect().height, diff --git a/src/ui/panelRailCatalog.js b/src/ui/panelRailCatalog.js index dbda77dcd..6e0b0a876 100644 --- a/src/ui/panelRailCatalog.js +++ b/src/ui/panelRailCatalog.js @@ -19,7 +19,7 @@ export const PANEL_RAIL_ITEMS = Object.freeze({ }, 'utilities-panel': { icon: 'handyman', label: msg('UTILITIES') }, 'scene-panel': { icon: 'movie', label: msg('AUTHORING') }, - 'pp-toggles': { icon: 'tune', label: msg('DISPLAY') }, + 'pp-toggles': { icon: 'palette', label: msg('VISUAL') }, 'cctv-panel': { icon: 'videocam', label: msg('CCTV') }, 'weather-panel': { icon: 'partly_cloudy_day', label: msg('WEATHER') }, 'news-panel': { icon: 'public', label: msg('NEWS') }, diff --git a/src/ui/railEdgeScroll.js b/src/ui/railEdgeScroll.js new file mode 100644 index 000000000..42cfc91ca --- /dev/null +++ b/src/ui/railEdgeScroll.js @@ -0,0 +1,207 @@ +// Edge scrolling for the side rails. While the pointer is in a screen edge's +// strip (from the edge to just past its rail), that rail's border lights up, +// and the scroll wheel steps to the next or previous panel on that side +// instead of zooming the globe, wrapping round at either end. The open item's +// highlight slides between items however the panel changes, and a panel +// opened by the wheel slides in from the direction of travel. + +/** How far past the rail the strip reaches, in pixels. */ +const STRIP_MARGIN = 16; +/** Wheel travel (pixels) that counts as one step. */ +const STEP_DELTA = 40; +/** + * A pause this long (ms) with no wheel events ends a scroll gesture. One + * gesture moves one step, however long it runs, trackpad coasting included. + */ +const GESTURE_GAP_MS = 180; +/** Things in the strip that keep their own pointer and wheel behaviour. */ +const OWN_CONTROLS = + 'a, button, input, select, textarea, [role="dialog"], .ui-panel, #first-run-launcher, #cesium-credits'; + +/** + * @param {Document} [doc] + * @returns {() => void} removes the listeners and observers + */ +export function installRailEdgeScroll(doc = globalThis.document) { + const win = doc?.defaultView; + if (!doc || !win) return () => {}; + const coarse = win.matchMedia?.('(pointer: coarse)'); + + let hot = null; + let travel = 0; + let lastWheel = 0; + let lastSpeed = 0; + let stepped = false; + let frame = 0; + + const rails = () => + ['left', 'right'] + .map((side) => ({ side, rail: doc.querySelector(`.ui-rail--${side}`) })) + .filter(({ rail }) => rail && rail.getBoundingClientRect().width > 0); + + const items = (rail) => + [...rail.querySelectorAll('.ui-rail__item')].filter((item) => !item.disabled); + + // ── The sliding highlight ── + // Each rail draws it as a ::before under its items, placed by custom + // properties; the open item's own background steps aside while it shows. + // Vue rewrites a rail's class list when it folds its labels, so whether the + // highlight is showing is kept here, and the classes are put back each time. + const gliding = new WeakSet(); + function glide(rail) { + rail.classList.toggle('ui-rail--edge-hot', rail === hot); + const on = rail.querySelector('.ui-rail__item[aria-pressed="true"]'); + if (!on?.offsetWidth) { + gliding.delete(rail); + rail.classList.remove('ui-rail--glide'); + return; + } + const railBox = rail.getBoundingClientRect(); + const box = on.getBoundingClientRect(); + const shown = gliding.has(rail); + // Appearing from nothing: jump into place, then fade in. + rail.classList.toggle('ui-rail--glide-jump', !shown); + rail.style.setProperty('--rail-glide-x', `${box.left - railBox.left - rail.clientLeft}px`); + rail.style.setProperty('--rail-glide-y', `${box.top - railBox.top - rail.clientTop}px`); + rail.style.setProperty('--rail-glide-w', `${box.width}px`); + rail.style.setProperty('--rail-glide-h', `${box.height}px`); + rail.classList.add('ui-rail--glide'); + gliding.add(rail); + if (!shown) win.requestAnimationFrame(() => rail.classList.remove('ui-rail--glide-jump')); + } + + // Follow the rails for a few frames after any change, as their items + // resize while labels fold away. + function follow(frames = 24) { + win.cancelAnimationFrame(frame); + let left = frames; + const tick = () => { + doc.querySelectorAll('.ui-rail').forEach(glide); + if ((left -= 1) > 0) frame = win.requestAnimationFrame(tick); + }; + tick(); + } + + const observer = + typeof win.MutationObserver === 'function' + ? new win.MutationObserver((records) => { + // A rail item opened or closed. Nothing here writes aria-pressed, + // and the work waits for the next frame, so this never feeds itself. + if (records.some((record) => record.target.classList?.contains('ui-rail__item'))) + win.requestAnimationFrame(() => follow()); + }) + : null; + observer?.observe(doc.body, { + subtree: true, + attributes: true, + attributeFilter: ['aria-pressed'], + }); + + // ── The edge strip ── + /** The rail whose strip holds the point, unless a control there owns it. */ + function railAt(x, target) { + if (doc.body.classList.contains('mobile-shell') || coarse?.matches) return null; + for (const { side, rail } of rails()) { + const box = rail.getBoundingClientRect(); + const inStrip = + side === 'left' + ? x <= box.right + STRIP_MARGIN + : x >= box.left - STRIP_MARGIN; + if (!inStrip) continue; + if (rail.contains(target)) return rail; + if (target?.closest?.(OWN_CONTROLS)) return null; + return rail; + } + return null; + } + + function setHot(rail) { + if (rail === hot) return; + hot?.classList.remove('ui-rail--edge-hot'); + hot = rail; + travel = 0; + hot?.classList.add('ui-rail--edge-hot'); + follow(2); + } + + function onMove(event) { + setHot(railAt(event.clientX, event.target)); + } + + function onLeave(event) { + if (!event.relatedTarget) setHot(null); + } + + function step(direction) { + const list = items(hot); + if (!list.length) return; + const current = list.findIndex((item) => item.getAttribute('aria-pressed') === 'true'); + // Past either end, carry on from the other. + const nextIndex = + current < 0 + ? direction > 0 + ? 0 + : list.length - 1 + : (current + direction + list.length) % list.length; + if (nextIndex === current) return; + const target = list[nextIndex]; + target.click(); + const panel = doc.getElementById(target.dataset.railItem); + if (panel) { + panel.classList.remove('rail-switch-down', 'rail-switch-up'); + void panel.offsetWidth; + panel.classList.add(direction > 0 ? 'rail-switch-down' : 'rail-switch-up'); + panel.addEventListener( + 'animationend', + () => panel.classList.remove('rail-switch-down', 'rail-switch-up'), + { once: true }, + ); + } + follow(); + } + + function onWheel(event) { + if (!hot || event.ctrlKey) return; + // Recheck: the pointer may not have moved since the panels changed. + if (railAt(event.clientX, event.target) !== hot) return setHot(null); + event.preventDefault(); + event.stopPropagation(); + const now = win.performance?.now?.() ?? Date.now(); + const speed = Math.abs(event.deltaY); + // A new gesture: after a pause, after turning round, or a fresh flick + // while the last one is still coasting (the speed jumps back up). + const turned = travel && Math.sign(event.deltaY) !== Math.sign(travel); + const flick = stepped && speed > 20 && speed > lastSpeed * 2; + if (now - lastWheel > GESTURE_GAP_MS || turned || flick) { + travel = 0; + stepped = false; + } + lastWheel = now; + lastSpeed = speed; + if (stepped) return; + travel += event.deltaY; + if (Math.abs(travel) < STEP_DELTA) return; + stepped = true; + step(Math.sign(travel)); + } + + const onResize = () => follow(2); + doc.addEventListener('pointermove', onMove, { passive: true }); + doc.addEventListener('pointerout', onLeave, { passive: true }); + win.addEventListener('wheel', onWheel, { capture: true, passive: false }); + win.addEventListener('resize', onResize, { passive: true }); + follow(); + + return () => { + setHot(null); + observer?.disconnect(); + win.cancelAnimationFrame(frame); + doc.removeEventListener('pointermove', onMove); + doc.removeEventListener('pointerout', onLeave); + win.removeEventListener('wheel', onWheel, { capture: true }); + win.removeEventListener('resize', onResize); + doc.querySelectorAll('.ui-rail').forEach((rail) => + rail.classList.remove('ui-rail--glide', 'ui-rail--glide-jump', 'ui-rail--edge-hot'), + ); + }; +} diff --git a/src/ui/rightPanelRail.js b/src/ui/rightPanelRail.js index 44043fb01..e92d2267b 100644 --- a/src/ui/rightPanelRail.js +++ b/src/ui/rightPanelRail.js @@ -31,6 +31,20 @@ function settledLeftRailTop(leftStack, viewportHeight, getComputedStyle) { return Number.isFinite(targetPct) ? (targetPct * viewportHeight) / 100 : top; } +/** + * An element's CSS `top` in pixels where it will settle: the end of a running + * `top` transition, else its computed value. NaN when it cannot be read. + */ +function settledCssTop(element, getComputedStyle) { + if (!element) return NaN; + const transition = element + .getAnimations?.() + .find((animation) => animation.transitionProperty === 'top'); + const target = parseFloat(transition?.effect?.getKeyframes?.().at(-1)?.top); + if (Number.isFinite(target)) return target; + return parseFloat(getComputedStyle(element).top); +} + /** * Measure and place the right panel rail for one synchronous layout pass. * The caller owns scheduling, obstacle selection, disclosure preferences and @@ -126,9 +140,20 @@ export function layoutRightPanelRail({ viewportHeight, getComputedStyle, ); - // Align with the left rail's buttons, which hold still while its stack moves. - const leftRailOffset = - parseFloat(leftStack?.style.getPropertyValue('--panel-rail-offset')) || 0; + // Align with the left rail's buttons, which hold still while its stack moves: + // the rail's own settled `top` inside the stack, so every left layout is + // followed (a layout may pin the rail to the stack's top whatever the + // offset says). The stack's offset is the fallback when there is no rail. + const leftRailInset = settledCssTop( + leftStack?.querySelector?.('.gev-panel-rail') ?? null, + getComputedStyle, + ); + // A rail that sits lower in its stack has only made room above itself for + // the open panel's own icon, which stays at the stack's top: the column's + // top has not moved, so that inset is not followed. + const leftRailOffset = Number.isFinite(leftRailInset) + ? Math.min(0, leftRailInset) + : parseFloat(leftStack?.style.getPropertyValue('--panel-rail-offset')) || 0; const alignedTop = Number.isFinite(leftStackTop) ? leftStackTop + leftRailOffset : viewportHeight * 0.26; @@ -206,13 +231,24 @@ export function layoutRightPanelRail({ 0, ) + gap * Math.max(0, measuredPanels.length - 1); + // An open Context panel takes the column's full height: up to just under + // the HUD readouts at the top of the screen, down to the usual bottom. + // CCTV does the same, so its feed and controls have the room. + const FULL_HEIGHT = new Set(['global-context-panel', 'cctv-panel']); + const contextOpen = panels.some( + (panel) => FULL_HEIGHT.has(panel.id) && !panel.classList.contains('collapsed'), + ); + // Any open panel starts from that same raised top, so switching between + // Context, CCTV and Street Level does not move the column. Only the two + // above also stretch to the bottom. + const anyOpen = panels.some((panel) => !panel.classList.contains('collapsed')); const layout = resolveHudRailLayout({ viewportHeight, panelHeight: naturalHeight, laneLeft: stackRect.left, laneRight: stackRect.right, obstacles: obstacleRects, - baseTop: alignedTop, + baseTop: anyOpen ? viewportHeight * 0.04 : alignedTop, baseBottom: viewportHeight * 0.96, gap: safeGap, align: 'start', @@ -221,9 +257,11 @@ export function layoutRightPanelRail({ const { safeTop, safeBottom, maxHeight: availableHeight } = layout; const stabilityBand = Math.max(48, viewportHeight * 0.06); const wasFocused = stack.classList.contains('layout-focus'); - const shouldFocus = wasFocused - ? naturalHeight >= availableHeight - stabilityBand - : naturalHeight > availableHeight; + const shouldFocus = + contextOpen || + (wasFocused + ? naturalHeight >= availableHeight - stabilityBand + : naturalHeight > availableHeight); const layoutTop = shouldFocus ? safeTop : layout.top; const collapsedHeight = visiblePanels.reduce( (total, panel) => diff --git a/src/ui/shellLifecycle.test.mjs b/src/ui/shellLifecycle.test.mjs index 2c8bc8ee7..bcefb345e 100644 --- a/src/ui/shellLifecycle.test.mjs +++ b/src/ui/shellLifecycle.test.mjs @@ -259,7 +259,7 @@ test('recording restores the original HUD after repeated entry and revokes retai } }); -test('weather rail orders between CCTV and Context, observes and presents chrome', (t) => { +test('Context leads the right rail, weather follows CCTV, observes and presents chrome', (t) => { const f = fixture(); const observed = new Set(); const previousResizeObserver = globalThis.ResizeObserver; @@ -319,7 +319,7 @@ test('weather rail orders between CCTV and Context, observes and presents chrome owner._initRightPanelAdaptiveLayout(); assert.deepEqual( stack.children.map((panel) => panel.id), - ['pp-toggles', 'cctv-panel', 'weather-panel', 'global-context-panel'], + ['global-context-panel', 'pp-toggles', 'cctv-panel', 'weather-panel'], ); assert.ok(observed.has(weather)); // Moving a panel into the rail leaves its state as it was. diff --git a/src/ui/styles/credits.css b/src/ui/styles/credits.css new file mode 100644 index 000000000..be4160a66 --- /dev/null +++ b/src/ui/styles/credits.css @@ -0,0 +1,50 @@ +/* ── Map attribution ─────────────────────────────────────────────────── + The required Cesium / imagery credits sit in a small glass pill. On wide + screens it drops to the bottom-left corner, clear of the HUD's coordinate + readout and left of the command dock; narrower screens keep the raised + position the dock rules give it. Attribution must stay visible. */ +body:not(.ui-clean-view):not(.recording-mode) #cesium-credits, +body.ui-clean-view #cesium-credits, +body.recording-mode #cesium-credits { + display: inline-flex; + align-items: center; + height: auto !important; + padding: 0.3rem 0.75rem 0.3rem 0.45rem; + background: var(--glass-bg); + border: 1px solid var(--glass-border); + border-radius: 999px; + box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35); + backdrop-filter: blur(20px) saturate(1.3); + -webkit-backdrop-filter: blur(20px) saturate(1.3); + text-shadow: none; +} + +#cesium-credits .cesium-widget-credits { + position: static !important; + display: inline-flex; + align-items: center; + gap: 0.5rem; + width: auto !important; + height: auto !important; + padding: 0 !important; +} + +#cesium-credits img { + height: 18px; + vertical-align: middle !important; +} + +@media (min-width: 1200px) { + body:not(.ui-clean-view):not(.recording-mode) #cesium-credits, + body:not(.ui-clean-view):not(.recording-mode):has( + #intel-hud[data-variant='minimal'].active + ) + #cesium-credits { + right: auto; + bottom: 1.1rem; + left: 1.5rem; + /* Never reach under the centred command dock (about 30rem wide). */ + max-width: calc(50vw - 17rem); + overflow: hidden; + } +} diff --git a/src/ui/styles/left-tools.css b/src/ui/styles/left-tools.css new file mode 100644 index 000000000..0ce9759a8 --- /dev/null +++ b/src/ui/styles/left-tools.css @@ -0,0 +1,167 @@ +/* On desktop and tablet the omnibox finds places and Visual (left rail) + holds the presets, so the command dock keeps only voice. Phones keep the + trays in their sheets. */ +body:not(.mobile-shell) #command-dock > #control-panel, +body:not(.mobile-shell) #command-dock > #location-bar { + display: none; +} + +/* ── Visual: presets and map source at the top of the panel ─────────── */ +.visual-presets { + display: grid; + gap: 8px; + padding: 2px 0 12px; + margin-bottom: 10px; + border-bottom: 1px solid var(--glass-border); +} + +.visual-presets__heading { + margin: 4px 0 0; + color: var(--text-secondary); + font: 600 10px/1.2 var(--font-mono); + letter-spacing: 0.14em; + text-transform: uppercase; +} + +.visual-presets__heading--row { + display: flex; + justify-content: space-between; + gap: 8px; +} + +.visual-presets__status { + color: var(--accent); +} + +.visual-presets__status.warn { + color: #ff9f43; +} + +.visual-presets__grid { + display: grid; + grid-template-columns: repeat(3, minmax(0, 1fr)); + gap: 6px; +} + +.visual-presets__style { + position: relative; + display: grid; + justify-items: center; + gap: 4px; + padding: 9px 4px 7px; + color: var(--text-secondary); + background: rgba(255, 255, 255, 0.03); + border: 1px solid var(--glass-border); + border-radius: var(--btn-radius); + cursor: pointer; +} + +.visual-presets__style:hover { + color: var(--text-primary); + background: rgba(255, 255, 255, 0.06); +} + +.visual-presets__style.active { + color: var(--accent); + background: var(--accent-dim); + border-color: var(--accent-dim); +} + +.visual-presets__icon { + font-size: 15px; + line-height: 1; +} + +.visual-presets__label { + font: 500 11px/1 var(--font-sans); +} + +.visual-presets__key { + color: var(--text-secondary); + font: 9px/1 var(--font-mono); + opacity: 0.6; +} + +.visual-presets__key { + position: absolute; + top: 4px; + right: 5px; +} + +.visual-presets__chips { + display: flex; + flex-wrap: wrap; + gap: 5px; +} + +.visual-presets__chip { + display: inline-flex; + align-items: center; + gap: 5px; + padding: 5px 9px; + color: var(--text-secondary); + font: 500 11px/1.2 var(--font-sans); + background: rgba(255, 255, 255, 0.03); + border: 1px solid var(--glass-border); + border-radius: 999px; + cursor: pointer; +} + +.visual-presets__chip small { + font-size: 9px; + opacity: 0.6; +} + +.visual-presets__chip:hover { + color: var(--text-primary); + background: rgba(255, 255, 255, 0.06); +} + +.visual-presets__chip.active { + color: var(--accent); + background: var(--accent-dim); + border-color: var(--accent-dim); +} + +.visual-presets__chip.unavailable { + opacity: 0.45; + cursor: default; +} + +/* Visual in the left column: it takes clicks (the column itself lets them + through to the globe) and stays inside the column, scrolling as a whole. */ +#left-panel-stack > #pp-toggles { + position: relative; + inset: auto; + flex: 0 1 var(--left-panel-allocated-height, auto); + min-height: 0; + max-height: var(--left-panel-allocated-height, 100%); + overflow-y: auto; + pointer-events: auto; +} + +#left-panel-stack > #pp-toggles.collapsed { + display: none; +} + +/* ── Expanded panel width ─────────────────────────────────────────────── + Data Layers opens 15px wider than it used to (280 → 295px), and that is + the narrowest any side panel opens to; wider ones (Context, CCTV, + Authoring) keep their own width. */ +:root { + --side-panel-min-expanded-width: 295px; +} + +#data-panel, +#utilities-panel { + --panel-expanded-width: var(--side-panel-min-expanded-width); +} + +#left-panel-stack > #pp-toggles:not(.collapsed) { + --pp-expanded-width: var(--side-panel-min-expanded-width); + width: var(--side-panel-min-expanded-width); +} + +:is(#left-panel-stack, #right-context-rail) > [data-panel-id]:not(.collapsed) { + min-width: var(--side-panel-min-expanded-width); +} diff --git a/src/ui/styles/panel-edge.css b/src/ui/styles/panel-edge.css new file mode 100644 index 000000000..c9cfa4faf --- /dev/null +++ b/src/ui/styles/panel-edge.css @@ -0,0 +1,92 @@ +/* ── Panels over the rail ─────────────────────────────────────────────── + Each panel header's edge switch (UiPanelEdge) slides that side's open + panels over their rail to the screen edge; the rail stays underneath. */ +.ui-panel-edge { + display: grid; + flex: none; + place-items: center; + width: 22px; + height: 22px; + padding: 0; + color: rgba(206, 232, 239, 0.6); + background: rgba(255, 255, 255, 0.03); + border: 1px solid rgba(255, 255, 255, 0.12); + border-radius: 6px; + cursor: pointer; +} + +.ui-panel-edge .material-symbols-outlined { + font-size: 14px; +} + +.ui-panel-edge:hover, +.ui-panel-edge:focus-visible { + color: var(--text-primary, #e8eaed); + border-color: rgba(255, 255, 255, 0.24); +} + +.ui-panel-edge[aria-pressed='true'] { + color: #36dcff; + background: rgba(54, 220, 255, 0.12); + border-color: rgba(54, 220, 255, 0.45); +} + +/* Collapsed panels hide the switch; it only means something once open. */ +.panel-collapsible.collapsed .ui-panel-edge { + display: none; +} + +/* Right: open panels move right by the rail's width and sit over it. */ +body.panels-edge-right:not(.context-docked) #right-context-rail > :not(.gev-panel-rail) { + z-index: 2; + transform: translateX(var(--panel-rail-clearance, 48px)); +} + +/* Left: the same, moving left. */ +body.panels-edge-left #left-panel-stack > :not(.gev-panel-rail) { + z-index: 2; + transform: translateX(calc(-1 * var(--panel-rail-clearance, 48px))); +} + +body.mobile-shell .ui-panel-edge { + display: none; +} + +/* ── Edge mode with a panel open: the rail's icons move to a row along the + top of the panel, and the panel steps down to make room. ── */ +:root { + --edge-rail-row: 50px; +} + +body.panels-edge-left .gev-panel-rail--left:has(.ui-rail--collapsible:not(.ui-rail--expanded)), +body.panels-edge-right:not(.context-docked) .gev-panel-rail--right:has(.ui-rail--collapsible:not(.ui-rail--expanded)) { + top: 0 !important; + z-index: 3; +} + +body.panels-edge-left .gev-panel-rail--left .ui-rail--collapsible:not(.ui-rail--expanded), +body.panels-edge-right:not(.context-docked) .gev-panel-rail--right .ui-rail--collapsible:not(.ui-rail--expanded) { + flex-direction: row; + width: max-content; + gap: 4px; +} + +/* The open panel's icon joins the row instead of floating above it. */ +body.panels-edge-left .gev-panel-rail--left .ui-rail--collapsible:not(.ui-rail--expanded) .ui-tooltip { + position: static !important; + padding: 0 !important; + border: 0 !important; + background: none !important; + backdrop-filter: none !important; + -webkit-backdrop-filter: none !important; +} + +body.panels-edge-left #left-panel-stack > :not(.gev-panel-rail):not(.collapsed) { + transform: translate(calc(-1 * var(--panel-rail-clearance, 48px)), var(--edge-rail-row)); + max-height: calc(100% - var(--edge-rail-row)) !important; +} + +body.panels-edge-right:not(.context-docked) #right-context-rail > :not(.gev-panel-rail) { + transform: translate(var(--panel-rail-clearance, 48px), var(--edge-rail-row)); + max-height: calc(100% - var(--edge-rail-row)) !important; +} diff --git a/src/ui/styles/rail-edge.css b/src/ui/styles/rail-edge.css new file mode 100644 index 000000000..e1af40be4 --- /dev/null +++ b/src/ui/styles/rail-edge.css @@ -0,0 +1,102 @@ +/* ── Side rails: sliding highlight and edge scrolling ────────────────── + The open item's highlight is drawn once per rail, under the icons, and + slides from item to item when the panel changes. With the pointer in a + screen edge's strip, the rail's border lights up a little to say the wheel + now steps through its panels; the panel that opens slides in from the + direction of travel. */ +.ui-rail { + position: relative; + transition: + border-color 240ms ease, + border-radius var(--transition-fast); +} + +.ui-rail.ui-rail--edge-hot { + border-color: rgba(48, 194, 224, 0.4); +} + +/* The highlight itself, matching an open item's own look. */ +.ui-rail::before { + position: absolute; + top: 0; + left: 0; + z-index: 0; + width: var(--rail-glide-w, 32px); + height: var(--rail-glide-h, 32px); + background: var(--accent-dim); + border: 1px solid var(--accent-dim); + border-radius: var(--btn-radius); + box-sizing: border-box; + content: ''; + opacity: 0; + pointer-events: none; + transform: translate(var(--rail-glide-x, 0), var(--rail-glide-y, 0)); + transition: + transform 380ms cubic-bezier(0.22, 1, 0.36, 1), + width 380ms cubic-bezier(0.22, 1, 0.36, 1), + height 380ms cubic-bezier(0.22, 1, 0.36, 1), + border-radius var(--transition-fast), + opacity 200ms ease; +} + +.ui-rail--expanded::before { + border-radius: 16px; +} + +.ui-rail.ui-rail--glide::before { + opacity: 1; +} + +.ui-rail.ui-rail--glide-jump::before { + transition: opacity 200ms ease; +} + +/* While the shared highlight shows, the items stay clear and sit above it; + the open item keeps its accent colour, which eases in as it arrives. */ +.ui-rail--glide .ui-rail__item { + z-index: 1; + transition: + color 300ms ease, + background var(--transition-fast), + border-color var(--transition-fast), + border-radius var(--transition-fast); +} + +.ui-rail--glide .ui-rail__item--on, +.ui-rail--glide .ui-rail__item--on:hover:not(:disabled) { + background: transparent; + border-color: transparent; +} + +.rail-switch-down { + animation: rail-switch-down 340ms cubic-bezier(0.22, 1, 0.36, 1); +} + +.rail-switch-up { + animation: rail-switch-up 340ms cubic-bezier(0.22, 1, 0.36, 1); +} + +@keyframes rail-switch-down { + from { + opacity: 0; + translate: 0 16px; + } +} + +@keyframes rail-switch-up { + from { + opacity: 0; + translate: 0 -16px; + } +} + +@media (prefers-reduced-motion: reduce) { + .ui-rail::before { + transition: opacity 200ms ease; + } + + .rail-switch-down, + .rail-switch-up { + animation: none; + } +} diff --git a/src/ui/styles/rail-split.css b/src/ui/styles/rail-split.css new file mode 100644 index 000000000..1f8400dd1 --- /dev/null +++ b/src/ui/styles/rail-split.css @@ -0,0 +1,192 @@ +/* Experiment: with a left panel open, its rail icon leaves the rail and sits + level with the panel's title, as the panel's own tab. The other icons stay + in the rail underneath it and close the gap. With nothing open the rail keeps its + labelled pills. */ +.gev-panel-rail--left:has(.ui-rail--collapsible:not(.ui-rail--expanded) .ui-rail__item--on) { + /* The lifted chip (42px) centres on the panel title (26px into the + stack); the rail starts 6px below the chip. */ + top: 53px; +} + +.gev-panel-rail--left .ui-rail--collapsible:not(.ui-rail--expanded) { + position: relative; +} + +.gev-panel-rail--left + .ui-rail--collapsible:not(.ui-rail--expanded) + .ui-tooltip:has(> .ui-rail__item--on) { + position: absolute; + bottom: calc(100% + 6px); + left: -1px; + padding: 4px; + border: 1px solid var(--glass-border); + border-radius: calc(var(--btn-radius) + 4px); + background: var(--glass-bg); + backdrop-filter: blur(20px); + -webkit-backdrop-filter: blur(20px); +} + +.gev-panel-rail--left + .ui-rail--collapsible:not(.ui-rail--expanded) + .ui-tooltip:has(> .ui-rail__item--on) + .ui-rail__item { + width: 32px; +} + +/* With nothing open, the icons and their names split into two glass panels + side by side: the plain icon rail, and a name panel beside it with one row + per icon. A name is part of its button, so clicking it opens that panel. */ +.gev-panel-rail--left .ui-rail--expanded { + position: relative; + border-radius: calc(var(--btn-radius) + 4px); +} + +.gev-panel-rail--left .ui-rail--expanded .ui-rail__item { + width: 32px; + border-radius: var(--btn-radius); +} + +.gev-panel-rail--left .ui-rail--expanded::after { + content: ''; + position: absolute; + top: -1px; + bottom: -1px; + left: calc(100% + 6px); + width: 170px; + border: 1px solid var(--glass-border); + border-radius: calc(var(--btn-radius) + 4px); + background: var(--glass-bg); + backdrop-filter: blur(20px); + -webkit-backdrop-filter: blur(20px); + pointer-events: none; +} + +.gev-panel-rail--left .ui-rail--expanded .ui-rail__label { + position: absolute; + z-index: 1; + top: 0; + bottom: 0; + /* Past the rail's padding and border, the 6px gap, and the name panel's + border and inner padding. */ + left: calc(100% + 24px); + display: flex; + align-items: center; + max-width: 150px; + margin: 0; +} + +.gev-panel-rail--left .ui-rail--expanded .ui-rail__item:hover .ui-rail__label { + color: var(--text-primary); +} + +/* The column rises to sit just under the HUD readout instead of leaving a + gap above it, with or without a panel open, so opening one doesn't move + the rail down. */ +#left-panel-stack { + top: calc(var(--left-stack-safe-top, var(--left-stack-top)) + var(--panel-rail-lift, 0px)); +} + +/* The right rail splits the same way with nothing open, mirrored: the icon + rail stays on the screen edge and the name panel sits to its left. */ +.gev-panel-rail--right .ui-rail--expanded { + position: relative; + border-radius: calc(var(--btn-radius) + 4px); +} + +.gev-panel-rail--right .ui-rail--expanded .ui-rail__item { + width: 32px; + border-radius: var(--btn-radius); +} + +.gev-panel-rail--right .ui-rail--expanded::after { + content: ''; + position: absolute; + top: -1px; + bottom: -1px; + right: calc(100% + 6px); + width: 170px; + border: 1px solid var(--glass-border); + border-radius: calc(var(--btn-radius) + 4px); + background: var(--glass-bg); + backdrop-filter: blur(20px); + -webkit-backdrop-filter: blur(20px); + pointer-events: none; +} + +.gev-panel-rail--right .ui-rail--expanded .ui-rail__label { + position: absolute; + z-index: 1; + top: 0; + bottom: 0; + /* From the button's left edge back past the rail's padding and border, + the 6px gap and the 170px name panel, to the panel's inner padding. */ + left: -168px; + display: flex; + align-items: center; + max-width: 150px; + margin: 0; +} + +.gev-panel-rail--right .ui-rail--expanded .ui-rail__item:hover .ui-rail__label { + color: var(--text-primary); +} + +/* In clean view the screen-edge gutters stay empty: the HUD's vertical edge + readouts (ONA / COLL on the left, BAND / BITS / LVL on the right) are not + shown. Cyber lays its HUD out differently and keeps them. */ +:root:not([data-ui-theme='cyber']) body.ui-clean-view #intel-hud .hud-edge { + display: none !important; +} + +/* The bottom-right readout (GSD / ALT / AIS) has one more line than the + bottom-left one (MGRS / coordinates); it drops by that line so the two + corners start level. */ +#intel-hud[data-variant='tactical'] .hud-bottom-right { + bottom: calc(2vh + 6.5rem - 26px); +} + +@media (min-width: 1200px) { + #intel-hud[data-variant='tactical'] .hud-bottom-right { + bottom: calc(4.2rem - 26px); + } +} + +/* ── Contrast: rails and name panels read clearly over dark space as well + as bright imagery. ── */ +:is(.gev-panel-rail--left, .gev-panel-rail--right) .ui-rail { + background: rgba(16, 20, 28, 0.82) !important; + border-color: rgba(255, 255, 255, 0.14) !important; + box-shadow: + 0 6px 20px rgba(0, 0, 0, 0.45), + inset 0 1px 0 rgba(255, 255, 255, 0.05); +} + +:is(.gev-panel-rail--left, .gev-panel-rail--right) .ui-rail--expanded::after { + background: rgba(16, 20, 28, 0.82) !important; + border-color: rgba(255, 255, 255, 0.14) !important; + box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45); +} + +:is(.gev-panel-rail--left, .gev-panel-rail--right) .ui-rail__item { + color: rgba(225, 236, 242, 0.88); +} + +:is(.gev-panel-rail--left, .gev-panel-rail--right) .ui-rail__label { + color: rgba(225, 236, 242, 0.82) !important; +} + +:is(.gev-panel-rail--left, .gev-panel-rail--right) .ui-rail__item:hover { + color: #fff; +} + +/* The open item's highlight sits on the button itself, so it shows wherever + the button is (the lifted chip, the edge row). */ +:is(.gev-panel-rail--left, .gev-panel-rail--right) .ui-rail__item.ui-rail__item--on { + color: #00d4ff !important; + background: rgba(0, 212, 255, 0.15) !important; + border-color: rgba(0, 212, 255, 0.15) !important; +} + +:is(.gev-panel-rail--left, .gev-panel-rail--right) .ui-rail.ui-rail--glide::before { + display: none !important; +} diff --git a/src/ui/styles/shell-spacing.css b/src/ui/styles/shell-spacing.css new file mode 100644 index 000000000..7e67e526d --- /dev/null +++ b/src/ui/styles/shell-spacing.css @@ -0,0 +1,33 @@ +/* ── Shell spacing on wide screens ───────────────────────────────────── + With the map credits in the bottom-left corner pill, the tactical HUD's + corner readouts no longer need to stand clear of them, so they close the + empty bands: the top readouts sit just under the title block and the + bottom readouts just above the credits and the key chip. The side panels + lay themselves out around the HUD, so they gain the space. The first-run + card spans the same band. */ +@media (min-width: 1200px) { + #intel-hud[data-variant='tactical'] .hud-top-left, + #intel-hud[data-variant='tactical'] .hud-top-right { + top: 102px; + } + + #intel-hud[data-variant='tactical'] .hud-bottom-left, + #intel-hud[data-variant='tactical'] .hud-bottom-right { + bottom: 4.2rem; + } + + #first-run-launcher { + top: 102px; + max-height: calc(100vh - 102px - 4.2rem); + max-height: calc(100dvh - 102px - 4.2rem); + } +} + +/* The active style already shows top right ("ACTIVE STYLE · NORMAL"), so the + HUD's own style line is a duplicate wherever that indicator is shown. Phones + hide the indicator (responsive.css), so they keep the HUD line. */ +@media (min-width: 721px) { + body:not(.mobile-shell) #intel-hud #hud-mode { + display: none; + } +} From b080857c35bb1428253b85df74e17e098e26b192 Mon Sep 17 00:00:00 2001 From: Manjunath Paparaju Date: Fri, 13 Nov 2026 10:38:45 +0530 Subject: [PATCH 09/30] Make one scroll at a rail's edge step one panel A swipe is still speeding up when it first steps, and that rise in speed was read as a fresh flick, so one swipe could step two panels. A flick now counts only after the gesture has clearly slowed and a short moment after a step; a mouse wheel notch still steps each time. The rest of a gesture that has stepped is used up even when the pointer is no longer in the strip, so its coasting does not zoom the globe or scroll what opened under it. The strip is never wider than a rail's own column, a panel in either stack keeps its own scrolling, and the slide classes come off without an animation to end them (reduced motion). Co-authored-by: Sameh Khamis --- src/ui/railEdgeScroll.js | 79 +++++++++++++++++++++++++++++++--------- 1 file changed, 62 insertions(+), 17 deletions(-) diff --git a/src/ui/railEdgeScroll.js b/src/ui/railEdgeScroll.js index 42cfc91ca..57d94a998 100644 --- a/src/ui/railEdgeScroll.js +++ b/src/ui/railEdgeScroll.js @@ -14,9 +14,18 @@ const STEP_DELTA = 40; * gesture moves one step, however long it runs, trackpad coasting included. */ const GESTURE_GAP_MS = 180; -/** Things in the strip that keep their own pointer and wheel behaviour. */ +/** After a step, how long (ms) before the same motion can count as a new flick. */ +const STEP_COOLDOWN_MS = 220; +/** A wheel event this large (pixels) is a mouse wheel notch, not a trackpad. */ +const NOTCH_DELTA = 100; +/** The widest the strip gets, measured from the screen edge, whatever shape the rail takes. */ +const STRIP_MAX = 84; +/** + * Things in the strip that keep their own pointer and wheel behaviour: any + * control, and every panel in either side's stack (a panel scrolls itself). + */ const OWN_CONTROLS = - 'a, button, input, select, textarea, [role="dialog"], .ui-panel, #first-run-launcher, #cesium-credits'; + 'a, button, input, select, textarea, [role="dialog"], .ui-panel, #left-panel-stack > :not(.gev-panel-rail), #right-context-rail > :not(.gev-panel-rail), #first-run-launcher, #cesium-credits'; /** * @param {Document} [doc] @@ -32,6 +41,10 @@ export function installRailEdgeScroll(doc = globalThis.document) { let lastWheel = 0; let lastSpeed = 0; let stepped = false; + /** When the last step was taken, the fastest the gesture has been, and whether it has slowed since. */ + let steppedAt = 0; + let peakSpeed = 0; + let slowed = false; let frame = 0; const rails = () => @@ -103,10 +116,14 @@ export function installRailEdgeScroll(doc = globalThis.document) { if (doc.body.classList.contains('mobile-shell') || coarse?.matches) return null; for (const { side, rail } of rails()) { const box = rail.getBoundingClientRect(); + // From the screen edge to just past the rail, but never wider than a + // rail's own column: a rail laid out as a row across the top of its + // panels would otherwise claim most of the panel's width. + const width = doc.documentElement.clientWidth; const inStrip = side === 'left' - ? x <= box.right + STRIP_MARGIN - : x >= box.left - STRIP_MARGIN; + ? x <= Math.min(box.right + STRIP_MARGIN, STRIP_MAX) + : x >= Math.max(box.left - STRIP_MARGIN, width - STRIP_MAX); if (!inStrip) continue; if (rail.contains(target)) return rail; if (target?.closest?.(OWN_CONTROLS)) return null; @@ -151,37 +168,65 @@ export function installRailEdgeScroll(doc = globalThis.document) { panel.classList.remove('rail-switch-down', 'rail-switch-up'); void panel.offsetWidth; panel.classList.add(direction > 0 ? 'rail-switch-down' : 'rail-switch-up'); - panel.addEventListener( - 'animationend', - () => panel.classList.remove('rail-switch-down', 'rail-switch-up'), - { once: true }, - ); + // The classes come off when the slide ends, or after a moment where + // there is no slide to end (reduced motion). + const settle = () => { + win.clearTimeout(timer); + panel.removeEventListener('animationend', settle); + panel.classList.remove('rail-switch-down', 'rail-switch-up'); + }; + const timer = win.setTimeout(settle, 600); + panel.addEventListener('animationend', settle); } follow(); } function onWheel(event) { - if (!hot || event.ctrlKey) return; + if (event.ctrlKey) return; + const now = win.performance?.now?.() ?? Date.now(); + const inGesture = now - lastWheel <= GESTURE_GAP_MS; // Recheck: the pointer may not have moved since the panels changed. - if (railAt(event.clientX, event.target) !== hot) return setHot(null); + const stillHot = Boolean(hot) && railAt(event.clientX, event.target) === hot; + if (!stillHot) { + setHot(null); + // The rest of a gesture that has already stepped is used up here, so + // its coasting does not go on to zoom the globe or scroll what opened + // under the pointer. + if (stepped && inGesture) { + event.preventDefault(); + event.stopPropagation(); + lastWheel = now; + } + return; + } event.preventDefault(); event.stopPropagation(); - const now = win.performance?.now?.() ?? Date.now(); const speed = Math.abs(event.deltaY); - // A new gesture: after a pause, after turning round, or a fresh flick - // while the last one is still coasting (the speed jumps back up). + // A new gesture: after a pause, after turning round, a mouse wheel notch, + // or a fresh flick while the last one is still coasting. A flick is a + // rise in speed after the gesture has clearly slowed, and not in the + // moment after a step: a swipe is still speeding up when it first steps. const turned = travel && Math.sign(event.deltaY) !== Math.sign(travel); - const flick = stepped && speed > 20 && speed > lastSpeed * 2; - if (now - lastWheel > GESTURE_GAP_MS || turned || flick) { + const cooled = now - steppedAt > STEP_COOLDOWN_MS; + const notch = stepped && cooled && speed >= NOTCH_DELTA; + const flick = stepped && cooled && slowed && speed > Math.max(8, lastSpeed * 1.8); + if (!inGesture || turned || notch || flick) { travel = 0; stepped = false; + peakSpeed = 0; + slowed = false; } lastWheel = now; lastSpeed = speed; - if (stepped) return; + peakSpeed = Math.max(peakSpeed, speed); + if (stepped) { + if (speed < peakSpeed * 0.5) slowed = true; + return; + } travel += event.deltaY; if (Math.abs(travel) < STEP_DELTA) return; stepped = true; + steppedAt = now; step(Math.sign(travel)); } From 59ffa8753544f6f0574518da8afdf47a2375bf99 Mon Sep 17 00:00:00 2001 From: Manjunath Paparaju Date: Fri, 13 Nov 2026 10:44:45 +0530 Subject: [PATCH 10/30] Keep the left rail's order when its open item is lifted out Co-authored-by: Sameh Khamis --- src/ui/railEdgeScroll.js | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/ui/railEdgeScroll.js b/src/ui/railEdgeScroll.js index 57d94a998..4dfd56df6 100644 --- a/src/ui/railEdgeScroll.js +++ b/src/ui/railEdgeScroll.js @@ -61,9 +61,25 @@ export function installRailEdgeScroll(doc = globalThis.document) { // Vue rewrites a rail's class list when it folds its labels, so whether the // highlight is showing is kept here, and the classes are put back each time. const gliding = new WeakSet(); + + // Where a rail lifts its open item out to sit beside the panel's title, the + // items left in the rail follow on from it in turn, so the next one in line + // is the one directly under it and a step brings that one up. A rail that + // keeps its open item in place keeps its own order. + function reorder(rail, on) { + const slots = [...rail.children].filter((slot) => slot.querySelector?.('.ui-rail__item')); + const at = on ? slots.findIndex((slot) => slot.contains(on)) : -1; + const lifted = at >= 0 && win.getComputedStyle(slots[at]).position === 'absolute'; + slots.forEach((slot, index) => { + const order = lifted ? String((index - at + slots.length) % slots.length) : ''; + if (slot.style.order !== order) slot.style.order = order; + }); + } + function glide(rail) { rail.classList.toggle('ui-rail--edge-hot', rail === hot); const on = rail.querySelector('.ui-rail__item[aria-pressed="true"]'); + reorder(rail, on); if (!on?.offsetWidth) { gliding.delete(rail); rail.classList.remove('ui-rail--glide'); @@ -245,8 +261,9 @@ export function installRailEdgeScroll(doc = globalThis.document) { doc.removeEventListener('pointerout', onLeave); win.removeEventListener('wheel', onWheel, { capture: true }); win.removeEventListener('resize', onResize); - doc.querySelectorAll('.ui-rail').forEach((rail) => - rail.classList.remove('ui-rail--glide', 'ui-rail--glide-jump', 'ui-rail--edge-hot'), - ); + doc.querySelectorAll('.ui-rail').forEach((rail) => { + rail.classList.remove('ui-rail--glide', 'ui-rail--glide-jump', 'ui-rail--edge-hot'); + reorder(rail, null); + }); }; } From b090937e5fda51e91461a4d6d0a0228c7cd162df Mon Sep 17 00:00:00 2001 From: Manjunath Paparaju Date: Fri, 13 Nov 2026 10:51:01 +0530 Subject: [PATCH 11/30] Keep rail icons in place and move only the highlight The left rail no longer lifts its open icon out beside the panel title or reorders the rest behind it. Every icon keeps its place, open or not, and the rail's shared highlight slides to the open one, on both rails. The rail also holds one height whichever panel is open: its offset now allows for the stack rising by a different amount for a tall panel than at rest. Co-authored-by: Sameh Khamis --- src/ui/leftPanelRail.js | 7 +++-- src/ui/panelRails.test.mjs | 17 +++++++++--- src/ui/railEdgeScroll.js | 16 ----------- src/ui/styles/panel-edge.css | 10 ------- src/ui/styles/rail-split.css | 52 +++++++++--------------------------- 5 files changed, 30 insertions(+), 72 deletions(-) diff --git a/src/ui/leftPanelRail.js b/src/ui/leftPanelRail.js index 0b3e7ee2f..c5c65378b 100644 --- a/src/ui/leftPanelRail.js +++ b/src/ui/leftPanelRail.js @@ -283,13 +283,16 @@ export function layoutLeftPanelRail({ getComputedStyle(stack) .getPropertyValue?.('--panel-stack-top-pinned') ?.trim() === '1'; - const railOffset = `${(topPinned ? 0 : safeTop - layoutTop).toFixed(1)}px`; + // The stack itself rises by the lift below, by a different amount for a + // tall panel than at rest; the rail takes up the difference. + const lift = (top) => Math.min(0, obstacleSafeTop - top); + const railOffset = `${(topPinned ? 0 : safeTop + lift(safeTop) - layoutTop - lift(layoutTop)).toFixed(1)}px`; if (stack.style.getPropertyValue('--panel-rail-offset') !== railOffset) { stack.style.setProperty('--panel-rail-offset', railOffset); } // How far the column can rise before it meets the HUD readout, so the rail // and any open panel sit just under it, whether or not a panel is open. - const railLift = `${(topPinned ? 0 : Math.min(0, obstacleSafeTop - layoutTop)).toFixed(1)}px`; + const railLift = `${(topPinned ? 0 : lift(layoutTop)).toFixed(1)}px`; if (stack.style.getPropertyValue('--panel-rail-lift') !== railLift) { stack.style.setProperty('--panel-rail-lift', railLift); } diff --git a/src/ui/panelRails.test.mjs b/src/ui/panelRails.test.mjs index 40c2be20b..7edbc854a 100644 --- a/src/ui/panelRails.test.mjs +++ b/src/ui/panelRails.test.mjs @@ -359,14 +359,23 @@ test('right rail aligns to the left rail buttons while the left stack is offset' assert.equal(f.stack.dataset.safeTop, '286.7'); }); -test('left rail buttons hold still while a tall panel moves the stack', () => { +test('left rail buttons hold still whether the open panel is short or tall', () => { + // Where the rail sits: the stack's top, the stack's rise, and the rail's + // own offset inside the stack. + const railTop = (stack) => + (parseFloat(stack.style.getPropertyValue('--left-stack-safe-top')) * 900) / + 100 + + parseFloat(stack.style.getPropertyValue('--panel-rail-lift')) + + parseFloat(stack.style.getPropertyValue('--panel-rail-offset')); + const short = fixture('left'); + short.expand(short.first, 250); + short.run(); const f = fixture('left'); f.expand(f.first, 900); f.run(); assert.equal(f.stack.dataset.layoutMode, 'focus'); - assert.ok( - parseFloat(f.stack.style.getPropertyValue('--panel-rail-offset')) > 0, - ); + assert.notEqual(short.stack.dataset.layoutMode, 'focus'); + assert.ok(Math.abs(railTop(f.stack) - railTop(short.stack)) < 0.2); // A theme that pins the stack's top (Cyber) leaves nothing to offset. f.stack.computed.getPropertyValue = (name) => diff --git a/src/ui/railEdgeScroll.js b/src/ui/railEdgeScroll.js index 4dfd56df6..cf46ef02f 100644 --- a/src/ui/railEdgeScroll.js +++ b/src/ui/railEdgeScroll.js @@ -62,24 +62,9 @@ export function installRailEdgeScroll(doc = globalThis.document) { // highlight is showing is kept here, and the classes are put back each time. const gliding = new WeakSet(); - // Where a rail lifts its open item out to sit beside the panel's title, the - // items left in the rail follow on from it in turn, so the next one in line - // is the one directly under it and a step brings that one up. A rail that - // keeps its open item in place keeps its own order. - function reorder(rail, on) { - const slots = [...rail.children].filter((slot) => slot.querySelector?.('.ui-rail__item')); - const at = on ? slots.findIndex((slot) => slot.contains(on)) : -1; - const lifted = at >= 0 && win.getComputedStyle(slots[at]).position === 'absolute'; - slots.forEach((slot, index) => { - const order = lifted ? String((index - at + slots.length) % slots.length) : ''; - if (slot.style.order !== order) slot.style.order = order; - }); - } - function glide(rail) { rail.classList.toggle('ui-rail--edge-hot', rail === hot); const on = rail.querySelector('.ui-rail__item[aria-pressed="true"]'); - reorder(rail, on); if (!on?.offsetWidth) { gliding.delete(rail); rail.classList.remove('ui-rail--glide'); @@ -263,7 +248,6 @@ export function installRailEdgeScroll(doc = globalThis.document) { win.removeEventListener('resize', onResize); doc.querySelectorAll('.ui-rail').forEach((rail) => { rail.classList.remove('ui-rail--glide', 'ui-rail--glide-jump', 'ui-rail--edge-hot'); - reorder(rail, null); }); }; } diff --git a/src/ui/styles/panel-edge.css b/src/ui/styles/panel-edge.css index c9cfa4faf..79d19b6d2 100644 --- a/src/ui/styles/panel-edge.css +++ b/src/ui/styles/panel-edge.css @@ -71,16 +71,6 @@ body.panels-edge-right:not(.context-docked) .gev-panel-rail--right .ui-rail--col gap: 4px; } -/* The open panel's icon joins the row instead of floating above it. */ -body.panels-edge-left .gev-panel-rail--left .ui-rail--collapsible:not(.ui-rail--expanded) .ui-tooltip { - position: static !important; - padding: 0 !important; - border: 0 !important; - background: none !important; - backdrop-filter: none !important; - -webkit-backdrop-filter: none !important; -} - body.panels-edge-left #left-panel-stack > :not(.gev-panel-rail):not(.collapsed) { transform: translate(calc(-1 * var(--panel-rail-clearance, 48px)), var(--edge-rail-row)); max-height: calc(100% - var(--edge-rail-row)) !important; diff --git a/src/ui/styles/rail-split.css b/src/ui/styles/rail-split.css index 1f8400dd1..d84940233 100644 --- a/src/ui/styles/rail-split.css +++ b/src/ui/styles/rail-split.css @@ -1,37 +1,5 @@ -/* Experiment: with a left panel open, its rail icon leaves the rail and sits - level with the panel's title, as the panel's own tab. The other icons stay - in the rail underneath it and close the gap. With nothing open the rail keeps its - labelled pills. */ -.gev-panel-rail--left:has(.ui-rail--collapsible:not(.ui-rail--expanded) .ui-rail__item--on) { - /* The lifted chip (42px) centres on the panel title (26px into the - stack); the rail starts 6px below the chip. */ - top: 53px; -} - -.gev-panel-rail--left .ui-rail--collapsible:not(.ui-rail--expanded) { - position: relative; -} - -.gev-panel-rail--left - .ui-rail--collapsible:not(.ui-rail--expanded) - .ui-tooltip:has(> .ui-rail__item--on) { - position: absolute; - bottom: calc(100% + 6px); - left: -1px; - padding: 4px; - border: 1px solid var(--glass-border); - border-radius: calc(var(--btn-radius) + 4px); - background: var(--glass-bg); - backdrop-filter: blur(20px); - -webkit-backdrop-filter: blur(20px); -} - -.gev-panel-rail--left - .ui-rail--collapsible:not(.ui-rail--expanded) - .ui-tooltip:has(> .ui-rail__item--on) - .ui-rail__item { - width: 32px; -} +/* The left rail's icons keep their places whether or not a panel is open; + only the highlight moves to the open one. */ /* With nothing open, the icons and their names split into two glass panels side by side: the plain icon rail, and a name panel beside it with one row @@ -179,14 +147,18 @@ color: #fff; } -/* The open item's highlight sits on the button itself, so it shows wherever - the button is (the lifted chip, the edge row). */ +/* The open item takes the accent colour; its highlight is the rail's shared + one, which slides to it. Without that highlight the button carries its own. */ :is(.gev-panel-rail--left, .gev-panel-rail--right) .ui-rail__item.ui-rail__item--on { color: #00d4ff !important; - background: rgba(0, 212, 255, 0.15) !important; - border-color: rgba(0, 212, 255, 0.15) !important; } -:is(.gev-panel-rail--left, .gev-panel-rail--right) .ui-rail.ui-rail--glide::before { - display: none !important; +:is(.gev-panel-rail--left, .gev-panel-rail--right) .ui-rail:not(.ui-rail--glide) .ui-rail__item.ui-rail__item--on { + background: rgba(0, 212, 255, 0.15); + border-color: rgba(0, 212, 255, 0.15); +} + +:is(.gev-panel-rail--left, .gev-panel-rail--right) .ui-rail::before { + background: rgba(0, 212, 255, 0.15); + border-color: rgba(0, 212, 255, 0.28); } From 9cc2a1811b2b7e18ff3fb4e7122e6d915a503b93 Mon Sep 17 00:00:00 2001 From: Manjunath Paparaju Date: Fri, 13 Nov 2026 10:52:37 +0530 Subject: [PATCH 12/30] Leave at least half a second between edge-scroll steps A scroll that would step a rail again within 500 ms of the last step is used up without stepping, so panels never switch back to back. Co-authored-by: Sameh Khamis --- src/ui/railEdgeScroll.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/ui/railEdgeScroll.js b/src/ui/railEdgeScroll.js index cf46ef02f..c66b461ab 100644 --- a/src/ui/railEdgeScroll.js +++ b/src/ui/railEdgeScroll.js @@ -16,6 +16,12 @@ const STEP_DELTA = 40; const GESTURE_GAP_MS = 180; /** After a step, how long (ms) before the same motion can count as a new flick. */ const STEP_COOLDOWN_MS = 220; +/** + * The least time (ms) between two steps, whatever the wheel does. A motion + * that would step sooner is used up without stepping, so panels never switch + * back to back. + */ +const STEP_GAP_MS = 500; /** A wheel event this large (pixels) is a mouse wheel notch, not a trackpad. */ const NOTCH_DELTA = 100; /** The widest the strip gets, measured from the screen edge, whatever shape the rail takes. */ @@ -227,6 +233,7 @@ export function installRailEdgeScroll(doc = globalThis.document) { travel += event.deltaY; if (Math.abs(travel) < STEP_DELTA) return; stepped = true; + if (now - steppedAt < STEP_GAP_MS) return; steppedAt = now; step(Math.sign(travel)); } From 422a11d9a4998152eea6de68b02faf266d2ad30a Mon Sep 17 00:00:00 2001 From: Manjunath Paparaju Date: Fri, 13 Nov 2026 11:07:06 +0530 Subject: [PATCH 13/30] Give a rail's open icon its own island With a panel open, a rail's glass is drawn in pieces: one around the open icon and one for each run of icons above and below it, with a small break between them. The icons keep their places; the rail's icon spacing grows from 2 px to 12 px to leave room for the break. The shadow rule for the old lifted icon is removed. Co-authored-by: Sameh Khamis --- src/ui/styles/rail-split.css | 81 ++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/src/ui/styles/rail-split.css b/src/ui/styles/rail-split.css index d84940233..22313cc7b 100644 --- a/src/ui/styles/rail-split.css +++ b/src/ui/styles/rail-split.css @@ -162,3 +162,84 @@ background: rgba(0, 212, 255, 0.15); border-color: rgba(0, 212, 255, 0.28); } + +/* ── The open icon is its own island ── + With a panel open, the rail's glass is drawn in pieces behind its icons: + one piece for the open icon, and one for each run of icons above and below + it. The icons keep their places, open or not; the spacing between them is + what leaves room for the break. */ +:is(.gev-panel-rail--left, .gev-panel-rail--right) .ui-rail { + gap: 12px; +} + +:is(body:not(.panels-edge-left) .gev-panel-rail--left, body:not(.panels-edge-right) .gev-panel-rail--right) + .ui-rail--collapsible:not(.ui-rail--expanded):has(.ui-rail__item--on) { + background: none !important; + border-color: transparent !important; + box-shadow: none !important; + backdrop-filter: none; + -webkit-backdrop-filter: none; +} + +:is(body:not(.panels-edge-left) .gev-panel-rail--left, body:not(.panels-edge-right) .gev-panel-rail--right) + .ui-rail--collapsible:not(.ui-rail--expanded):has(.ui-rail__item--on) + > .ui-tooltip::before { + position: absolute; + inset: -6px -5px; + z-index: -1; + background: rgba(16, 20, 28, 0.82); + border: solid rgba(255, 255, 255, 0.14); + border-width: 0 1px; + backdrop-filter: blur(20px); + -webkit-backdrop-filter: blur(20px); + content: ''; + pointer-events: none; +} + +/* The ends of the rail. */ +:is(body:not(.panels-edge-left) .gev-panel-rail--left, body:not(.panels-edge-right) .gev-panel-rail--right) + .ui-rail--collapsible:not(.ui-rail--expanded):has(.ui-rail__item--on) + > .ui-tooltip:first-child::before { + top: -5px; + border-top-width: 1px; + border-top-left-radius: 14px; + border-top-right-radius: 14px; +} + +:is(body:not(.panels-edge-left) .gev-panel-rail--left, body:not(.panels-edge-right) .gev-panel-rail--right) + .ui-rail--collapsible:not(.ui-rail--expanded):has(.ui-rail__item--on) + > .ui-tooltip:last-child::before { + bottom: -5px; + border-bottom-width: 1px; + border-bottom-left-radius: 14px; + border-bottom-right-radius: 14px; +} + +/* The runs stop short of the open icon. */ +:is(body:not(.panels-edge-left) .gev-panel-rail--left, body:not(.panels-edge-right) .gev-panel-rail--right) + .ui-rail--collapsible:not(.ui-rail--expanded):has(.ui-rail__item--on) + > .ui-tooltip:has(+ .ui-tooltip > .ui-rail__item--on)::before { + bottom: -1px; + border-bottom-width: 1px; + border-bottom-left-radius: 14px; + border-bottom-right-radius: 14px; +} + +:is(body:not(.panels-edge-left) .gev-panel-rail--left, body:not(.panels-edge-right) .gev-panel-rail--right) + .ui-rail--collapsible:not(.ui-rail--expanded):has(.ui-rail__item--on) + > .ui-tooltip:has(> .ui-rail__item--on) + .ui-tooltip::before { + top: -1px; + border-top-width: 1px; + border-top-left-radius: 14px; + border-top-right-radius: 14px; +} + +/* The open icon's own piece. */ +:is(body:not(.panels-edge-left) .gev-panel-rail--left, body:not(.panels-edge-right) .gev-panel-rail--right) + .ui-rail--collapsible:not(.ui-rail--expanded):has(.ui-rail__item--on) + > .ui-tooltip:has(> .ui-rail__item--on)::before { + inset: -4px -5px; + border-width: 1px; + border-radius: 14px; + box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45); +} From 81f3602134744b89b63ca3594644bde92e1cab1d Mon Sep 17 00:00:00 2001 From: Manjunath Paparaju Date: Fri, 13 Nov 2026 13:03:12 +0530 Subject: [PATCH 14/30] Hold an edge-scroll step that comes too soon instead of dropping it A scroll that reached a step within 500 ms of the last one was used up without stepping, so mouse wheel notches 300 ms apart stepped only every other notch and a second swipe inside the gap did nothing. Such a step now waits and fires once the gap has passed (one held at most, skipped if the pointer has left the strip), and the held timer is cleared on teardown. A comment naming the items cockpit hides is corrected. Co-authored-by: Sameh Khamis --- src/ui/railEdgeScroll.js | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/ui/railEdgeScroll.js b/src/ui/railEdgeScroll.js index c66b461ab..7b965cda0 100644 --- a/src/ui/railEdgeScroll.js +++ b/src/ui/railEdgeScroll.js @@ -18,8 +18,8 @@ const GESTURE_GAP_MS = 180; const STEP_COOLDOWN_MS = 220; /** * The least time (ms) between two steps, whatever the wheel does. A motion - * that would step sooner is used up without stepping, so panels never switch - * back to back. + * that would step sooner waits and steps once the gap has passed (one step + * held at most), so panels never switch back to back and no step is lost. */ const STEP_GAP_MS = 500; /** A wheel event this large (pixels) is a mouse wheel notch, not a trackpad. */ @@ -49,6 +49,8 @@ export function installRailEdgeScroll(doc = globalThis.document) { let stepped = false; /** When the last step was taken, the fastest the gesture has been, and whether it has slowed since. */ let steppedAt = 0; + /** A step waiting for the gap to pass, if any. */ + let heldStep = 0; let peakSpeed = 0; let slowed = false; let frame = 0; @@ -59,7 +61,9 @@ export function installRailEdgeScroll(doc = globalThis.document) { .filter(({ rail }) => rail && rail.getBoundingClientRect().width > 0); const items = (rail) => - [...rail.querySelectorAll('.ui-rail__item')].filter((item) => !item.disabled); + // Only items that show: a theme or mode may hide some, and the wheel must + // not open those. + [...rail.querySelectorAll('.ui-rail__item')].filter((item) => !item.disabled && item.offsetWidth > 0); // ── The sliding highlight ── // Each rail draws it as a ::before under its items, placed by custom @@ -233,9 +237,22 @@ export function installRailEdgeScroll(doc = globalThis.document) { travel += event.deltaY; if (Math.abs(travel) < STEP_DELTA) return; stepped = true; - if (now - steppedAt < STEP_GAP_MS) return; - steppedAt = now; - step(Math.sign(travel)); + const direction = Math.sign(travel); + const wait = STEP_GAP_MS - (now - steppedAt); + if (wait <= 0) { + steppedAt = now; + step(direction); + return; + } + // Too soon after the last step: hold this one until the gap has passed. + if (heldStep) return; + heldStep = win.setTimeout(() => { + heldStep = 0; + // The pointer may have left the strip meanwhile; then nothing steps. + if (!hot) return; + steppedAt = win.performance?.now?.() ?? Date.now(); + step(direction); + }, wait); } const onResize = () => follow(2); @@ -246,6 +263,7 @@ export function installRailEdgeScroll(doc = globalThis.document) { follow(); return () => { + win.clearTimeout(heldStep); setHot(null); observer?.disconnect(); win.cancelAnimationFrame(frame); From 9261279639c2fb60fcdb622d69aa63c9b2919750 Mon Sep 17 00:00:00 2001 From: Manjunath Paparaju Date: Fri, 13 Nov 2026 15:42:31 +0530 Subject: [PATCH 15/30] Drop a held edge-scroll step when the motion turns or the pointer moves to the other rail Co-authored-by: Sameh Khamis --- src/ui/railEdgeScroll.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/ui/railEdgeScroll.js b/src/ui/railEdgeScroll.js index 7b965cda0..548f79668 100644 --- a/src/ui/railEdgeScroll.js +++ b/src/ui/railEdgeScroll.js @@ -222,6 +222,12 @@ export function installRailEdgeScroll(doc = globalThis.document) { const notch = stepped && cooled && speed >= NOTCH_DELTA; const flick = stepped && cooled && slowed && speed > Math.max(8, lastSpeed * 1.8); if (!inGesture || turned || notch || flick) { + // A held step belongs to the motion it came from; a reversal or a new + // flick replaces it rather than queueing behind it. + if (turned && heldStep) { + win.clearTimeout(heldStep); + heldStep = 0; + } travel = 0; stepped = false; peakSpeed = 0; @@ -246,10 +252,12 @@ export function installRailEdgeScroll(doc = globalThis.document) { } // Too soon after the last step: hold this one until the gap has passed. if (heldStep) return; + const heldRail = hot; heldStep = win.setTimeout(() => { heldStep = 0; - // The pointer may have left the strip meanwhile; then nothing steps. - if (!hot) return; + // The pointer may have left the strip, or moved to the other rail, + // meanwhile; then nothing steps. + if (!hot || hot !== heldRail) return; steppedAt = win.performance?.now?.() ?? Date.now(); step(direction); }, wait); From 129b35e47078c61e3030eaae493d09b70e87f0fc Mon Sep 17 00:00:00 2001 From: Manjunath Paparaju Date: Fri, 13 Nov 2026 16:00:22 +0530 Subject: [PATCH 16/30] Show the rail highlight at icon size when a first panel opens Opening a panel from the labelled rail folds its pills to icons over a few frames, and the highlight faded in at a pill's width and then shrank, as did the open button's own fill. The highlight now appears only once the open button is an icon again (square), its size changes at once rather than easing, and the open button carries no fill of its own. Co-authored-by: Sameh Khamis --- src/ui/railEdgeScroll.js | 5 +++++ src/ui/styles/rail-edge.css | 5 +++-- src/ui/styles/rail-split.css | 8 +++++--- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/ui/railEdgeScroll.js b/src/ui/railEdgeScroll.js index 548f79668..2a7a606c6 100644 --- a/src/ui/railEdgeScroll.js +++ b/src/ui/railEdgeScroll.js @@ -83,6 +83,11 @@ export function installRailEdgeScroll(doc = globalThis.document) { const railBox = rail.getBoundingClientRect(); const box = on.getBoundingClientRect(); const shown = gliding.has(rail); + // A rail opening its first panel folds its labelled pills to icons, the + // buttons shrinking over a few frames; the highlight waits until the open + // button is an icon again (square) rather than fading in at a pill's + // width and then shrinking. + if (!shown && (rail.classList.contains('ui-rail--expanded') || box.width > box.height + 2)) return; // Appearing from nothing: jump into place, then fade in. rail.classList.toggle('ui-rail--glide-jump', !shown); rail.style.setProperty('--rail-glide-x', `${box.left - railBox.left - rail.clientLeft}px`); diff --git a/src/ui/styles/rail-edge.css b/src/ui/styles/rail-edge.css index e1af40be4..cbcdb0eda 100644 --- a/src/ui/styles/rail-edge.css +++ b/src/ui/styles/rail-edge.css @@ -31,10 +31,11 @@ opacity: 0; pointer-events: none; transform: translate(var(--rail-glide-x, 0), var(--rail-glide-y, 0)); + /* Only the position slides. The size follows at once: it changes only + when the rail changes shape (its labelled pills folding to icons as a + panel opens), and a size easing there reads as a stretch. */ transition: transform 380ms cubic-bezier(0.22, 1, 0.36, 1), - width 380ms cubic-bezier(0.22, 1, 0.36, 1), - height 380ms cubic-bezier(0.22, 1, 0.36, 1), border-radius var(--transition-fast), opacity 200ms ease; } diff --git a/src/ui/styles/rail-split.css b/src/ui/styles/rail-split.css index 22313cc7b..f974b0cbc 100644 --- a/src/ui/styles/rail-split.css +++ b/src/ui/styles/rail-split.css @@ -148,14 +148,16 @@ } /* The open item takes the accent colour; its highlight is the rail's shared - one, which slides to it. Without that highlight the button carries its own. */ + one, which slides to it. The button carries no fill of its own: as a rail + folds its labelled pills to icons, a fill on the shrinking button would + read as the highlight stretching. */ :is(.gev-panel-rail--left, .gev-panel-rail--right) .ui-rail__item.ui-rail__item--on { color: #00d4ff !important; } :is(.gev-panel-rail--left, .gev-panel-rail--right) .ui-rail:not(.ui-rail--glide) .ui-rail__item.ui-rail__item--on { - background: rgba(0, 212, 255, 0.15); - border-color: rgba(0, 212, 255, 0.15); + background: none; + border-color: transparent; } :is(.gev-panel-rail--left, .gev-panel-rail--right) .ui-rail::before { From 4568b9ff12af3df212a236fda204c56f0d76103b Mon Sep 17 00:00:00 2001 From: Manjunath Paparaju Date: Fri, 13 Nov 2026 16:01:15 +0530 Subject: [PATCH 17/30] Fold the side rails' labels at once When a panel opened or closed, the rails' labels eased their width, which stretched and shrank every button in the rail. On the side rails the labels now fold away and come back at once; only their fade eases. Co-authored-by: Sameh Khamis --- src/ui/styles/rail-split.css | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/ui/styles/rail-split.css b/src/ui/styles/rail-split.css index f974b0cbc..72debe865 100644 --- a/src/ui/styles/rail-split.css +++ b/src/ui/styles/rail-split.css @@ -245,3 +245,10 @@ border-radius: 14px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45); } + +/* The side rails fold their labels away at once when a panel opens, and back + when it closes: easing the labels' width made every button visibly + stretch and shrink. Only their fade eases. */ +:is(.gev-panel-rail--left, .gev-panel-rail--right) .ui-rail__label { + transition: opacity var(--transition-fast); +} From 4debb49fe07ef90758907a9ae8257187c03424ff Mon Sep 17 00:00:00 2001 From: Manjunath Paparaju Date: Fri, 13 Nov 2026 16:13:26 +0530 Subject: [PATCH 18/30] Place a rail's highlight again whenever the rail changes size The highlight was placed only when an item was pressed or released, the window resized, or the pointer moved through an edge strip. A rail hidden and shown again (Context docked and undocked) was left with its open item unmarked, and a rail turned from a column to a row (panels moved to the screen edge) kept its highlight where the icon had been. Each rail is now watched for size changes, and its highlight placed again when it changes. Co-authored-by: Sameh Khamis --- src/ui/railEdgeScroll.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/ui/railEdgeScroll.js b/src/ui/railEdgeScroll.js index 2a7a606c6..de3c2e39a 100644 --- a/src/ui/railEdgeScroll.js +++ b/src/ui/railEdgeScroll.js @@ -105,6 +105,7 @@ export function installRailEdgeScroll(doc = globalThis.document) { win.cancelAnimationFrame(frame); let left = frames; const tick = () => { + watchRails(); doc.querySelectorAll('.ui-rail').forEach(glide); if ((left -= 1) > 0) frame = win.requestAnimationFrame(tick); }; @@ -126,6 +127,23 @@ export function installRailEdgeScroll(doc = globalThis.document) { attributeFilter: ['aria-pressed'], }); + // A rail also changes shape with nothing pressed or released: hidden and + // shown again (Context docked and undocked), or turned from a column to a + // row (panels moved to the screen edge). Its highlight is placed again + // whenever its size changes, so it is never left where an icon was. + const sized = + typeof win.ResizeObserver === 'function' ? new win.ResizeObserver(() => follow(2)) : null; + const watched = new WeakSet(); + const watchRails = () => { + if (!sized) return; + doc.querySelectorAll('.ui-rail').forEach((rail) => { + if (watched.has(rail)) return; + watched.add(rail); + sized.observe(rail); + }); + }; + watchRails(); + // ── The edge strip ── /** The rail whose strip holds the point, unless a control there owns it. */ function railAt(x, target) { @@ -279,6 +297,7 @@ export function installRailEdgeScroll(doc = globalThis.document) { win.clearTimeout(heldStep); setHot(null); observer?.disconnect(); + sized?.disconnect(); win.cancelAnimationFrame(frame); doc.removeEventListener('pointermove', onMove); doc.removeEventListener('pointerout', onLeave); From 8da632cc2d2f099ac6e1f64c59e71954231ffd96 Mon Sep 17 00:00:00 2001 From: Manjunath Paparaju Date: Fri, 13 Nov 2026 16:55:01 +0530 Subject: [PATCH 19/30] Line the side rails up and show coordinates once in Minimal HUD - The right rail now starts level with the left one whether or not a panel is open on it. It used to rise to 4% of the screen when one was open, which in Tactical and Cyber a top-right readout pushed back down, but in Minimal (which has none) left it about 35 px above the left rail. - Minimal no longer shows its full-width coordinate strip above the corner coordinates block, which showed the same position twice; it keeps the corner block, where the other layouts have it. This changes upstream's Minimal layout. Co-authored-by: Sameh Khamis --- src/ui/rightPanelRail.js | 13 +++++++------ src/ui/styles/overlays.css | 4 +++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/ui/rightPanelRail.js b/src/ui/rightPanelRail.js index e92d2267b..352ebda94 100644 --- a/src/ui/rightPanelRail.js +++ b/src/ui/rightPanelRail.js @@ -236,19 +236,20 @@ export function layoutRightPanelRail({ // CCTV does the same, so its feed and controls have the room. const FULL_HEIGHT = new Set(['global-context-panel', 'cctv-panel']); const contextOpen = panels.some( - (panel) => FULL_HEIGHT.has(panel.id) && !panel.classList.contains('collapsed'), + (panel) => + FULL_HEIGHT.has(panel.id) && !panel.classList.contains('collapsed'), ); - // Any open panel starts from that same raised top, so switching between - // Context, CCTV and Street Level does not move the column. Only the two - // above also stretch to the bottom. - const anyOpen = panels.some((panel) => !panel.classList.contains('collapsed')); + // Every panel starts level with the left rail, open or not, so the two + // rails line up in every HUD layout (Minimal has no top-right readout to + // push this column down) and switching between Context, CCTV and Street + // Level does not move it. Only the two above also stretch to the bottom. const layout = resolveHudRailLayout({ viewportHeight, panelHeight: naturalHeight, laneLeft: stackRect.left, laneRight: stackRect.right, obstacles: obstacleRects, - baseTop: anyOpen ? viewportHeight * 0.04 : alignedTop, + baseTop: alignedTop, baseBottom: viewportHeight * 0.96, gap: safeGap, align: 'start', diff --git a/src/ui/styles/overlays.css b/src/ui/styles/overlays.css index 85aaafa06..b45611785 100644 --- a/src/ui/styles/overlays.css +++ b/src/ui/styles/overlays.css @@ -310,8 +310,10 @@ bottom: 12vh; } +/* Minimal keeps its coordinates in the corner block, where the other layouts + have them; the full-width strip would only repeat the same position. */ #intel-hud[data-variant='minimal'] .hud-bottom-bar { - display: flex; + display: none; bottom: calc(12vh + 4rem); } From 85415bda97522cb2d235bb1295a1c653a075e0f9 Mon Sep 17 00:00:00 2001 From: Manjunath Paparaju Date: Sat, 14 Nov 2026 13:15:07 -0800 Subject: [PATCH 20/30] Install edge scrolling and the rail styles in the shell Co-authored-by: Sameh Khamis --- index.html | 2 +- src/ui/applicationShell.js | 4 ++++ style.css | 6 ++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index f3057f742..806a8b41b 100644 --- a/index.html +++ b/index.html @@ -26,7 +26,7 @@ with the sources: src/materialSymbolsSubset.test.mjs fails when a source names a glyph this list is missing, because a missing glyph does not draw a box — the ligature never forms and the element renders the literal word. --> - +
diff --git a/src/ui/applicationShell.js b/src/ui/applicationShell.js index 1fd86824f..564578e60 100644 --- a/src/ui/applicationShell.js +++ b/src/ui/applicationShell.js @@ -65,6 +65,7 @@ import { useHudStore } from './stores/hud.js'; import { useDisplayStore } from './stores/display.js'; import { useLocaleStore } from './stores/locale.js'; import { useLocationStore } from './stores/location.js'; +import { installRailEdgeScroll } from './railEdgeScroll.js'; import { useCockpitStore } from './stores/cockpit.js'; import { useGlobeActionsStore } from './stores/globeActions.js'; import { useRecordingStore } from './stores/recording.js'; @@ -164,6 +165,8 @@ export class StyleManager extends ShellFacade { }); // Vue views share this runtime and its stores; dispose unmounts them. this._ui = createUiRuntime({ pinia: applicationPinia() }); + // Scrolling at a screen edge steps through that side's rail panels. + this._removeRailEdgeScroll = installRailEdgeScroll(); this._feedback = new ShellFeedback({ readLayers: () => withPlacePacks(this._dataManager?.getAll?.() || []), }); @@ -1856,6 +1859,7 @@ export class StyleManager extends ShellFacade { const { destroyTrackedReadout, destroyWorldOverlay, destroyDetection } = this.services; if (this._disposed) return; + this._removeRailEdgeScroll?.(); this._shareRestoration.destroy(); this._feedback.clearLoadingStatus(); this._disposed = true; diff --git a/style.css b/style.css index 45f4f3eff..976aa0f8d 100644 --- a/style.css +++ b/style.css @@ -45,5 +45,11 @@ @import './src/ui/styles/rtl.css'; @import './src/ui/styles/mobile-shell.css'; @import './src/ui/styles/annotations.css'; +@import './src/ui/styles/credits.css'; +@import './src/ui/styles/shell-spacing.css'; +@import './src/ui/styles/rail-edge.css'; +@import './src/ui/styles/rail-split.css'; +@import './src/ui/styles/left-tools.css'; +@import './src/ui/styles/panel-edge.css'; @import './src/ui/styles/ai-chat.css'; @import './src/ui/styles/cyber.css'; From 605bf5b564dd1968c41b698a2c9eafebdde3ff86 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Sat, 14 Nov 2026 13:36:12 -0800 Subject: [PATCH 21/30] Keep the dock's Location and Visual Presets trays on desktop Nothing replaces them on this branch yet, so the dock keeps them. The credit pill and the HUD spacing built on it are left for a change of their own. Co-authored-by: Manjunath Paparaju --- src/ui/styles/credits.css | 50 ------------ src/ui/styles/left-tools.css | 130 -------------------------------- src/ui/styles/shell-spacing.css | 33 -------- style.css | 2 - 4 files changed, 215 deletions(-) delete mode 100644 src/ui/styles/credits.css delete mode 100644 src/ui/styles/shell-spacing.css diff --git a/src/ui/styles/credits.css b/src/ui/styles/credits.css deleted file mode 100644 index be4160a66..000000000 --- a/src/ui/styles/credits.css +++ /dev/null @@ -1,50 +0,0 @@ -/* ── Map attribution ─────────────────────────────────────────────────── - The required Cesium / imagery credits sit in a small glass pill. On wide - screens it drops to the bottom-left corner, clear of the HUD's coordinate - readout and left of the command dock; narrower screens keep the raised - position the dock rules give it. Attribution must stay visible. */ -body:not(.ui-clean-view):not(.recording-mode) #cesium-credits, -body.ui-clean-view #cesium-credits, -body.recording-mode #cesium-credits { - display: inline-flex; - align-items: center; - height: auto !important; - padding: 0.3rem 0.75rem 0.3rem 0.45rem; - background: var(--glass-bg); - border: 1px solid var(--glass-border); - border-radius: 999px; - box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35); - backdrop-filter: blur(20px) saturate(1.3); - -webkit-backdrop-filter: blur(20px) saturate(1.3); - text-shadow: none; -} - -#cesium-credits .cesium-widget-credits { - position: static !important; - display: inline-flex; - align-items: center; - gap: 0.5rem; - width: auto !important; - height: auto !important; - padding: 0 !important; -} - -#cesium-credits img { - height: 18px; - vertical-align: middle !important; -} - -@media (min-width: 1200px) { - body:not(.ui-clean-view):not(.recording-mode) #cesium-credits, - body:not(.ui-clean-view):not(.recording-mode):has( - #intel-hud[data-variant='minimal'].active - ) - #cesium-credits { - right: auto; - bottom: 1.1rem; - left: 1.5rem; - /* Never reach under the centred command dock (about 30rem wide). */ - max-width: calc(50vw - 17rem); - overflow: hidden; - } -} diff --git a/src/ui/styles/left-tools.css b/src/ui/styles/left-tools.css index 0ce9759a8..83da30251 100644 --- a/src/ui/styles/left-tools.css +++ b/src/ui/styles/left-tools.css @@ -1,133 +1,3 @@ -/* On desktop and tablet the omnibox finds places and Visual (left rail) - holds the presets, so the command dock keeps only voice. Phones keep the - trays in their sheets. */ -body:not(.mobile-shell) #command-dock > #control-panel, -body:not(.mobile-shell) #command-dock > #location-bar { - display: none; -} - -/* ── Visual: presets and map source at the top of the panel ─────────── */ -.visual-presets { - display: grid; - gap: 8px; - padding: 2px 0 12px; - margin-bottom: 10px; - border-bottom: 1px solid var(--glass-border); -} - -.visual-presets__heading { - margin: 4px 0 0; - color: var(--text-secondary); - font: 600 10px/1.2 var(--font-mono); - letter-spacing: 0.14em; - text-transform: uppercase; -} - -.visual-presets__heading--row { - display: flex; - justify-content: space-between; - gap: 8px; -} - -.visual-presets__status { - color: var(--accent); -} - -.visual-presets__status.warn { - color: #ff9f43; -} - -.visual-presets__grid { - display: grid; - grid-template-columns: repeat(3, minmax(0, 1fr)); - gap: 6px; -} - -.visual-presets__style { - position: relative; - display: grid; - justify-items: center; - gap: 4px; - padding: 9px 4px 7px; - color: var(--text-secondary); - background: rgba(255, 255, 255, 0.03); - border: 1px solid var(--glass-border); - border-radius: var(--btn-radius); - cursor: pointer; -} - -.visual-presets__style:hover { - color: var(--text-primary); - background: rgba(255, 255, 255, 0.06); -} - -.visual-presets__style.active { - color: var(--accent); - background: var(--accent-dim); - border-color: var(--accent-dim); -} - -.visual-presets__icon { - font-size: 15px; - line-height: 1; -} - -.visual-presets__label { - font: 500 11px/1 var(--font-sans); -} - -.visual-presets__key { - color: var(--text-secondary); - font: 9px/1 var(--font-mono); - opacity: 0.6; -} - -.visual-presets__key { - position: absolute; - top: 4px; - right: 5px; -} - -.visual-presets__chips { - display: flex; - flex-wrap: wrap; - gap: 5px; -} - -.visual-presets__chip { - display: inline-flex; - align-items: center; - gap: 5px; - padding: 5px 9px; - color: var(--text-secondary); - font: 500 11px/1.2 var(--font-sans); - background: rgba(255, 255, 255, 0.03); - border: 1px solid var(--glass-border); - border-radius: 999px; - cursor: pointer; -} - -.visual-presets__chip small { - font-size: 9px; - opacity: 0.6; -} - -.visual-presets__chip:hover { - color: var(--text-primary); - background: rgba(255, 255, 255, 0.06); -} - -.visual-presets__chip.active { - color: var(--accent); - background: var(--accent-dim); - border-color: var(--accent-dim); -} - -.visual-presets__chip.unavailable { - opacity: 0.45; - cursor: default; -} - /* Visual in the left column: it takes clicks (the column itself lets them through to the globe) and stays inside the column, scrolling as a whole. */ #left-panel-stack > #pp-toggles { diff --git a/src/ui/styles/shell-spacing.css b/src/ui/styles/shell-spacing.css deleted file mode 100644 index 7e67e526d..000000000 --- a/src/ui/styles/shell-spacing.css +++ /dev/null @@ -1,33 +0,0 @@ -/* ── Shell spacing on wide screens ───────────────────────────────────── - With the map credits in the bottom-left corner pill, the tactical HUD's - corner readouts no longer need to stand clear of them, so they close the - empty bands: the top readouts sit just under the title block and the - bottom readouts just above the credits and the key chip. The side panels - lay themselves out around the HUD, so they gain the space. The first-run - card spans the same band. */ -@media (min-width: 1200px) { - #intel-hud[data-variant='tactical'] .hud-top-left, - #intel-hud[data-variant='tactical'] .hud-top-right { - top: 102px; - } - - #intel-hud[data-variant='tactical'] .hud-bottom-left, - #intel-hud[data-variant='tactical'] .hud-bottom-right { - bottom: 4.2rem; - } - - #first-run-launcher { - top: 102px; - max-height: calc(100vh - 102px - 4.2rem); - max-height: calc(100dvh - 102px - 4.2rem); - } -} - -/* The active style already shows top right ("ACTIVE STYLE · NORMAL"), so the - HUD's own style line is a duplicate wherever that indicator is shown. Phones - hide the indicator (responsive.css), so they keep the HUD line. */ -@media (min-width: 721px) { - body:not(.mobile-shell) #intel-hud #hud-mode { - display: none; - } -} diff --git a/style.css b/style.css index 976aa0f8d..012714e4e 100644 --- a/style.css +++ b/style.css @@ -45,8 +45,6 @@ @import './src/ui/styles/rtl.css'; @import './src/ui/styles/mobile-shell.css'; @import './src/ui/styles/annotations.css'; -@import './src/ui/styles/credits.css'; -@import './src/ui/styles/shell-spacing.css'; @import './src/ui/styles/rail-edge.css'; @import './src/ui/styles/rail-split.css'; @import './src/ui/styles/left-tools.css'; From 235fe94a896a5be0864ad771fee42964f451c2f7 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Sat, 14 Nov 2026 13:36:12 -0800 Subject: [PATCH 22/30] Open Visual from the left stack in the phone's More sheet Co-authored-by: Manjunath Paparaju --- src/ui/mobileShell.js | 3 ++- src/ui/mobileShell.test.mjs | 2 +- src/ui/styles/mobile-shell.css | 6 ++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/ui/mobileShell.js b/src/ui/mobileShell.js index 65673cd55..7570e2d17 100644 --- a/src/ui/mobileShell.js +++ b/src/ui/mobileShell.js @@ -368,7 +368,8 @@ export function initMobileShell({ : sheet === 'search' ? [dock] : sheet === 'more' - ? [element('right-context-rail'), dock] + ? // Visual lives in the left stack; the dock holds the presets. + [element('left-panel-stack'), dock] : [element('right-context-rail')]; return roots.find((root) => root?.contains(target)); }; diff --git a/src/ui/mobileShell.test.mjs b/src/ui/mobileShell.test.mjs index c0e0b909f..337fde99b 100644 --- a/src/ui/mobileShell.test.mjs +++ b/src/ui/mobileShell.test.mjs @@ -623,7 +623,7 @@ test('the phone shell keeps the required attribution visible', () => { ); const openDock = rule('body.mobile-shell[data-mobile-sheet] #command-dock'); const railSheet = rule( - "body.mobile-shell[data-mobile-sheet='more'] #right-context-rail", + "body.mobile-shell[data-mobile-sheet='more'] #left-panel-stack", ); assert.ok(z(sheetCredit) > z(openDock)); assert.ok(z(sheetCredit) > z(railSheet)); diff --git a/src/ui/styles/mobile-shell.css b/src/ui/styles/mobile-shell.css index 593e10a07..b6e7875f8 100644 --- a/src/ui/styles/mobile-shell.css +++ b/src/ui/styles/mobile-shell.css @@ -129,7 +129,9 @@ body.mobile-shell #right-context-rail { body.mobile-shell[data-mobile-sheet='layers'] #left-panel-stack, body.mobile-shell[data-mobile-sheet='cameras'] #right-context-rail, body.mobile-shell[data-mobile-sheet='context'] #right-context-rail, -body.mobile-shell[data-mobile-sheet='more'] #right-context-rail { +/* Visual opens from the left rail on wider screens, so it lives in the left + stack and the More sheet is that stack showing Visual alone. */ +body.mobile-shell[data-mobile-sheet='more'] #left-panel-stack { position: fixed; top: auto; right: 0; @@ -189,7 +191,7 @@ body.mobile-shell[data-mobile-sheet='context'] body.mobile-shell[data-mobile-sheet='context'] #right-context-rail > #recent-imagery-panel:not([hidden]), -body.mobile-shell[data-mobile-sheet='more'] #right-context-rail > #pp-toggles { +body.mobile-shell[data-mobile-sheet='more'] #left-panel-stack > #pp-toggles { position: relative; inset: auto; display: block; From 9374e0228b308d40913eb772b236a1316ac27429 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Sat, 14 Nov 2026 13:36:12 -0800 Subject: [PATCH 23/30] Leave the wheel alone where edge scrolling should not take it Hidden rails (clean view, recording), sideways or empty moves, dialogs and the world timeline keep their wheel; coasting after a step is swallowed for at most 800 ms; line-based wheels step a panel per notch; the strip follows where each rail is in a right-to-left language; a held step is dropped when the pointer leaves the strip; nothing runs after removal. Co-authored-by: Manjunath Paparaju --- src/ui/railEdgeScroll.js | 127 +++++++++++++++++++---- src/ui/railEdgeScroll.test.mjs | 177 +++++++++++++++++++++++++++++++++ 2 files changed, 282 insertions(+), 22 deletions(-) create mode 100644 src/ui/railEdgeScroll.test.mjs diff --git a/src/ui/railEdgeScroll.js b/src/ui/railEdgeScroll.js index de3c2e39a..4e3d9b0a4 100644 --- a/src/ui/railEdgeScroll.js +++ b/src/ui/railEdgeScroll.js @@ -26,12 +26,20 @@ const STEP_GAP_MS = 500; const NOTCH_DELTA = 100; /** The widest the strip gets, measured from the screen edge, whatever shape the rail takes. */ const STRIP_MAX = 84; +/** + * After a step, how long (ms) the rest of that gesture is still swallowed once + * the pointer has left the strip, so trackpad coasting does not go on to zoom + * the globe. Past it, the wheel belongs to whatever is under the pointer. + */ +const COAST_MAX_MS = 800; +/** Pixels per wheel line, for mice that report lines rather than pixels. */ +const LINE_PX = 16; /** * Things in the strip that keep their own pointer and wheel behaviour: any * control, and every panel in either side's stack (a panel scrolls itself). */ const OWN_CONTROLS = - 'a, button, input, select, textarea, [role="dialog"], .ui-panel, #left-panel-stack > :not(.gev-panel-rail), #right-context-rail > :not(.gev-panel-rail), #first-run-launcher, #cesium-credits'; + 'a, button, input, select, textarea, dialog, [role="dialog"], .ui-panel, #left-panel-stack > :not(.gev-panel-rail), #right-context-rail > :not(.gev-panel-rail), #first-run-launcher, #cesium-credits, #world-timeline'; /** * @param {Document} [doc] @@ -54,16 +62,40 @@ export function installRailEdgeScroll(doc = globalThis.document) { let peakSpeed = 0; let slowed = false; let frame = 0; + /** Set once removed, so frames already queued do nothing. */ + let removed = false; + // Clean view and recording hide the rails with visibility and opacity, + // which keep their boxes, so a box alone does not mean the rail shows. + const showing = (node) => + node.getBoundingClientRect().width > 0 && + (typeof node.checkVisibility !== 'function' || + node.checkVisibility({ + visibilityProperty: true, + opacityProperty: true, + })); + + // Which screen edge a rail is on comes from where it is, not its name: in a + // right-to-left language the left stack sits on the right. const rails = () => ['left', 'right'] - .map((side) => ({ side, rail: doc.querySelector(`.ui-rail--${side}`) })) - .filter(({ rail }) => rail && rail.getBoundingClientRect().width > 0); + .map((name) => doc.querySelector(`.ui-rail--${name}`)) + .filter((rail) => rail && showing(rail)) + .map((rail) => { + const box = rail.getBoundingClientRect(); + const middle = doc.documentElement.clientWidth / 2; + return { + side: box.left + box.width / 2 < middle ? 'left' : 'right', + rail, + }; + }); const items = (rail) => // Only items that show: a theme or mode may hide some, and the wheel must // not open those. - [...rail.querySelectorAll('.ui-rail__item')].filter((item) => !item.disabled && item.offsetWidth > 0); + [...rail.querySelectorAll('.ui-rail__item')].filter( + (item) => !item.disabled && showing(item), + ); // ── The sliding highlight ── // Each rail draws it as a ::before under its items, placed by custom @@ -73,6 +105,7 @@ export function installRailEdgeScroll(doc = globalThis.document) { const gliding = new WeakSet(); function glide(rail) { + if (removed) return; rail.classList.toggle('ui-rail--edge-hot', rail === hot); const on = rail.querySelector('.ui-rail__item[aria-pressed="true"]'); if (!on?.offsetWidth) { @@ -87,16 +120,30 @@ export function installRailEdgeScroll(doc = globalThis.document) { // buttons shrinking over a few frames; the highlight waits until the open // button is an icon again (square) rather than fading in at a pill's // width and then shrinking. - if (!shown && (rail.classList.contains('ui-rail--expanded') || box.width > box.height + 2)) return; + if ( + !shown && + (rail.classList.contains('ui-rail--expanded') || + box.width > box.height + 2) + ) + return; // Appearing from nothing: jump into place, then fade in. rail.classList.toggle('ui-rail--glide-jump', !shown); - rail.style.setProperty('--rail-glide-x', `${box.left - railBox.left - rail.clientLeft}px`); - rail.style.setProperty('--rail-glide-y', `${box.top - railBox.top - rail.clientTop}px`); + rail.style.setProperty( + '--rail-glide-x', + `${box.left - railBox.left - rail.clientLeft}px`, + ); + rail.style.setProperty( + '--rail-glide-y', + `${box.top - railBox.top - rail.clientTop}px`, + ); rail.style.setProperty('--rail-glide-w', `${box.width}px`); rail.style.setProperty('--rail-glide-h', `${box.height}px`); rail.classList.add('ui-rail--glide'); gliding.add(rail); - if (!shown) win.requestAnimationFrame(() => rail.classList.remove('ui-rail--glide-jump')); + if (!shown) + win.requestAnimationFrame(() => + rail.classList.remove('ui-rail--glide-jump'), + ); } // Follow the rails for a few frames after any change, as their items @@ -105,6 +152,7 @@ export function installRailEdgeScroll(doc = globalThis.document) { win.cancelAnimationFrame(frame); let left = frames; const tick = () => { + if (removed) return; watchRails(); doc.querySelectorAll('.ui-rail').forEach(glide); if ((left -= 1) > 0) frame = win.requestAnimationFrame(tick); @@ -117,7 +165,11 @@ export function installRailEdgeScroll(doc = globalThis.document) { ? new win.MutationObserver((records) => { // A rail item opened or closed. Nothing here writes aria-pressed, // and the work waits for the next frame, so this never feeds itself. - if (records.some((record) => record.target.classList?.contains('ui-rail__item'))) + if ( + records.some((record) => + record.target.classList?.contains('ui-rail__item'), + ) + ) win.requestAnimationFrame(() => follow()); }) : null; @@ -132,7 +184,9 @@ export function installRailEdgeScroll(doc = globalThis.document) { // row (panels moved to the screen edge). Its highlight is placed again // whenever its size changes, so it is never left where an icon was. const sized = - typeof win.ResizeObserver === 'function' ? new win.ResizeObserver(() => follow(2)) : null; + typeof win.ResizeObserver === 'function' + ? new win.ResizeObserver(() => follow(2)) + : null; const watched = new WeakSet(); const watchRails = () => { if (!sized) return; @@ -147,7 +201,8 @@ export function installRailEdgeScroll(doc = globalThis.document) { // ── The edge strip ── /** The rail whose strip holds the point, unless a control there owns it. */ function railAt(x, target) { - if (doc.body.classList.contains('mobile-shell') || coarse?.matches) return null; + if (doc.body.classList.contains('mobile-shell') || coarse?.matches) + return null; for (const { side, rail } of rails()) { const box = rail.getBoundingClientRect(); // From the screen edge to just past the rail, but never wider than a @@ -168,6 +223,12 @@ export function installRailEdgeScroll(doc = globalThis.document) { function setHot(rail) { if (rail === hot) return; + // A held step belongs to the strip it was made in; leaving drops it, so + // coming back later does not set it off with no wheel turned. + if (heldStep) { + win.clearTimeout(heldStep); + heldStep = 0; + } hot?.classList.remove('ui-rail--edge-hot'); hot = rail; travel = 0; @@ -186,7 +247,9 @@ export function installRailEdgeScroll(doc = globalThis.document) { function step(direction) { const list = items(hot); if (!list.length) return; - const current = list.findIndex((item) => item.getAttribute('aria-pressed') === 'true'); + const current = list.findIndex( + (item) => item.getAttribute('aria-pressed') === 'true', + ); // Past either end, carry on from the other. const nextIndex = current < 0 @@ -201,7 +264,9 @@ export function installRailEdgeScroll(doc = globalThis.document) { if (panel) { panel.classList.remove('rail-switch-down', 'rail-switch-up'); void panel.offsetWidth; - panel.classList.add(direction > 0 ? 'rail-switch-down' : 'rail-switch-up'); + panel.classList.add( + direction > 0 ? 'rail-switch-down' : 'rail-switch-up', + ); // The classes come off when the slide ends, or after a moment where // there is no slide to end (reduced motion). const settle = () => { @@ -216,17 +281,20 @@ export function installRailEdgeScroll(doc = globalThis.document) { } function onWheel(event) { - if (event.ctrlKey) return; + // Pinch zoom, and sideways or empty moves (trackpads send them mid-swipe), + // are left alone: they neither step nor turn a gesture round. + if (event.ctrlKey || !event.deltaY) return; const now = win.performance?.now?.() ?? Date.now(); const inGesture = now - lastWheel <= GESTURE_GAP_MS; // Recheck: the pointer may not have moved since the panels changed. - const stillHot = Boolean(hot) && railAt(event.clientX, event.target) === hot; + const stillHot = + Boolean(hot) && railAt(event.clientX, event.target) === hot; if (!stillHot) { setHot(null); // The rest of a gesture that has already stepped is used up here, so // its coasting does not go on to zoom the globe or scroll what opened // under the pointer. - if (stepped && inGesture) { + if (stepped && inGesture && now - steppedAt <= COAST_MAX_MS) { event.preventDefault(); event.stopPropagation(); lastWheel = now; @@ -235,15 +303,25 @@ export function installRailEdgeScroll(doc = globalThis.document) { } event.preventDefault(); event.stopPropagation(); - const speed = Math.abs(event.deltaY); + // Line- and page-based wheels report far smaller numbers than pixels. + const deltaY = + event.deltaMode === 1 + ? event.deltaY * LINE_PX + : event.deltaMode === 2 + ? event.deltaY * win.innerHeight + : event.deltaY; + const speed = Math.abs(deltaY); // A new gesture: after a pause, after turning round, a mouse wheel notch, // or a fresh flick while the last one is still coasting. A flick is a // rise in speed after the gesture has clearly slowed, and not in the // moment after a step: a swipe is still speeding up when it first steps. - const turned = travel && Math.sign(event.deltaY) !== Math.sign(travel); + const turned = travel && Math.sign(deltaY) !== Math.sign(travel); const cooled = now - steppedAt > STEP_COOLDOWN_MS; - const notch = stepped && cooled && speed >= NOTCH_DELTA; - const flick = stepped && cooled && slowed && speed > Math.max(8, lastSpeed * 1.8); + // Every event from a line- or page-based wheel is a notch. + const notch = + stepped && cooled && (speed >= NOTCH_DELTA || event.deltaMode > 0); + const flick = + stepped && cooled && slowed && speed > Math.max(8, lastSpeed * 1.8); if (!inGesture || turned || notch || flick) { // A held step belongs to the motion it came from; a reversal or a new // flick replaces it rather than queueing behind it. @@ -263,7 +341,7 @@ export function installRailEdgeScroll(doc = globalThis.document) { if (speed < peakSpeed * 0.5) slowed = true; return; } - travel += event.deltaY; + travel += deltaY; if (Math.abs(travel) < STEP_DELTA) return; stepped = true; const direction = Math.sign(travel); @@ -294,6 +372,7 @@ export function installRailEdgeScroll(doc = globalThis.document) { follow(); return () => { + removed = true; win.clearTimeout(heldStep); setHot(null); observer?.disconnect(); @@ -304,7 +383,11 @@ export function installRailEdgeScroll(doc = globalThis.document) { win.removeEventListener('wheel', onWheel, { capture: true }); win.removeEventListener('resize', onResize); doc.querySelectorAll('.ui-rail').forEach((rail) => { - rail.classList.remove('ui-rail--glide', 'ui-rail--glide-jump', 'ui-rail--edge-hot'); + rail.classList.remove( + 'ui-rail--glide', + 'ui-rail--glide-jump', + 'ui-rail--edge-hot', + ); }); }; } diff --git a/src/ui/railEdgeScroll.test.mjs b/src/ui/railEdgeScroll.test.mjs new file mode 100644 index 000000000..a16964ebe --- /dev/null +++ b/src/ui/railEdgeScroll.test.mjs @@ -0,0 +1,177 @@ +import test from 'node:test'; +import assert from 'node:assert/strict'; +import { Window } from 'happy-dom'; +import { installRailEdgeScroll } from './railEdgeScroll.js'; + +// A page with a left and a right rail of three items each, laid out by hand: +// happy-dom does no layout, so boxes and the clock are stubbed. +function page({ rtl = false } = {}) { + const window = new Window({ width: 1600, height: 900 }); + const doc = window.document; + let now = 1000; + const timers = new Map(); + let nextTimer = 1; + window.performance.now = () => now; + window.setTimeout = (fn, ms) => { + const id = nextTimer++; + timers.set(id, { fn, at: now + ms }); + return id; + }; + window.clearTimeout = (id) => timers.delete(id); + window.requestAnimationFrame = () => 0; + window.cancelAnimationFrame = () => {}; + Object.defineProperty(doc.documentElement, 'clientWidth', { value: 1600 }); + const box = (el, left, top, width, height) => { + el.getBoundingClientRect = () => ({ + left, + top, + width, + height, + right: left + width, + bottom: top + height, + }); + Object.defineProperty(el, 'offsetWidth', { get: () => width }); + }; + const clicks = []; + const rail = (name, left) => { + const el = doc.createElement('div'); + el.className = `ui-rail ui-rail--${name}`; + box(el, left, 200, 40, 120); + for (let i = 0; i < 3; i++) { + const item = doc.createElement('button'); + item.className = 'ui-rail__item'; + item.dataset.railItem = `${name}-${i}`; + item.setAttribute('aria-pressed', i === 0 ? 'true' : 'false'); + box(item, left + 4, 204 + i * 40, 32, 32); + item.addEventListener('click', () => { + clicks.push(item.dataset.railItem); + for (const other of el.children) + other.setAttribute('aria-pressed', String(other === item)); + }); + el.append(item); + } + doc.body.append(el); + return el; + }; + // In a right-to-left language the left stack's rail is on the right edge. + const left = rail('left', rtl ? 1550 : 10); + const right = rail('right', rtl ? 10 : 1550); + const remove = installRailEdgeScroll(doc); + const wheel = (x, deltaY, { deltaMode = 0, target = doc.body } = {}) => { + // happy-dom leaves clientX off these events, so it is set by hand. + const at = (event) => Object.defineProperty(event, 'clientX', { value: x }); + target.dispatchEvent( + at(new window.PointerEvent('pointermove', { bubbles: true })), + ); + const event = at( + new window.WheelEvent('wheel', { + bubbles: true, + cancelable: true, + deltaY, + deltaMode, + }), + ); + target.dispatchEvent(event); + return event; + }; + const advance = (ms) => { + now += ms; + for (const [id, timer] of [...timers]) { + if (timer.at > now) continue; + timers.delete(id); + timer.fn(); + } + }; + return { window, doc, left, right, clicks, wheel, advance, remove }; +} + +test('a wheel in the left strip steps that rail and keeps the globe from zooming', () => { + const p = page(); + const event = p.wheel(20, 120); + assert.equal(event.defaultPrevented, true); + assert.deepEqual(p.clicks, ['left-1']); + p.remove(); +}); + +test('a line-based mouse wheel steps one panel per notch', () => { + const p = page(); + p.wheel(20, 3, { deltaMode: 1 }); + p.advance(600); + p.wheel(20, 3, { deltaMode: 1 }); + assert.deepEqual(p.clicks, ['left-1', 'left-2']); + p.remove(); +}); + +test('a rail hidden by clean view or recording leaves the wheel to the globe', () => { + const p = page(); + p.left.checkVisibility = () => false; + const event = p.wheel(20, 120); + assert.equal(event.defaultPrevented, false); + assert.deepEqual(p.clicks, []); + p.remove(); +}); + +test('right to left: the wheel at each screen edge steps the rail on that edge', () => { + const p = page({ rtl: true }); + p.wheel(1580, 120); + p.advance(600); + p.wheel(20, 120); + assert.deepEqual(p.clicks, ['left-1', 'right-1']); + p.remove(); +}); + +test('after a step, the wheel goes back to the page once the coasting is over', () => { + const p = page(); + p.wheel(20, 120); + // The pointer moves off the strip while the gesture still coasts. + let event; + for (let i = 0; i < 20; i++) { + p.advance(100); + event = p.wheel(800, 30); + } + assert.equal(event.defaultPrevented, false); + assert.deepEqual(p.clicks, ['left-1']); + p.remove(); +}); + +test('a held step is dropped when the pointer leaves the strip, even if it comes back', () => { + const p = page(); + p.wheel(20, 120); + p.advance(250); + p.wheel(20, -120); // turns round: a second step, held for the gap + p.wheel(800, 0); // leaves the strip + p.wheel(20, 0); // and returns before the gap ends + p.advance(600); + assert.deepEqual(p.clicks, ['left-1']); + p.remove(); +}); + +test('removing it stops edge scrolling', () => { + const p = page(); + p.remove(); + const event = p.wheel(20, 120); + assert.equal(event.defaultPrevented, false); + assert.deepEqual(p.clicks, []); +}); + +test('a sideways move mid-swipe neither turns the gesture round nor steps again', () => { + const p = page(); + p.wheel(20, 60); + p.advance(50); + const sideways = p.wheel(20, 0); + p.advance(50); + p.wheel(20, 40); // the same swipe coasting on + assert.equal(sideways.defaultPrevented, false); + assert.deepEqual(p.clicks, ['left-1']); + p.remove(); +}); + +test('an open dialog near the edge keeps its own wheel', () => { + const p = page(); + const dialog = p.doc.createElement('dialog'); + p.doc.body.append(dialog); + const event = p.wheel(20, 120, { target: dialog }); + assert.equal(event.defaultPrevented, false); + assert.deepEqual(p.clicks, []); + p.remove(); +}); From d0b614d88ee5ad849d75d8ee4d9706ddff47c95a Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Sat, 14 Nov 2026 13:36:12 -0800 Subject: [PATCH 24/30] Keep edge mode to the desktop shell and mirror it in right-to-left Phones and Cockpit keep their own layouts and do not show the switch. The rails' name panels and edge mode run toward the middle in a right-to-left language, and the switch reads its side again after the layout moves it. Co-authored-by: Manjunath Paparaju --- src/ui/kit/UiPanelEdge.vue | 17 ++++++++++---- src/ui/panelEdge.js | 4 +++- src/ui/styles/panel-edge.css | 38 +++++++++++++++++++++++-------- src/ui/styles/rtl.css | 44 ++++++++++++++++++++++++++++++++++++ 4 files changed, 88 insertions(+), 15 deletions(-) diff --git a/src/ui/kit/UiPanelEdge.vue b/src/ui/kit/UiPanelEdge.vue index 5827e914f..bb1ec1f9c 100644 --- a/src/ui/kit/UiPanelEdge.vue +++ b/src/ui/kit/UiPanelEdge.vue @@ -15,10 +15,19 @@ function toggle() { function sync() { side.value = panelSide(button.value); } -onMounted(sync); -const icon = computed(() => (side.value === 'right' ? 'align_horizontal_right' : 'align_horizontal_left')); +// The layout moves some panels to the right column after they mount, so the +// side is read again once that has happened. +onMounted(() => { + sync(); + globalThis.requestAnimationFrame?.(sync); +}); +const icon = computed(() => + side.value === 'right' ? 'align_horizontal_right' : 'align_horizontal_left', +); const label = computed(() => - on.value ? t('Move panels back beside the rail') : t('Move panels over the rail, to the edge'), + on.value + ? t('Move panels back beside the rail') + : t('Move panels over the rail, to the edge'), ); @@ -26,7 +35,7 @@ const label = computed(() =>