mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-15 07:42:23 +00:00
test(bikeshare): check PBSC activation from real station coordinates
Assert through computeInRangeCities that a camera over each system's outermost live-feed station activates it, including both Kona and Hilo for HIBike, and that HIBike stays off over Honolulu. Drop Pennsylvania from the changelog: Philadelphia's Indego is already registered.
This commit is contained in:
1 parent
a4d6181fb9
commit
afa9e763f2
2 files changed
+57
-11
No files matched your search
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
- Add Detroit (MoGo), Pittsburgh (POGOH), Aspen (WE-cycle) and Kona & Hilo
|
- Add Detroit (MoGo), Pittsburgh (POGOH), Aspen (WE-cycle) and Kona & Hilo
|
||||||
(HIBike) to the GBFS bikeshare registry, the layer's first stations in
|
(HIBike) to the GBFS bikeshare registry, the layer's first stations in
|
||||||
Michigan and Pennsylvania.
|
Michigan.
|
||||||
|
|
||||||
- Treat explicitly current, complete empty vessel coverage as a successful update,
|
- Treat explicitly current, complete empty vessel coverage as a successful update,
|
||||||
clearing obsolete contacts while retaining stale or incomplete snapshots.
|
clearing obsolete contacts while retaining stale or incomplete snapshots.
|
||||||
|
|||||||
@@ -1,19 +1,48 @@
|
|||||||
import assert from 'node:assert/strict';
|
import assert from 'node:assert/strict';
|
||||||
import test from 'node:test';
|
import test from 'node:test';
|
||||||
import { CITY_BY_ID } from './registry.js';
|
import { CITY_BY_ID } from './registry.js';
|
||||||
|
import { createModel } from './model.js';
|
||||||
|
import { createViewport } from './viewport.js';
|
||||||
import { isAllowedGbfsHost, isAllowedGbfsPath } from '../../data/gbfsSource.js';
|
import { isAllowedGbfsHost, isAllowedGbfsPath } from '../../data/gbfsSource.js';
|
||||||
import { CITY_RANGE_BASE_KM } from './policy.js';
|
|
||||||
|
|
||||||
// Each city's PBSC host, and its farthest station from the registered centre
|
// Each city's PBSC host, and the stations farthest from its registered centre
|
||||||
// as measured against the live feed (km), so a camera over any part of the
|
// in the live feed (checked 2026-10-13). HIBike's centre sits between its two
|
||||||
// system activates it.
|
// towns, so it lists the outermost station in each.
|
||||||
const CITIES = {
|
const CITIES = {
|
||||||
'detroit-mogo': { host: 'detroit.publicbikesystem.net', provider: 'MoGo', farthestKm: 22.4 },
|
'detroit-mogo': {
|
||||||
'pittsburgh-pogoh': { host: 'pittsburgh.publicbikesystem.net', provider: 'POGOH', farthestKm: 9.1 },
|
host: 'detroit.publicbikesystem.net',
|
||||||
'aspen-we-cycle': { host: 'aspen.publicbikesystem.net', provider: 'WE-cycle', farthestKm: 42.6 },
|
provider: 'MoGo',
|
||||||
'hawaii-island-hibike': { host: 'kona.publicbikesystem.net', provider: 'HIBike', farthestKm: 53.8 },
|
stations: [{ name: 'Robina Ave & W Twelve Mile Rd', lat: 42.50288, lon: -83.18921 }],
|
||||||
|
},
|
||||||
|
'pittsburgh-pogoh': {
|
||||||
|
host: 'pittsburgh.publicbikesystem.net',
|
||||||
|
provider: 'POGOH',
|
||||||
|
stations: [{ name: 'Wilkinsburg Park & Ride', lat: 40.446951, lon: -79.888593 }],
|
||||||
|
},
|
||||||
|
'aspen-we-cycle': {
|
||||||
|
host: 'aspen.publicbikesystem.net',
|
||||||
|
provider: 'WE-cycle',
|
||||||
|
stations: [{ name: 'Cowen Dr | Hwy 133', lat: 39.413115, lon: -107.220634 }],
|
||||||
|
},
|
||||||
|
'hawaii-island-hibike': {
|
||||||
|
host: 'kona.publicbikesystem.net',
|
||||||
|
provider: 'HIBike',
|
||||||
|
stations: [
|
||||||
|
{ name: 'Kona Community Center', lat: 19.642932, lon: -156.004962 },
|
||||||
|
{ name: 'Kealoha Beach Park, Hilo', lat: 19.733317, lon: -155.029202 },
|
||||||
|
],
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// The production range check, with no viewer or fetches behind it.
|
||||||
|
const parts = { model: createModel({ state: {}, services: {}, parts: {}, source: null }) };
|
||||||
|
const { computeInRangeCities } = createViewport({
|
||||||
|
state: {},
|
||||||
|
services: { render: { governorRequestRender() {} } },
|
||||||
|
parts,
|
||||||
|
source: null,
|
||||||
|
});
|
||||||
|
|
||||||
test('the added US PBSC systems are registered and readable through the proxy', () => {
|
test('the added US PBSC systems are registered and readable through the proxy', () => {
|
||||||
for (const [id, expected] of Object.entries(CITIES)) {
|
for (const [id, expected] of Object.entries(CITIES)) {
|
||||||
const city = CITY_BY_ID.get(id);
|
const city = CITY_BY_ID.get(id);
|
||||||
@@ -25,7 +54,24 @@ test('the added US PBSC systems are registered and readable through the proxy',
|
|||||||
assert.ok(isAllowedGbfsHost(url.hostname), `${id} host ${url.hostname}`);
|
assert.ok(isAllowedGbfsHost(url.hostname), `${id} host ${url.hostname}`);
|
||||||
assert.ok(isAllowedGbfsPath(url.pathname), `${id} path ${url.pathname}`);
|
assert.ok(isAllowedGbfsPath(url.pathname), `${id} path ${url.pathname}`);
|
||||||
}
|
}
|
||||||
const radius = Math.max(CITY_RANGE_BASE_KM, city.loadRadiusKm);
|
|
||||||
assert.ok(radius > expected.farthestKm, `${id} radius ${radius} covers its farthest station`);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('a camera over each outermost station activates its system', () => {
|
||||||
|
for (const [id, expected] of Object.entries(CITIES)) {
|
||||||
|
for (const station of expected.stations) {
|
||||||
|
assert.ok(
|
||||||
|
computeInRangeCities({ lat: station.lat, lon: station.lon }).has(id),
|
||||||
|
`${station.name} activates ${id}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test('HIBike stays inactive away from Hawaii Island', () => {
|
||||||
|
// Honolulu is about 270 km from the HIBike centre.
|
||||||
|
assert.equal(
|
||||||
|
computeInRangeCities({ lat: 21.3069, lon: -157.8583 }).has('hawaii-island-hibike'),
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
});
|
||||||
Reference in new issue
Block a user