Merge remote-tracking branch 'origin/pr1228' into codex/cctv-shared-batch-20261019

This commit is contained in:
Said committed 2026-10-19 22:50:20 +01:00
commit 4416a491d2
2 files changed
+95 -26

No files matched your search

+12 -7
View File
@@ -524,6 +524,11 @@ function pickOntarioCctvView(views) {
let ontarioKeyMissingLogged = false;
/** Test seam: let the next keyless call log the missing-key line again. */
export function _resetOntarioKeyWarningForTest() {
ontarioKeyMissingLogged = false;
}
/**
* Fetch Ontario 511 CCTV cameras. The camera list comes from the 511 API,
* which now requires a free developer key (511on.ca/developers/doc, "Requires a
@@ -534,7 +539,7 @@ let ontarioKeyMissingLogged = false;
* view are kept.
*
* @param {object} [_options] The catalog's loader options (unused).
* @param {object} [env] Environment to read the key from.
* @param {object} [env] Environment to read the key and the source cap from.
* @returns {Promise<Array<object>>} Normalized camera source objects.
*/
export async function loadOntarioSourcesFromOpenData(
@@ -560,12 +565,12 @@ export async function loadOntarioSourcesFromOpenData(
});
if (!resp.ok) {
// The API answers 400 "Invalid Key" to a wrong or revoked key.
console.warn(
'[CCTV] Ontario 511 camera download failed:',
resp.status,
const keyHint =
resp.status === 400 || resp.status === 401 || resp.status === 403
? '(check ONTARIO_511_API_KEY)'
: '',
? ' (check ONTARIO_511_API_KEY)'
: '';
console.warn(
`[CCTV] Ontario 511 camera download failed: ${resp.status}${keyHint}`,
);
return [];
}
@@ -629,7 +634,7 @@ export async function loadOntarioSourcesFromOpenData(
new Map(cameras.map((camera) => [camera.id, camera])).values(),
);
const maxRaw = Number(
process.env.CCTV_ONTARIO_MAX_SOURCES || DEFAULT_ONTARIO_MAX_SOURCES,
env.CCTV_ONTARIO_MAX_SOURCES || DEFAULT_ONTARIO_MAX_SOURCES,
);
const maxCount = Number.isFinite(maxRaw)
? Math.max(8, Math.min(1000, Math.floor(maxRaw)))