mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 17:52:21 +00:00
Rail cockpit rides: no height on an unknown floor, a standing train keeps its direction
- railHeightM is null while the train is drawn on the ellipsoid (floor quality 0) instead of -1.5 m, so a view waits for the surface. - An arc step between two reports tells which way a train runs only above 15 m, the layer's parked-train jitter (FOLLOW_MIN_MOVE_M). GPS jitter of a standing train no longer flips the direction through the playback segments, which turned a ride 180 degrees every poll. - drawDirection, a copy of direction, becomes a directionPlayed flag.
This commit is contained in:
1 parent
134138931f
commit
a7d966ae7e
4 files changed
+105
-17
No files matched your search
@@ -44,6 +44,13 @@ const PACK = Object.freeze({
|
||||
routes: { R1: [0] },
|
||||
});
|
||||
|
||||
/** A floor service that knows the ground everywhere, at 12 m. */
|
||||
const WARM_GROUND = Object.freeze({
|
||||
GROUND_FLOOR_LIFT_M: 1.5,
|
||||
cachedGroundFloor: () => 12,
|
||||
warmGroundFloor() {},
|
||||
});
|
||||
|
||||
/** Two trains on the line, T1 running east and T2 west, a step a poll. */
|
||||
async function onTheLine(t, options = {}) {
|
||||
const app = harness(t, {
|
||||
@@ -76,7 +83,7 @@ const T1 = railTrainKey('mbta-rail', 'T1');
|
||||
const T2 = railTrainKey('mbta-rail', 'T2');
|
||||
|
||||
test('the selected train reads as a snapshot of its place, motion and sources', async (t) => {
|
||||
const app = await onTheLine(t);
|
||||
const app = await onTheLine(t, { ground: WARM_GROUND });
|
||||
assert.equal(app.layer.getSelectedTrain(), null, 'nothing selected');
|
||||
app.parts().selection.selectTrain(T1);
|
||||
const view = app.layer.getSelectedTrain();
|
||||
@@ -105,6 +112,7 @@ test('the selected train reads as a snapshot of its place, motion and sources',
|
||||
assert.equal(view.provenance.positionSource, 'gps');
|
||||
assert.equal(view.provenance.timestampSource, 'vehicle');
|
||||
const drawn = app.entry(T1).drawnHeight;
|
||||
assert.ok(view.position.heightQuality > 0, 'on a known floor');
|
||||
assert.equal(view.position.railHeightM, drawn.h - 1.5);
|
||||
assert.ok(Number.isFinite(view.position.latitude));
|
||||
assert.ok(Array.isArray(view.stops));
|
||||
@@ -129,6 +137,20 @@ const stopList = (...names) =>
|
||||
state: 'upcoming',
|
||||
}));
|
||||
|
||||
test('a train drawn on an unknown floor reports no rail height', async (t) => {
|
||||
// The harness's floor service is always cold: the train is drawn on the
|
||||
// ellipsoid, which is no floor for a view to stand on.
|
||||
const app = await onTheLine(t);
|
||||
app.parts().selection.selectTrain(T1);
|
||||
const view = app.layer.getSelectedTrain();
|
||||
assert.equal(view.position.heightQuality, 0, 'no floor is known');
|
||||
assert.equal(
|
||||
view.position.railHeightM,
|
||||
null,
|
||||
'an unknown floor is no height',
|
||||
);
|
||||
});
|
||||
|
||||
test('a snapshot read again while nothing changed is the one read before', async (t) => {
|
||||
let list = stopList('Alpha', 'Bravo', 'Charlie');
|
||||
const app = await onTheLine(t, {
|
||||
|
||||
Reference in new issue
Block a user