mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-20 10:12:18 +00:00
Merge main (d49d3d10) into the renderer branch
This commit is contained in:
commit
489c316556
134 files changed
+4980
-229
No files matched your search
@@ -16,6 +16,7 @@ import {
|
||||
import {
|
||||
transitModeFor,
|
||||
transitModeResolved,
|
||||
transitModelRouteType,
|
||||
} from '../../data/transitFeeds.js';
|
||||
import {
|
||||
attachFloorToPlace,
|
||||
@@ -85,6 +86,7 @@ export function createIngestion({ state, services, parts, source }) {
|
||||
state._heightDirty.delete(entry);
|
||||
parts.rendering.cancelWake(entry);
|
||||
destroyTrack(entry.track);
|
||||
entry.placement?.forget(key);
|
||||
state._vehicles.delete(key);
|
||||
state._detectRevision += 1;
|
||||
}
|
||||
@@ -222,12 +224,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 +276,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);
|
||||
@@ -318,8 +328,12 @@ export function createIngestion({ state, services, parts, source }) {
|
||||
entry = {
|
||||
key,
|
||||
feedId: feed.id,
|
||||
// A host-supplied placement, if any, draws it while live.
|
||||
placement: services.placement ?? null,
|
||||
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,
|
||||
|
||||
@@ -98,6 +98,7 @@ export function createLifecycle({ state, services, parts }) {
|
||||
entry.detectContact = null;
|
||||
parts.rendering.cancelWake(entry);
|
||||
destroyTrack(entry.track);
|
||||
entry.placement?.forget(entry.key);
|
||||
}
|
||||
state._vehicles.clear();
|
||||
parts.height.clear();
|
||||
@@ -179,6 +180,7 @@ export function createLifecycle({ state, services, parts }) {
|
||||
entry.detectContact = null;
|
||||
parts.rendering.cancelWake(entry);
|
||||
destroyTrack(entry.track);
|
||||
entry.placement?.forget(entry.key);
|
||||
}
|
||||
state._vehicles.clear();
|
||||
parts.rendering.stopModels();
|
||||
|
||||
@@ -13,6 +13,8 @@ import {
|
||||
} from './policy.js';
|
||||
import { FLOOR_WARM_PER_POLL } from './policy.js';
|
||||
import { fleetModelFakes } from '../../testSupport/fleetModelFakes.mjs';
|
||||
import { layerPlacement } from '../../data/placementProvider.js';
|
||||
import { PLACED_WAKE_MS } from './movement.js';
|
||||
import {
|
||||
FUTURE_STAMP_TOLERANCE_MS,
|
||||
ORDER_REJECTS_BEFORE_RESET,
|
||||
@@ -229,6 +231,8 @@ function harness(
|
||||
// Fleet-model services (testSupport/fleetModelFakes.mjs), with a camera
|
||||
// looking straight down for them; without them vehicles stay icons.
|
||||
fleet = null,
|
||||
// A host-supplied placement (../../data/placementProvider.js), or none.
|
||||
placement = null,
|
||||
} = {},
|
||||
) {
|
||||
const viewRect = { ...view };
|
||||
@@ -346,6 +350,7 @@ function harness(
|
||||
source,
|
||||
services: {
|
||||
...(fleet ? { fleet } : {}),
|
||||
...(placement ? { placement: layerPlacement(placement, 'transit') } : {}),
|
||||
ground,
|
||||
mesh: {
|
||||
sampleMeshFloorCells(scene, points, options) {
|
||||
@@ -1329,6 +1334,110 @@ test('a parked fleet that keeps reporting the same position stops asking for fra
|
||||
'only the vehicle that actually moved is animating',
|
||||
);
|
||||
});
|
||||
test('a vehicle a placement holds still stops asking for frames, and moves on when the placement does', async (t) => {
|
||||
// The placement parks bus-1 at a terminal until `spot` moves.
|
||||
let spot = { lat: 42.3605, lon: -71.0605 };
|
||||
let asked = 0;
|
||||
const app = harness(t, {
|
||||
placement: {
|
||||
layer: () => ({
|
||||
place: () => {
|
||||
asked += 1;
|
||||
return { ...spot, courseDeg: 0, speedMps: 0 };
|
||||
},
|
||||
}),
|
||||
},
|
||||
});
|
||||
app.serve('mbta', () => ({
|
||||
status: 200,
|
||||
body: snapshot(
|
||||
'mbta',
|
||||
'MBTA',
|
||||
[vehicle('bus-1', 42.36, -71.06, reported())],
|
||||
{ fetchedAt: Date.now() },
|
||||
),
|
||||
}));
|
||||
app.layer.enable(app.viewer);
|
||||
await app.layer.update();
|
||||
app.settle();
|
||||
const entry = app.vehicles()[0];
|
||||
assert.equal(entry.placed, true);
|
||||
for (let i = 0; i < 3; i += 1) {
|
||||
app.advance(16);
|
||||
app.frame();
|
||||
}
|
||||
assert.equal(app.state()._moving.has(entry), false, 'parked: not animating');
|
||||
assert.equal(app.holds().includes('transit'), false, 'and the loop idles');
|
||||
assert.notEqual(entry.wakeTimer, null, 'a wake asks the placement again');
|
||||
assert.ok(Math.abs(lat(entry) - 42.3605) < 1e-6, 'drawn where placed');
|
||||
|
||||
// Asked again while it stays put: still idle, the wake re-armed.
|
||||
const before = asked;
|
||||
app.advance(PLACED_WAKE_MS);
|
||||
assert.ok(asked > before, 'the wake asked the placement');
|
||||
assert.equal(app.state()._moving.has(entry), false);
|
||||
assert.equal(app.holds().includes('transit'), false);
|
||||
|
||||
// The placement moves it: the next wake picks that up and the loop runs.
|
||||
spot = { lat: 42.361, lon: -71.0605 };
|
||||
app.advance(PLACED_WAKE_MS);
|
||||
assert.equal(app.state()._moving.has(entry), true, 'moving again');
|
||||
assert.ok(app.holds().includes('transit'), 'and holds the loop');
|
||||
assert.ok(Math.abs(lat(entry) - 42.361) < 1e-6);
|
||||
for (let i = 0; i < 3; i += 1) {
|
||||
spot = { lat: spot.lat + 1e-5, lon: spot.lon };
|
||||
app.advance(16);
|
||||
app.frame();
|
||||
assert.equal(app.state()._moving.has(entry), true, 'while it moves');
|
||||
}
|
||||
|
||||
// It stops again: the next frame that sees it unchanged lets go.
|
||||
app.advance(16);
|
||||
app.frame();
|
||||
assert.equal(app.state()._moving.has(entry), false, 'stopped again');
|
||||
assert.equal(app.holds().includes('transit'), false);
|
||||
});
|
||||
|
||||
test('a vehicle a placement draws is shown from a high camera, as one it does not', async (t) => {
|
||||
// Far above the ground no floor is asked for, so the fixes carry no height
|
||||
// and the vehicle stands on the ellipsoid, placed or not.
|
||||
const app = harness(t, {
|
||||
at: { lat: 52.09, lon: 5.12 },
|
||||
altitude: 1_500_000,
|
||||
view: { west: -78.084, south: 20, east: 88.084, north: 84 },
|
||||
placement: {
|
||||
layer: () => ({
|
||||
place: (id) =>
|
||||
id.endsWith('nl-1')
|
||||
? { lat: 52.091, lon: 5.12, courseDeg: 0, speedMps: 0 }
|
||||
: null,
|
||||
}),
|
||||
},
|
||||
});
|
||||
const now = Date.now();
|
||||
app.serve('ovapi-nl', () => ({
|
||||
status: 200,
|
||||
body: snapshot(
|
||||
'ovapi-nl',
|
||||
'OVapi',
|
||||
[
|
||||
vehicle('nl-1', 52.09, 5.12, now / 1000),
|
||||
vehicle('nl-2', 51.92, 4.48, now / 1000),
|
||||
],
|
||||
{ fetchedAt: Date.now() },
|
||||
),
|
||||
}));
|
||||
app.layer.enable(app.viewer);
|
||||
await app.layer.update();
|
||||
app.advance(250);
|
||||
app.frame();
|
||||
const placed = app.vehicles().find((entry) => entry.placed === true);
|
||||
assert.ok(placed, 'one vehicle is placed');
|
||||
const shown = app.vehicles().filter((entry) => entry.marker?.show !== false);
|
||||
assert.equal(shown.length, 2, 'both vehicles are drawn');
|
||||
assert.ok(Math.abs(lat(placed) - 52.091) < 1e-6, 'where placed');
|
||||
});
|
||||
|
||||
test('the last vehicle leaving mid-segment takes the render hold with it', async (t) => {
|
||||
const app = harness(t);
|
||||
const fetchedAt = Date.now();
|
||||
|
||||
@@ -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
|
||||
});
|
||||
@@ -181,13 +186,57 @@ export function recordFix(entry, fix, observation = {}) {
|
||||
);
|
||||
entry.currentEpoch = latest.epoch;
|
||||
if (context) entry.track.epochs.set(latest.epoch, context);
|
||||
entry.placement?.observe(entry.key, {
|
||||
timeMs: fix.t,
|
||||
lat: fix.lat,
|
||||
lon: fix.lon,
|
||||
altitudeM: NaN,
|
||||
speedMps: NaN,
|
||||
courseDeg: Number.isFinite(fix.bearingDeg) ? fix.bearingDeg : NaN,
|
||||
headingDeg: NaN,
|
||||
feedId: entry.feedId,
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* How often a vehicle a host-supplied placement holds still is asked again
|
||||
* whether it moves, so it resumes without the frame loop running for it.
|
||||
*/
|
||||
export const PLACED_WAKE_MS = 1000;
|
||||
|
||||
/**
|
||||
* Advance a vehicle's playback to now. With a host-supplied placement
|
||||
* (`entry.placement`, ../../data/placementProvider.js) that places it, it is
|
||||
* drawn there, its course and speed the placement's (`entry.placed`); the
|
||||
* playback's own phase, motion and segment stand. `entry.placedMoving` says
|
||||
* whether the placed position changed since the placement was last asked at
|
||||
* an earlier time (true for its first answer, so one more frame can tell).
|
||||
*/
|
||||
export function updatePlayback(entry, wallNowMs, monoNowMs) {
|
||||
entry.clocks.wallNowMs = wallNowMs;
|
||||
entry.clocks.monoNowMs = monoNowMs;
|
||||
advance(entry.track, entry.clocks, entry.sample);
|
||||
const placed = entry.placement?.place(entry.key, wallNowMs) ?? null;
|
||||
const wasPlaced = entry.placed === true;
|
||||
entry.placed = placed !== null;
|
||||
if (!placed) entry.placedMoving = false;
|
||||
else if (!wasPlaced) entry.placedMoving = true;
|
||||
else if (wallNowMs !== entry.placedAtWallMs)
|
||||
entry.placedMoving =
|
||||
placed.lat !== entry.placedLat || placed.lon !== entry.placedLon;
|
||||
if (placed) {
|
||||
entry.placedLat = placed.lat;
|
||||
entry.placedLon = placed.lon;
|
||||
entry.placedAtWallMs = wallNowMs;
|
||||
const sample = entry.sample;
|
||||
sample.lat = placed.lat;
|
||||
sample.lon = placed.lon;
|
||||
if (Number.isFinite(placed.courseDeg))
|
||||
sample.segmentCourseDeg = placed.courseDeg;
|
||||
if (Number.isFinite(placed.speedMps))
|
||||
sample.segmentSpeedMps = placed.speedMps;
|
||||
}
|
||||
entry.resets = entry.track.resets;
|
||||
const segment = entry.segment;
|
||||
readFix(
|
||||
@@ -212,6 +261,16 @@ export function syncPlayback(entry, wallNowMs, monoNowMs = performance.now()) {
|
||||
}
|
||||
updatePlayback(entry, wallNowMs, monoNowMs);
|
||||
}
|
||||
/**
|
||||
* Whether a vehicle's drawn position changes on its own: a vehicle a
|
||||
* host-supplied placement draws moves while that placement's position
|
||||
* changes; any other while its playback glides along a segment.
|
||||
*/
|
||||
export function playbackMoving(entry) {
|
||||
if (entry.placed === true) return entry.placedMoving === true;
|
||||
const sample = entry.sample;
|
||||
return sample?.phase === 'playing' && sample.segmentSpeedMps > 0;
|
||||
}
|
||||
export function playbackPosition(entry) {
|
||||
if (!entry?.track) return null;
|
||||
return {
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
} from './movement.js';
|
||||
import { buildTransitSelectionCopy } from './policy.js';
|
||||
import { sampleAt } from '../../data/contactPlayback.js';
|
||||
import { layerPlacement } from '../../data/placementProvider.js';
|
||||
const entry = () => {
|
||||
const e = { mode: 'bus', modeInferred: false, courseDeg: null };
|
||||
initializePlayback(e);
|
||||
@@ -163,3 +164,101 @@ test('course fallback prefers held course, then finite reported bearing, then un
|
||||
assert.equal(e.courseDeg, expected);
|
||||
}
|
||||
});
|
||||
|
||||
const placedEntry = (placement) => {
|
||||
const e = {
|
||||
key: 'feed:7',
|
||||
feedId: 'feed',
|
||||
mode: 'bus',
|
||||
modeInferred: false,
|
||||
courseDeg: null,
|
||||
placement,
|
||||
};
|
||||
initializePlayback(e);
|
||||
return e;
|
||||
};
|
||||
const drive = (e) => {
|
||||
recordFix(e, { ...fix(0), bearingDeg: 10 });
|
||||
recordFix(e, { ...fix(15000, 42.001), bearingDeg: 20 });
|
||||
recordFix(e, fix(30000, 42.002));
|
||||
const samples = [];
|
||||
for (let wall = 0; wall <= 120000; wall += 2500) {
|
||||
updatePlayback(e, wall, wall);
|
||||
samples.push({ ...e.sample });
|
||||
}
|
||||
return samples;
|
||||
};
|
||||
test('without a placement, or one that places nothing, playback is the layer own', () => {
|
||||
const own = drive(placedEntry(null));
|
||||
const declined = [];
|
||||
const placement = layerPlacement(
|
||||
{
|
||||
layer: () => ({
|
||||
observe: (id, f) => declined.push([id, f.timeMs]),
|
||||
place: () => null,
|
||||
}),
|
||||
},
|
||||
'transit',
|
||||
);
|
||||
const e = placedEntry(placement);
|
||||
assert.deepEqual(drive(e), own);
|
||||
assert.equal(e.placed, false);
|
||||
assert.deepEqual(declined, [
|
||||
['feed:7', 0],
|
||||
['feed:7', 15000],
|
||||
['feed:7', 30000],
|
||||
]);
|
||||
});
|
||||
test('a placement draws the vehicle where it places it, keeping the playback state', () => {
|
||||
const own = drive(placedEntry(null));
|
||||
const e = placedEntry(
|
||||
layerPlacement(
|
||||
{
|
||||
layer: () => ({
|
||||
place: (id, wallMs) =>
|
||||
wallMs >= 60000
|
||||
? { lat: 1, lon: 2, courseDeg: 45, speedMps: 7 }
|
||||
: { lat: 3, lon: 4 },
|
||||
}),
|
||||
},
|
||||
'transit',
|
||||
),
|
||||
);
|
||||
const placed = drive(e);
|
||||
assert.equal(e.placed, true);
|
||||
for (let i = 0; i < own.length; i++) {
|
||||
const late = i * 2500 >= 60000;
|
||||
assert.equal(placed[i].lat, late ? 1 : 3);
|
||||
assert.equal(placed[i].lon, late ? 2 : 4);
|
||||
assert.equal(placed[i].phase, own[i].phase);
|
||||
assert.equal(placed[i].motion, own[i].motion);
|
||||
if (late) {
|
||||
assert.equal(placed[i].segmentCourseDeg, 45);
|
||||
assert.equal(placed[i].segmentSpeedMps, 7);
|
||||
} else {
|
||||
// No course or speed placed: the playback's own stand.
|
||||
assert.deepEqual(
|
||||
[placed[i].segmentCourseDeg, placed[i].segmentSpeedMps],
|
||||
[own[i].segmentCourseDeg, own[i].segmentSpeedMps],
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
test('a refused fix is never told to the placement', () => {
|
||||
const told = [];
|
||||
const e = placedEntry(
|
||||
layerPlacement(
|
||||
{
|
||||
layer: () => ({
|
||||
observe: (id, f) => told.push(f.lat),
|
||||
place: () => null,
|
||||
}),
|
||||
},
|
||||
'transit',
|
||||
),
|
||||
);
|
||||
recordFix(e, fix(0));
|
||||
recordFix(e, fix(15000, 42.001));
|
||||
assert.equal(recordFix(e, fix(30000, 43)).accepted, false);
|
||||
assert.deepEqual(told, [42, 42.001]);
|
||||
});
|
||||
@@ -188,9 +188,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',
|
||||
});
|
||||
@@ -525,9 +530,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'),
|
||||
});
|
||||
@@ -535,9 +545,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',
|
||||
});
|
||||
|
||||
@@ -12,8 +12,10 @@ import { fromDegreesInto } from '../../geo/ellipsoid.js';
|
||||
import { frustumPlanes } from '../../geo/frustum.js';
|
||||
import { perspectiveCourseRotation } from '../../data/screenRotation.js';
|
||||
import {
|
||||
PLACED_WAKE_MS,
|
||||
updatePlayback,
|
||||
applyDisplayCourse,
|
||||
playbackMoving,
|
||||
syncPlayback,
|
||||
} from './movement.js';
|
||||
import {
|
||||
@@ -535,7 +537,7 @@ export function createRendering({ state, services, parts }) {
|
||||
migrateMarker(entry, false);
|
||||
return;
|
||||
}
|
||||
const positional = sample.phase === 'playing' && sample.segmentSpeedMps > 0;
|
||||
const positional = playbackMoving(entry);
|
||||
const turning =
|
||||
Number.isFinite(sample.segmentCourseDeg) &&
|
||||
Number.isFinite(entry.courseDeg) &&
|
||||
@@ -548,7 +550,19 @@ export function createRendering({ state, services, parts }) {
|
||||
} else {
|
||||
state._moving.delete(entry);
|
||||
migrateMarker(entry, false);
|
||||
if (Number.isFinite(sample.nextWakeMonoMs)) {
|
||||
// A vehicle a host-supplied placement holds still is asked again every
|
||||
// PLACED_WAKE_MS: it moves on once the placement does.
|
||||
const monoNow = performance.now();
|
||||
const placedWake = entry.placed === true;
|
||||
const boundary = sample.nextWakeMonoMs;
|
||||
const wakeMonoMs = placedWake
|
||||
? Math.min(
|
||||
Number.isFinite(boundary) ? boundary : Infinity,
|
||||
monoNow + PLACED_WAKE_MS,
|
||||
)
|
||||
: boundary;
|
||||
if (Number.isFinite(wakeMonoMs)) {
|
||||
const atBoundary = !placedWake || boundary <= wakeMonoMs;
|
||||
entry.wakeTimer = setTimeout(
|
||||
() => {
|
||||
entry.wakeTimer = null;
|
||||
@@ -558,9 +572,10 @@ export function createRendering({ state, services, parts }) {
|
||||
schedulePlayback(entry);
|
||||
flushMarkers();
|
||||
syncRenderHold();
|
||||
governorRequestRender('transit-motion-boundary');
|
||||
if (atBoundary || state._moving.has(entry))
|
||||
governorRequestRender('transit-motion-boundary');
|
||||
},
|
||||
Math.max(1, sample.nextWakeMonoMs - performance.now()),
|
||||
Math.max(1, wakeMonoMs - monoNow),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -836,7 +851,8 @@ export function createRendering({ state, services, parts }) {
|
||||
if (
|
||||
!entry.surfaceReady ||
|
||||
entry.sample.phase !== 'playing' ||
|
||||
entry.sample.segmentSpeedMps === 0
|
||||
entry.sample.segmentSpeedMps === 0 ||
|
||||
(entry.placed === true && entry.placedMoving !== true)
|
||||
)
|
||||
schedulePlayback(entry);
|
||||
if (!state._moving.has(entry)) settleSelectedCard(entry);
|
||||
@@ -939,9 +955,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 =
|
||||
TRANSIT_MODE_COLORS[entry.mode] || TRANSIT_MODE_COLORS.unknown;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { getRegisteredTransitFeed } from '../../data/transitFeeds.js';
|
||||
import { fromDegrees } from '../../geo/ellipsoid.js';
|
||||
import { fromDegrees, fromDegreesInto } from '../../geo/ellipsoid.js';
|
||||
import {
|
||||
readFix,
|
||||
correctHeight,
|
||||
@@ -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) {
|
||||
@@ -200,6 +193,18 @@ export function createTrails({ state, services, parts, source }) {
|
||||
nearGround = parts.height.nearGround(),
|
||||
) {
|
||||
pruneMarkerPaths(entry, sample);
|
||||
// Placed by a host-supplied placement, it is drawn at the placed point,
|
||||
// at the height its own playback has reached; far above the ground, where
|
||||
// no floor is asked for, on the ellipsoid as an unplaced vehicle is.
|
||||
if (entry.placed === true) {
|
||||
const heightM = Number.isFinite(sample.heightM)
|
||||
? sample.heightM
|
||||
: nearGround
|
||||
? NaN
|
||||
: 0;
|
||||
if (!Number.isFinite(heightM)) return null;
|
||||
return fromDegreesInto(sample.lon, sample.lat, heightM, out);
|
||||
}
|
||||
if (!nearGround) {
|
||||
const a = entry.fromCart,
|
||||
b = entry.toCart,
|
||||
|
||||
Reference in new issue
Block a user