mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 16:52:20 +00:00
feat(transit): add 55 Japanese bus networks
Keyless VehiclePositions feeds the Mobility Database records under CC0 1.0 or CC BY 4.0. Added overnight in Japan: 50 answered with an empty message, and each row says whether positions have been seen.
This commit is contained in:
1 parent
eed1f42779
commit
d4e308d905
7 files changed
+1266
-3
No files matched your search
@@ -2,6 +2,7 @@ import { greatCircleKm } from '../geoDistance.js';
|
||||
import { RIO_ROUTE_NAMES } from './rioRouteNames.js';
|
||||
import { CATALOGUE_TRANSIT_FEED_ROWS } from './transitFeedsCatalogue.js';
|
||||
import { FRANCE_TRANSIT_FEED_ROWS } from './transitFeedsFrance.js';
|
||||
import { JAPAN_TRANSIT_FEED_ROWS } from './transitFeedsJapan.js';
|
||||
import { FRANCE_ROUTE_NAMES } from './transitRouteNamesFrance.js';
|
||||
|
||||
/**
|
||||
@@ -15,7 +16,8 @@ import { FRANCE_ROUTE_NAMES } from './transitRouteNamesFrance.js';
|
||||
* a DATA_SOURCES.md row with its license, and a credit in dataCredits.js.
|
||||
* The French networks listed on transport.data.gouv.fr are rows of the same
|
||||
* shape in `transitFeedsFrance.js`, and feeds added from the open catalogues
|
||||
* are in `transitFeedsCatalogue.js`; both are appended to the registry below.
|
||||
* are in `transitFeedsCatalogue.js` and `transitFeedsJapan.js`; all are appended
|
||||
* to the registry below.
|
||||
*
|
||||
* Admission rules for a feed:
|
||||
* - No key, token, or registration required (identify-yourself headers are
|
||||
@@ -1645,7 +1647,7 @@ export const TRANSIT_FEED_REGISTRY = Object.freeze([
|
||||
defaultMode: 'bus',
|
||||
}),
|
||||
...FRANCE_TRANSIT_FEED_ROWS.map(franceTransitFeed),
|
||||
...CATALOGUE_TRANSIT_FEED_ROWS.map((row) =>
|
||||
...[...CATALOGUE_TRANSIT_FEED_ROWS, ...JAPAN_TRANSIT_FEED_ROWS].map((row) =>
|
||||
transitFeed({ defaultMode: 'bus', ...row }),
|
||||
),
|
||||
]);
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,69 @@
|
||||
import { readFileSync } from 'node:fs';
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import {
|
||||
TRANSIT_FEED_ID_PATTERN,
|
||||
getTransitFeed,
|
||||
publicTransitCatalog,
|
||||
transitFeedsInRange,
|
||||
} from './transitFeeds.js';
|
||||
import { JAPAN_TRANSIT_FEED_ROWS } from './transitFeedsJapan.js';
|
||||
|
||||
test('every Japanese row is a live, keyless feed under CC0 or CC BY', () => {
|
||||
const ids = new Set();
|
||||
for (const row of JAPAN_TRANSIT_FEED_ROWS) {
|
||||
assert.match(row.id, TRANSIT_FEED_ID_PATTERN);
|
||||
assert.equal(ids.has(row.id), false, `${row.id} is unique`);
|
||||
ids.add(row.id);
|
||||
assert.ok(getTransitFeed(row.id), `${row.id} is routable`);
|
||||
assert.ok(
|
||||
publicTransitCatalog().some((entry) => entry.id === row.id),
|
||||
`${row.id} is offered to the browser`,
|
||||
);
|
||||
assert.ok(['CC0 1.0', 'CC BY 4.0'].includes(row.license));
|
||||
assert.match(
|
||||
row.licenseUrl,
|
||||
/^https:\/\/mobilitydatabase\.org\/feeds\/gtfs_rt\//,
|
||||
`${row.id} links its catalogue record`,
|
||||
);
|
||||
assert.match(
|
||||
row.terms.quote,
|
||||
row.license === 'CC0 1.0'
|
||||
? /creativecommons\.org\/publicdomain\/zero\/1\.0/
|
||||
: /creativecommons\.org\/licenses\/by\/4\.0/,
|
||||
`${row.id} quotes the licence it names`,
|
||||
);
|
||||
assert.match(
|
||||
row.terms.note,
|
||||
/Vehicle positions were seen on|its positions have not been seen yet/,
|
||||
`${row.id} says whether positions were seen`,
|
||||
);
|
||||
assert.equal(new URL(row.url).protocol, 'https:');
|
||||
assert.ok(
|
||||
// Japan, Hokkaidō to Okinawa.
|
||||
row.center.lat > 24 &&
|
||||
row.center.lat < 46 &&
|
||||
row.center.lon > 122 &&
|
||||
row.center.lon < 146,
|
||||
`${row.id} is centred in Japan`,
|
||||
);
|
||||
assert.ok(
|
||||
transitFeedsInRange(row.center.lat, row.center.lon).some(
|
||||
(entry) => entry.id === row.id,
|
||||
),
|
||||
`${row.id} covers its own centre`,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test('every Japanese feed is documented with its licence', () => {
|
||||
const lines = readFileSync(
|
||||
new URL('../../DATA_SOURCES.md', import.meta.url),
|
||||
'utf8',
|
||||
).split('\n');
|
||||
for (const row of JAPAN_TRANSIT_FEED_ROWS) {
|
||||
const line = lines.find((l) => l.startsWith(`| **${row.name}** `));
|
||||
assert.ok(line, `${row.name} has a DATA_SOURCES row`);
|
||||
assert.ok(line.includes(row.license) && line.includes(row.licenseUrl));
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user