mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
fix(transit): read Rio speeds as the m/s SMTR publishes
Both SMTR feeds now publish Position.speed in m/s. Compared with how far vehicles moved between reports on 2026-11-05, the published values ran 3.1x (buses) and 3.6x (BRT) below the observed speed, so the km/h conversion divided real speeds by 3.6. Drop speedUnit and the conversion.
This commit is contained in:
1 parent
e5dd7c71ac
commit
a67c7969fd
7 files changed
+14
-58
No files matched your search
@@ -285,29 +285,14 @@ test('the snapshot builder fills timestamps from the header it decoded', () => {
|
||||
assert.equal(snapshot.feedTimestamp, 1_700_000_000);
|
||||
});
|
||||
|
||||
test('a feed that publishes km/h has its speeds converted to m/s, and only that feed', () => {
|
||||
// Rio's SMTR feeds put km/h in Position.speed; read as m/s, a 36 km/h bus
|
||||
// would be reported at 130 km/h.
|
||||
test('Rio speeds pass through as the m/s they are published in', () => {
|
||||
// SMTR publishes m/s, as the spec requires: checked against how far
|
||||
// vehicles moved between reports on 2026-11-05.
|
||||
const bytes = encodeFeed({
|
||||
entities: [
|
||||
{ id: 'moving', lat: -22.9, lon: -43.2, speed: 36 },
|
||||
{ id: 'still', lat: -22.9, lon: -43.2, speed: 0 },
|
||||
{ id: 'silent', lat: -22.9, lon: -43.2 },
|
||||
],
|
||||
entities: [{ id: 'moving', lat: -22.9, lon: -43.2, speed: 10 }],
|
||||
});
|
||||
const rio = buildTransitSnapshot(getTransitFeed('smtr-rio-onibus'), bytes, 1);
|
||||
const speeds = Object.fromEntries(
|
||||
rio.vehicles.map((vehicle) => [vehicle.id, vehicle.speedMps]),
|
||||
);
|
||||
assert.ok(Math.abs(speeds.moving - 10) < 1e-6, '36 km/h is 10 m/s');
|
||||
assert.equal(speeds.still, 0);
|
||||
assert.equal(speeds.silent, null, 'an absent speed stays absent');
|
||||
const mbta = buildTransitSnapshot(getTransitFeed('mbta'), bytes, 1);
|
||||
assert.equal(
|
||||
mbta.vehicles.find((vehicle) => vehicle.id === 'moving').speedMps,
|
||||
36,
|
||||
'a spec-conforming feed is left alone',
|
||||
);
|
||||
assert.equal(rio.vehicles[0].speedMps, 10);
|
||||
});
|
||||
|
||||
test('conditional-request validators and gzip ride along with feed identification', () => {
|
||||
|
||||
Reference in new issue
Block a user