A spy satellite simulator in your browser, except the data is real. Live open source spatial intelligence on a photorealistic 3D globe.
JavaScript 3d-globecesiumflight-trackinggeospatialgeospatial-intelligencegisosintphotogrammetrysatellite-trackingspatial-intelligencewebglworldview
Merge branch 'main' into feat/cctv-toronto
Sameh Khamis7561a5ab823e
diff --cc CHANGELOG.mdindex bc81d10fa,c885e2caa..1b0c18271--- a/CHANGELOG.md+++ b/CHANGELOG.md@@@ -1,17 -1,30 +1,42 @@@# Changelog+- Add City of Toronto RESCU traffic cameras as a keyless CCTV source pack: the+ ~336 municipal cameras the Ontario 511 pack does not carry — downtown+ arterials plus the Gardiner, DVP, Allen and Lake Shore. The list is the+ City's own open data feed; frames are built from the documented+ `loc####.jpg` convention and a digits-only camera number, so the frame proxy+ is pinned to the portal origin by construction. The dataset publishes no+ camera facing — its `D1`-`D4` fields describe static 2016 comparison images,+ not the live pan-tilt-zoom frame — so headings use the shared id-hash+ fallback at low confidence and are corrected with the calibration gizmo.+ Carries the required Open Government Licence – Toronto attribution. Disable+ with `CCTV_TORONTO_ENABLED=0`.++ - Stop one retired bikeshare feed from reporting the whole layer as failed.+ City feeds are fetched independently, but failure was recorded in a single+ flag that only a successful *activation* cleared — and an already-loaded city+ never activates again. A dead feed re-entering camera range therefore latched+ LOAD FAILED permanently over a map still drawing every other city's stations.+ Failure is now tracked per city: a city that fails beside others still+ drawing marks the layer DEGRADED, polls that all fail over previously drawn+ points read STALE without advancing freshness, and LOAD FAILED is reported+ only when nothing is left to draw. A city that recovers clears its own+ failure, a failure is dropped once its city leaves range or the camera rises+ above the activation altitude, and late results from superseded requests are+ ignored.++ Repointed the three feeds whose operators had moved: Reddy Bikeshare (Buffalo)+ to Social Bicycles, Tugo (Tucson) and Trinity Metro (Fort Worth) to PBSC.+ Dropped CoGo (Columbus) and Broward B-cycle (Fort Lauderdale), whose systems+ have wound down — CoGo's feed reports no stations and last moved a bike in+ March 2025. The three repointed feeds were verified live.++ - Add Bike Share Toronto (1,069 stations) to the bikeshare registry. The system+ publishes the same PBSC GBFS v2 feeds as the Austin, Honolulu and Chattanooga+ entries, so it needs no new plumbing; a registry test now holds every city's+ feed URLs against the proxy host and path allowlists, so a city the proxy+ would refuse fails the suite instead of rendering an empty layer.+- GBFS v3 station names use English translations when available, then the firstusable translation or short name. Empty or malformed names no longer appear as`[object Object]` or interrupt station loading; legacy string names remaindiff --cc DATA_SOURCES.mdindex 47d517763,eeb5645fa..87a447c7c--- a/DATA_SOURCES.md+++ b/DATA_SOURCES.md@@@ -57,8 -60,12 +60,13 @@@ How to read this| **DriveBC** (Government of British Columbia) | CCTV camera catalog + frames, British Columbia highways | [Open Government Licence – British Columbia](https://www2.gov.bc.ca/gov/content/data/open-data/open-government-licence-bc) — attribution REQUIRED | "DriveBC. Contains information licensed under the Open Government Licence – British Columbia" || **Open Calgary** (`data.calgary.ca`) | CCTV camera catalog + frames, Calgary | [Open Government Licence – City of Calgary](https://data.calgary.ca/stories/s/Open-Calgary-Terms-of-Use/u45n-7awa) — attribution REQUIRED | "Contains information licensed under the Open Government Licence – City of Calgary" || **Statens vegvesen** (catalog `ogckart-sn1.atlas.vegvesen.no`, frames `kamera.atlas.vegvesen.no`, HLS `kamera.vegvesen.no`) | CCTV camera catalog + frames + live HLS video, Norway road cameras | [NLOD 2.0](https://data.norge.no/nlod/en/2.0) — attribution REQUIRED | "Contains data under the Norwegian licence for Open Government data (NLOD) distributed by Statens vegvesen" |+ | **NYC DOT Traffic Management Center** (`webcams.nyctmc.org`) | CCTV camera catalog + frames, New York City five boroughs | NYC DOT requires developers to sign a [data-sharing agreement](https://www.nyc.gov/html/dot/html/about/datafeeds.shtml) for the camera feed. **Off by default**; enable only under your own agreement | "NYC DOT Traffic Management Center" + NYC DOT's required application disclaimer (in the Data attribution popover) |+| **City of Toronto Open Data** (`opendata.toronto.ca`) | CCTV camera catalog + frames, Toronto city streets | [Open Government Licence – Toronto](https://www.toronto.ca/city-government/data-research-maps/open-data/open-data-licence/) — attribution REQUIRED | "Contains information licensed under the Open Government Licence – Toronto" |- | **GBFS (Lyft / BCycle)** | Bikeshare availability | Per-feed (attribution-only) | Credit the operator (e.g. Austin BCycle) + its `license_url` |+ | **GBFS (Lyft / BCycle / Social Bicycles / PBSC)** | Bikeshare availability | Per-feed (attribution-only) | Credit the operator (e.g. Austin BCycle) + its `license_url` |+ | **Bike Share Toronto** (`toronto.publicbikesystem.net`) | Bikeshare station availability, Toronto | Operator GBFS feed. No licence is published: the City's open-data package declares none and the feed has no `license_url`. Attribution is given to the operator. | "Bike Share Toronto (Toronto Parking Authority)" |+ | **Oslo / Bergen / Trondheim Bysykkel** (Urban Sharing, `gbfs.urbansharing.com`) | Bikeshare availability, Oslo, Bergen and Trondheim city bikes. Keyless GBFS; the proxy sends the `Client-Identifier` header the operators ask for | [NLOD 2.0](https://data.norge.no/nlod/en/2.0) — attribution REQUIRED ([Oslo](https://oslobysykkel.no/en/open-data/realtime), [Bergen](https://bergenbysykkel.no/en/apne-data/sanntid), [Trondheim](https://trondheimbysykkel.no/en/open-data/realtime)) | "Contains data under the Norwegian licence for Open Government data (NLOD) made available by Oslo Bysykkel, Bergen Bysykkel and Trondheim Bysykkel" |+ | **Kolumbus / Farte Bysykkel** (Entur Mobility, `api.entur.io/mobility/v2/gbfs`) | Bikeshare availability, Kolumbus Bysykkel (Stavanger/Nord-Jæren) and Farte Bysykkel (Skien/Porsgrunn). Keyless GBFS; the proxy sends the `ET-Client-Name` header Entur requires and is limited to Entur's GBFS paths | [NLOD](https://data.norge.no/nlod/en/2.0) per the [Entur Mobility API docs](https://developer.entur.org/pages-mobility-docs-mobility-v2) — attribution REQUIRED | "Contains data under the Norwegian licence for Open Government data (NLOD) made available by Entur (Kolumbus Bysykkel, Farte Bysykkel)" |+ | **JCDecaux Cyclocity** (`api.cyclocity.fr`) | Bikeshare availability, Bysykkel Lillestrøm. Keyless GBFS; the proxy is limited to JCDecaux contract paths | [Licence Ouverte / Etalab](https://developer.jcdecaux.com/files/Open-Licence-fr.pdf) (the feed's `license_url`) — attribution REQUIRED | "Bysykkel Lillestrøm: JCDecaux, Licence Ouverte" || **MBTA / MassDOT** (cdn.mbta.com) | Transit layer live vehicles and up to 15 minutes of recently observed positions, Greater Boston | MBTA / MassDOT open realtime vehicle data, used for the live view and up to fifteen minutes of recently observed positions; published for developer use and not against their use. | Attribution to MBTA / MassDOT (courtesy text) || **CapMetro** (data.texas.gov) | Transit layer live vehicles, Austin TX | CapMetro open realtime vehicle data, used for the live view; published for developer use and not against their use. | Attribution to CapMetro (courtesy text) || **Metro Transit** (Metropolitan Council) | Transit layer live vehicles, Minneapolis–St Paul | Metro Transit / Metropolitan Council open realtime vehicle data, used for the live view; published for developer use and not against their use. | Attribution to Metro Transit / Metropolitan Council (courtesy text) |@@@ -93,8 -143,7 +144,8 @@@ The optional Local ADS-B layer and the- **Live Traffic NSW cameras.** The camera list is the keyless public `data.livetraffic.com/cameras/traffic-cam.json` feed (Transport for NSW open data, CC BY 4.0); frames are stills on `webcams.transport.nsw.gov.au`, and only that host is registered. That image host answers non-browser clients with an HTML placeholder, so the proxy identifies as a browser for that one host and as itself everywhere else. Frames are fetched at request time and never stored or redistributed. Disable with `CCTV_NSW_ENABLED=0`.- **Open Calgary traffic cameras.** Keyless. The camera list is the public Socrata dataset `k7p9-kppz` on `data.calgary.ca`; frames are stills on the city's own `trafficcam.calgary.ca` host, and only that host is registered. Most rows publish an `http://` frame URL and the host redirects those to HTTPS, so URLs are upgraded and pinned to that origin before registration. Frames are fetched at request time and never stored or redistributed. The dataset publishes no camera facing: the `quadrant` field and the quadrant suffix on each camera name are Calgary's address grid, not a bearing, so headings use the shared id-hash fallback at low confidence and are corrected with the in-app calibration gizmo. The licence requires the attribution statement above. Disable with `CCTV_CALGARY_ENABLED=0`.- **Statens vegvesen road cameras.** Keyless. The camera list is one GeoJSON request to the OGC API Features view of the official DATEX 3.1 CCTV site table (`ogckart-sn1.atlas.vegvesen.no/ogc/features/v1/collections/datex_3_1:CctvSimple/items`), so no DATEX account is needed; frames are stills on `kamera.atlas.vegvesen.no/api/images/<cameraId>`, and only that exact path per camera is registered. Cameras the feed reports as faulty are dropped. About 135 working cameras also publish live HLS (`kamera.vegvesen.no/public/<cameraId>/manifest.m3u8`, MPEG-TS); those play as live video through the bounded in-memory HLS relay, with the still as the snapshot fallback, and only that exact manifest path per camera is registered. `CCTV_VEGVESEN_VIDEO=0` keeps every camera on stills. `orientationDescription` names the place a camera faces, not a bearing, so it goes into the label and headings use the id-hash fallback at low confidence. By default every live camera loads (~850); `CCTV_VEGVESEN_MAX_SOURCES` (8–1000) lowers the cap, keeping the cameras nearest Oslo, Bergen, Stavanger, Trondheim, Kristiansand, Bodø and Tromsø and `CCTV_VEGVESEN_ENABLED=0` turns the pack off. Frames are fetched at request time and never stored or redistributed. The NLOD attribution is registered in the Data attribution popover.+ - **NYC DOT Traffic Management Center cameras.** Off by default. NYC DOT's [developer data feeds page](https://www.nyc.gov/html/dot/html/about/datafeeds.shtml) asks developers who want the camera feed to contact `[email protected]` and sign a data-sharing agreement. This project does not hold one that covers downstream installations, so the pack loads only when an operator who holds their own agreement sets `CCTV_NYC_ENABLED=1`; with the flag unset, empty or any other value, the server makes no request to NYC DOT. The endpoint needs no key. The camera list is the public `webcams.nyctmc.org/api/cameras` catalog (~980 cameras across the five boroughs); frames are stills at `webcams.nyctmc.org/api/cameras/<uuid>/image`, synthesized from a validated UUID rather than taken from the payload, and only that host is registered. Cameras the feed reports as offline are dropped. The catalog publishes no camera facing, so headings use the shared id-hash fallback at low confidence and are corrected with the in-app calibration gizmo. Once enabled, the 250 cameras nearest the borough cores load; `CCTV_NYC_MAX_SOURCES` (8–400) changes the cap. Frames are fetched at request time and never stored or redistributed. NYC DOT asks every application that uses its data to carry its disclaimer; it is registered verbatim in the Data attribution popover.+- **City of Toronto RESCU cameras.** Keyless. The camera list is the City's public `tmcearthcameras.json` on `opendata.toronto.ca` (dataset "Traffic Cameras", Transportation Services), served as JSONP and unwrapped with an anchored pattern. This is the municipal network the Ontario 511 pack does not carry: downtown arterials plus the Gardiner, DVP, Allen and Lake Shore. The list publishes no frame URL, so frame URLs are BUILT from the documented `CameraImages/loc####.jpg` convention and a strictly-digits camera number, pinning the frame proxy to the portal origin by construction; the list fetch refuses redirects and bounds the body it buffers. Frames are fetched at request time and never stored or redistributed. The dataset publishes no camera facing: the `D1`-`D4` fields are the directions of the *comparison* images (static reference stills captured in 2016 under a different path), not a bearing for the live pan-tilt-zoom frame, so headings use the shared id-hash fallback at low confidence and are corrected with the in-app calibration gizmo. A camera that is temporarily out of service still answers 200 with a byte-identical "Image Unavailable" placeholder rather than an error (about 6% of the network at any moment), so such a camera reads as healthy; the frame it shows is the agency's, not a synthesized one. The licence requires the attribution statement above. Disable with `CCTV_TORONTO_ENABLED=0`.-- **Camera frame content.** Public camera frames can contain people, vehicles and license plates, and the camera layer does nothing with them beyond putting them on the map. A successful upstream response is relayed as the provider served it: nothing in the camera pipeline blurs, redacts, enhances or restores it, and nothing there runs face, plate or object detection or otherwise recognises or classifies what is in the picture. (The ALPR layer described below maps where plate-reader cameras are, from locations contributors tagged in OpenStreetMap; it reads nothing from any camera frame.) When an upstream has no frame for a camera, what you see instead is a Google Street View still or the app's own placeholder card; the panel's source badge names which of them you are looking at, and a refresh that fails after a frame has arrived leaves the last good picture on screen rather than replacing it. The browser resamples each frame for display: onto a fixed 1920x1080 surface for the camera's projection plane in the scene, and onto a 192x108 canvas for the small ambient card. That scaling is the only change made to the picture, and the only pixels the camera layer reads back are a 64x36 downscale hashed to tell whether the picture has changed. Live streams are piped through; the still path reads the image into memory to pass it on — TxDOT wraps its JPEG in a JSON envelope, which is decoded there — and no frame is written to disk (the disk cache, `.gev-cache/`, holds feed JSON for other layers and never camera imagery). Outside that pipeline, the voice assistant is the one feature that sends imagery anywhere: when it answers a question about what is in view it may attach a downscaled screenshot of the rendered scene — including any camera plane on screen — to the request it sends to the voice model. Frames are fetched only from server-registered camera URLs — a client cannot hand the proxy a URL (see [SECURITY.md](SECURITY.md)). What the app does stays inside the line README draws: no named-person search, no face recognition, no tracking individuals.- **Transit (GTFS-Realtime).** The proxy requests only registered operator feeds, validates redirects, bounds responses, and uses conditional requests, short snapshot caching and failure backoff. All seven registered regions are live-enabled; each can be disabled independently. Vehicles use delayed playback between reports, with report age and waiting states shown separately. Session-local selected trails are available for every feed. MBTA additionally retains up to 15 minutes of recently observed positions in the running proxy, so available history can survive a browser reload; server restart clears it. History reads never fetch upstream, and other feeds have no proxy retention. Nothing is archived to disk or collected in the background. Operator text credits are included as a courtesy and do not imply endorsement. Heights are aligned to work with Google 3D tiles; subway markers are shown at street level because these feeds do not supply depth.- **Radio Browser.** `/api/radio/stations` discovers official API mirrors, makes bounded and coalesced healthy/geolocated HTTPS-station queries, caches the normalized public-domain directory for 45 minutes, and may serve the last good catalog for up to seven days during an outage. Refreshes must meet minimum accepted-query and station coverage before replacing a warm catalog; schema-valid responses whose rows all fail the product's health policy do not count as successful queries. A usable partial cold catalog is explicitly `DEGRADED`, and malformed or empty successful payloads are rejected atomically. Every directory and click-count request rejects redirects, validates all resolved addresses as globally routable (including reserved/documentation IPv4 and special/non-global IPv6 exclusions), and pins the TLS connection to a validated address. Only MP3/AAC non-HLS directory rows with public HTTPS stream targets are returned; favicons are intentionally omitted. Pressing play connects one browser audio element directly to the selected broadcaster and calls the directory's click counter through known-ID-only `POST /api/radio/click/:uuid`. GEV never proxies, caches, records, bundles, or redistributes audio. Radio Browser supplies station-level tags, not dependable current-song or upcoming-program metadata, so Radio filtering never claims either. Direct playback exposes the listener's IP address to the broadcaster, whose own stream terms apply.diff --cc README.mdindex 938c7f8a2,578ccb185..5fb666162--- a/README.md+++ b/README.md@@@ -299,10 -375,11 +375,11 @@@ Twenty layers and map sources. **Eighte| 🚢 **Live Vessels** | Thousands of ships worldwide | AISStream | 🟡 || 🛰️ **Satellites** | 838-object catalog, color-coded by class with a live legend — the **DENSE** chip drops in the whole Starlink shell | CelesTrak | 🟢 || 🌍 **Earthquakes** | Global seismic activity, last 24h | USGS | 🟢 |+ | ◍ **Air quality** | Live AQHI on the published 1–10+ health-risk scale, with a Weather-panel card showing the band legend and the highest readings in view. **Canada only** — ECCC is the first registered provider | ECCC MSC GeoMet | 🟢 || 🚗 **Traffic** | Simulated vehicles on OSM roads. With TomTom, live flow speeds drive the simulation and congestion colors below ~8 km; individual vehicle positions are not live observations | TomTom + OSM | 🟢 simulation · 🟡 live flow speeds |- | 📹 **CCTV Mesh** | Public cameras projected _into_ the 3D space — Austin · Texas (TxDOT) · California (Caltrans) · London (TfL) · Ontario (511) · Finland (Fintraffic) · British Columbia (DriveBC) · Estonia (Tallinn, Tarktee) · Delaware (DelDOT live video) · New South Wales (Live Traffic NSW) · Calgary · Norway (Statens vegvesen) · Toronto. Positions are published; poses are estimated priors **you calibrate by dragging a gizmo on the camera itself** | City APIs | 🟢 |-| 📹 **CCTV Mesh** | ~3,900 public cameras projected _into_ the 3D space — Austin · Texas (TxDOT) · California (Caltrans) · London (TfL) · Ontario (511) · Finland (Fintraffic) · British Columbia (DriveBC) · Estonia (Tallinn, Tarktee) · Delaware (DelDOT live video) · New South Wales (Live Traffic NSW) · Calgary · Norway (Statens vegvesen), plus opt-in New York City (NYC DOT TMC, needs your own NYC DOT agreement). Positions are published; poses are estimated priors **you calibrate by dragging a gizmo on the camera itself** | City APIs | 🟢 |++| 📹 **CCTV Mesh** | Public cameras projected _into_ the 3D space — Austin · Texas (TxDOT) · California (Caltrans) · London (TfL) · Ontario (511) · Finland (Fintraffic) · British Columbia (DriveBC) · Estonia (Tallinn, Tarktee) · Delaware (DelDOT live video) · New South Wales (Live Traffic NSW) · Calgary · Norway (Statens vegvesen) · Toronto, plus opt-in New York City (NYC DOT TMC, needs your own NYC DOT agreement). Positions are published; poses are estimated priors **you calibrate by dragging a gizmo on the camera itself** | City APIs | 🟢 || 📷 **Mapped ALPR Cameras** | License-plate-reader camera locations tagged by OpenStreetMap contributors, loaded one city-sized view at a time, with **SHOW NEAREST**. Locations and tags only: no plate data, no video | OpenStreetMap (incl. DeFlock mapping) | 🟢 |- | 📷 **Street Level** | Street-level photos behind one panel, one chip per provider: coverage on the streets, image cones, an embedded viewer and **FOLLOW**. Mapillary and Google Street View; Panoramax and KartaView planned | Mapillary · Google | 🟡 Mapillary token · 🔴 Google Maps key |+ | 📷 **Street Level** | Street-level photos behind one panel, one chip per provider: coverage on the streets, image cones, an embedded viewer and **FOLLOW**. Mapillary, Google Street View, KartaView and Panoramax | Mapillary · Google · KartaView · Panoramax | 🟢 KartaView, Panoramax · 🟡 Mapillary token · 🔴 Google Maps key || 📻 **Radio** | Geolocated world radio with an **analog tuner** — drag the needle across up to 750 stations and the globe flies to each broadcaster | Radio Browser / broadcasters | 🟢 || 🚌 **Transit** | Live buses, trams, metros, trains and ferries with delayed playback between reports, selected-vehicle trails, and mode-coloured DETECT labels — Boston, Austin, Minneapolis, Helsinki, the Netherlands, Norway, South East Queensland | Operator GTFS-Realtime feeds | 🟢 || 🚲 **Bikeshare** | Live station availability | GBFS | 🟢 |diff --cc docs/CURRENT-STATE.mdindex eb674d95c,2cc281812..aab9d0447--- a/docs/CURRENT-STATE.md+++ b/docs/CURRENT-STATE.md@@@ -3071,10 -3192,10 +3192,10 @@@ its criteria cannot be silently ignored| Satellites | CelesTrak | `src/data/satellites.js` | `/api/celestrak` | 120s || Space Missions (30d) | Launch Library 2 + CelesTrak | `src/data/rocketLaunches.js` | `/api/launches` + `/api/celestrak/active` | 5 min || Traffic | Selectable TomTom / OpenStreetMap / Hybrid roads; optional TomTom flow (BYOK) | `src/data/traffic.js` | browser-direct OpenFreeMap tiles; `/api/tomtom` for flow | viewport-driven; capped tile cache |- | CCTV | Austin + Caltrans (CA) + TfL London + Ontario 511 + Fintraffic (FI) + DriveBC (BC) + TxDOT (TX) + Estonia (Tallinn, Tarktee) + Live Traffic NSW + Open Calgary Open Data + Statens vegvesen (NO, stills + live HLS) + City of Toronto RESCU + Street View fallback | `src/data/cctv.js` | `/api/cctv` | 10s (active) |-| CCTV | Austin + Caltrans (CA) + TfL London + Ontario 511 + Fintraffic (FI) + DriveBC (BC) + TxDOT (TX) + Estonia (Tallinn, Tarktee) + Live Traffic NSW + Open Calgary Open Data + Statens vegvesen (NO, stills + live HLS) + NYC DOT TMC (opt-in) + Street View fallback | `src/data/cctv.js` | `/api/cctv` | 10s (active) |++| CCTV | Austin + Caltrans (CA) + TfL London + Ontario 511 + Fintraffic (FI) + DriveBC (BC) + TxDOT (TX) + Estonia (Tallinn, Tarktee) + Live Traffic NSW + Open Calgary Open Data + Statens vegvesen (NO, stills + live HLS) + NYC DOT TMC (opt-in) + City of Toronto RESCU + Street View fallback | `src/data/cctv.js` | `/api/cctv` | 10s (active) || Radio | Radio Browser (public-domain station directory) | `src/data/radio.js` | `/api/radio/stations`, `/api/radio/click/:uuid` | 45 min directory refresh || Transit 🚌 | Operator GTFS-Realtime VehiclePositions (7 keyless regions, `src/data/transitFeeds.js`) | `src/layers/transit/` via `src/app/layers/transit.js` | `/api/transit` | 15s (poll + delayed playback) |- | Bikeshare 🚲 | GBFS (Lyft + BCycle) | `src/data/bikeshare.js` | `/api/gbfs` | 60s |+ | Bikeshare 🚲 | GBFS (Lyft + BCycle + Social Bicycles + PBSC incl. Bike Share Toronto + Urban Sharing, Entur, JCDecaux NO) | `src/data/bikeshare.js` | `/api/gbfs` | 60s || Directions 🧭 | OSRM on FOSSGIS servers (OpenStreetMap) | `src/data/directions.js` | `/api/route` (`steps=1`) | on placement / mode change || Datacenters ▣ | OSM extract (bundled) | `src/data/localLayers.js` | — | static || Dams ▰ | OpenInfraMap/OSM extract (bundled) | `src/data/localLayers.js` | — | static |diff --cc server/providers/cctv/catalog.jsindex e53acba80,99e627310..0d5392402--- a/server/providers/cctv/catalog.js+++ b/server/providers/cctv/catalog.js@@@ -19,7 -19,7 +19,8 @@@ importloadCalgarySourcesFromOpenData,loadDelDOTSourcesFromOpenData,loadVegvesenSourcesFromOpenData,+ loadNycSourcesFromOpenData,+ loadTorontoSourcesFromOpenData,} from './sources.js';/** Env kill switch: unset or anything but "0" means enabled. */@@@ -99,11 -102,13 +103,18 @@@ const LIVE_PACKS =enabled: () => envEnabled('CCTV_VEGVESEN_ENABLED'),load: loadVegvesenSourcesFromOpenData,},+ {+ // NYC DOT requires a data-sharing agreement for this feed, so the pack is+ // off unless the operator opts in (see DATA_SOURCES.md).+ name: 'nyc',+ enabled: () => envOptIn('CCTV_NYC_ENABLED'),+ load: loadNycSourcesFromOpenData,+ },+ {+ name: 'toronto',+ enabled: () => envEnabled('CCTV_TORONTO_ENABLED'),+ load: loadTorontoSourcesFromOpenData,+ },];/*** Load CCTV sources from a local JSON file (CCTV_SOURCES_FILE env or default).diff --cc server/providers/cctv/sources.jsindex e03701de9,43ba30994..dc925b9ea--- a/server/providers/cctv/sources.js+++ b/server/providers/cctv/sources.js@@@ -88,8 -89,8 +95,9 @@@ importisLikelyTexasCoordinate,isLikelyNswCoordinate,isLikelyCalgaryCoordinate,+ isLikelyNycCoordinate,isLikelyNorwayCoordinate,+ isLikelyTorontoCoordinate,cameraDisplayCode,rowArrayToObject,prioritizeSources,@@@ -1871,174 -1869,150 +1879,319 @@@ export async function loadVegvesenSourcerror?.message || error,);return [];+ }+ }++ const NYC_BOROUGHS = new Set([+ 'Manhattan',+ 'Brooklyn',+ 'Queens',+ 'Bronx',+ 'Staten Island',+ ]);++ /** NYC TMC publishes `isOnline` as the strings "true"/"false". */+ export function nycCameraIsOnline(value) {+ return (+ value === true ||+ String(value ?? '')+ .trim()+ .toLowerCase() === 'true'+ );+ }++ /**+ * Label for one NYC camera: the intersection an operator recognises+ * ("Central Park West @ 86 St"). The catalog's `area` is the borough, not+ * a facing, and is not part of the name.+ *+ * @param {object} record - Raw TMC camera row.+ * @param {string} cameraId - Derived stable id.+ * @returns {string}+ */+ export function nycCameraName(record, cameraId) {+ const name = String(record?.name ?? '').trim();+ if (name) return name;+ const short = String(cameraId || '')+ .replace(/^nyc-/, '')+ .slice(0, 8);+ return short ? `NYC Camera ${short}` : 'NYC Camera';+ }++ /**+ * One NYC DOT TMC camera row -> one catalog source, or null.+ *+ * Frame URLs are synthesized from a validated UUID on the pinned TMC image+ * origin. The payload's `imageUrl` is ignored so a catalog edit cannot steer+ * the frame proxy off-host. There is no heading in the feed; headings use+ * the shared id-hash fallback at low confidence, like Calgary and Fintraffic.+ *+ * @param {object} record - Raw TMC camera row.+ * @returns {?object}+ */+ export function nycCameraToSource(record) {+ if (!record || typeof record !== 'object') return null;+ if (!nycCameraIsOnline(record.isOnline)) return null;++ const lat = toFiniteNumber(record.latitude);+ const lon = toFiniteNumber(record.longitude);+ if (!isLikelyNycCoordinate(lat, lon)) return null;++ const uuid = String(record.id ?? '').trim();+ if (!NYC_CAMERA_ID_RE.test(uuid)) return null;+ const cameraId = `nyc-${uuid.toLowerCase()}`;+ const imageUrl = NYC_IMAGE_URL(uuid);+ const name = nycCameraName(record, cameraId);+ const area = String(record.area ?? '').trim();+ const city = NYC_BOROUGHS.has(area) ? area : 'New York';++ return {+ id: cameraId,+ name,+ city,+ cityId: 'nyc',+ provider: 'NYC DOT Traffic Management Center',+ lat,+ lon,+ headingDeg: fallbackHeadingFromId(cameraId),+ headingConfidence: 'low',+ pitchDeg: -18,+ fovDeg: 44,+ rangeM: 145,+ mountHeightM: 8,+ groundElevationM: NYC_GROUND_ELEVATION_M,+ feedType: 'image',+ url: imageUrl,+ snapshotUrl: imageUrl,+ sourceKind: 'nyc-dot-tmc',+ license: 'Public NYC DOT Traffic Management Center traffic camera',+ code: cameraDisplayCode(name.toUpperCase()),+ };+ }++ /**+ * Fetch NYC DOT Traffic Management Center cameras from the keyless+ * `webcams.nyctmc.org` catalog. Frames are stills on that same host,+ * registered from a validated UUID rather than from the payload URL.+ *+ * @returns {Promise<Array<object>>} Normalized camera source objects.+ */+ export async function loadNycSourcesFromOpenData() {+ try {+ const endpoint = process.env.CCTV_NYC_CAMERAS_URL || NYC_CAMERAS_URL;+ const resp = await fetch(endpoint, {+ headers: { Accept: 'application/json' },+ redirect: 'manual',+ signal: AbortSignal.timeout(CCTV_SOURCE_FETCH_TIMEOUT_MS),+ });+ const discard = async () => {+ try {+ await resp.body?.cancel();+ } catch {+ /* no-op */+ }+ return [];+ };+ if (resp.status >= 300 && resp.status < 400) {+ console.warn('[CCTV] NYC catalog redirected; redirects are not followed');+ return discard();+ }+ if (!resp.ok) {+ console.warn('[CCTV] NYC camera download failed:', resp.status);+ return discard();+ }+ const rows = await readResponseJsonCapped(resp, NYC_MAX_CATALOG_BYTES);+ if (!Array.isArray(rows)) return [];+ const cameras = [];+ const seen = new Set();+ for (const record of rows) {+ const camera = nycCameraToSource(record);+ if (!camera || seen.has(camera.id)) continue;+ seen.add(camera.id);+ cameras.push(camera);+ }+ const maxRaw = Number(+ process.env.CCTV_NYC_MAX_SOURCES || DEFAULT_NYC_MAX_SOURCES,+ );+ const maxCount = Number.isFinite(maxRaw)+ ? Math.max(8, Math.min(400, Math.floor(maxRaw)))+ : DEFAULT_NYC_MAX_SOURCES;+ const prioritized = prioritizeSources(cameras, maxCount, NYC_ANCHORS);+ console.log(+ `[CCTV] Loaded NYC camera sources: ${cameras.length} (using nearest ${prioritized.length})`,+ );+ return prioritized;+ } catch (error) {+ console.warn('[CCTV] NYC camera download error:', error?.message || error);+ return [];}}++/**+ * The JSONP envelope the City of Toronto wraps its camera list in. Anchored at+ * both ends, so only that exact callback is unwrapped — a payload that merely+ * contains the name somewhere is not treated as the list.+ */+const RESCU_JSONP = /^jsonTMCEarthCamerasCallback\(([\s\S]*)\)\s*;?$/;++/**+ * Unwrap the RESCU camera list. The portal serves the list as JSONP; should it+ * ever drop the wrapper, the bare JSON document still parses. Anything else —+ * a foreign callback, a truncated body, an error page — yields no cameras+ * rather than a thrown loader.+ *+ * @param {string} text - Raw response body.+ * @returns {Array<object>} The `Data` rows, or [] when the body is unusable.+ */+export function parseRescuCameraList(text) {+ const body = String(text ?? '').trim();+ if (!body) return [];+ const unwrapped = RESCU_JSONP.exec(body)?.[1] ?? body;+ try {+ const parsed = JSON.parse(unwrapped);+ const rows = parsed?.Data ?? parsed?.data;+ return Array.isArray(rows) ? rows : [];+ } catch {+ return [];+ }+}++/**+ * Convert one RESCU list row into a camera source.+ *+ * The row carries no URL: the frame URL is built from the documented+ * `loc####.jpg` convention and a camera number validated as plain digits, so+ * the frame proxy is pinned to the city origin by construction and no upstream+ * field — present or planted — can steer it.+ *+ * No compass heading exists in this dataset. `D1`-`D4` are the directions of+ * the *comparison* images (static reference stills captured in 2016, served+ * from a different path); the live frame is one pan-tilt-zoom camera pointing+ * wherever the operator left it. Treating those letters as a facing would put+ * a confident, wrong bearing on every camera in the city, so every row takes+ * the id-hash fallback and the low-confidence pose, as headingless Austin,+ * TfL, Fintraffic and Calgary cameras do.+ *+ * @param {object} row - One entry from the RESCU `Data` array.+ * @returns {object|null} Normalized camera source, or null when unusable.+ */+export function torontoCameraToSource(row) {+ if (!row || typeof row !== 'object') return null;+ const number = String(row.Number ?? row.number ?? '').trim();+ // Plain digits only: a number is about to become a URL path segment.+ if (!/^\d{1,6}$/.test(number)) return null;++ const lat = toFiniteNumber(row.Latitude ?? row.latitude);+ const lon = toFiniteNumber(row.Longitude ?? row.longitude);+ if (!isLikelyTorontoCoordinate(lat, lon)) return null;++ const cameraId = `toronto-${number}`;+ // The feed's own label, verbatim. It is upper-case ("MCCOWAN RD", "ST+ // HELEN'S AVE"); title-casing it would mangle more names than it fixed.+ const name =+ String(row.Name ?? row.name ?? '')+ .replace(/\s+/g, ' ')+ .trim() || `Toronto Camera ${number}`;++ return {+ id: cameraId,+ name,+ city: 'Toronto',+ cityId: 'toronto',+ provider: 'City of Toronto',+ lat,+ lon,+ headingDeg: fallbackHeadingFromId(cameraId),+ headingConfidence: 'low',+ pitchDeg: -18,+ fovDeg: 44,+ rangeM: 145,+ mountHeightM: 8,+ groundElevationM: TORONTO_GROUND_ELEVATION_M,+ feedType: 'image',+ url: `${TORONTO_RESCU_IMAGE_ORIGIN}loc${number}.jpg`,+ snapshotUrl: `${TORONTO_RESCU_IMAGE_ORIGIN}loc${number}.jpg`,+ sourceKind: 'toronto-rescu-open-data',+ license:+ 'Contains information licensed under the Open Government Licence – Toronto',+ // Unselected-label code: the intersection, so a camera at rest reads as a+ // place rather than as its id.+ code: cameraDisplayCode(name.toUpperCase()),+ };+}++/**+ * Fetch City of Toronto RESCU traffic cameras from the City's open data+ * portal, keyless. One JSONP list for the whole city; frames are stills on the+ * same portal origin.+ *+ * The list fetch refuses redirects (`redirect: 'manual'`) so the list host+ * cannot be steered, and caps the body it will buffer.+ *+ * Attribution: Open Government Licence – Toronto, registered in+ * src/data/dataCredits.js.+ *+ * @returns {Promise<Array<object>>} Normalized camera source objects.+ */+export async function loadTorontoSourcesFromOpenData() {+ try {+ const endpoint =+ process.env.CCTV_TORONTO_LIST_URL || TORONTO_RESCU_LIST_URL;+ const resp = await fetch(endpoint, {+ headers: { Accept: 'application/json, text/javascript' },+ redirect: 'manual',+ signal: AbortSignal.timeout(CCTV_SOURCE_FETCH_TIMEOUT_MS),+ });+ // A response this loader will not read still owns its transport until the+ // body is released, so every rejection path cancels before returning.+ const discard = async () => {+ try {+ await resp.body?.cancel();+ } catch {+ /* no-op */+ }+ return [];+ };+ if (resp.status >= 300 && resp.status < 400) {+ console.warn(+ '[CCTV] Toronto camera list redirected; redirects are not followed',+ );+ return discard();+ }+ if (!resp.ok) {+ console.warn('[CCTV] Toronto camera download failed:', resp.status);+ return discard();+ }+ const text = await readResponseTextCapped(resp, TORONTO_MAX_CATALOG_BYTES);+ const rows = parseRescuCameraList(text);+ if (!rows.length) return [];++ const cameras = [];+ const seen = new Set();+ for (const record of rows) {+ const camera = torontoCameraToSource(record);+ if (!camera || seen.has(camera.id)) continue;+ seen.add(camera.id);+ cameras.push(camera);+ }+ const maxRaw = Number(+ process.env.CCTV_TORONTO_MAX_SOURCES || DEFAULT_TORONTO_MAX_SOURCES,+ );+ const maxCount = Number.isFinite(maxRaw)+ ? Math.max(8, Math.min(500, Math.floor(maxRaw)))+ : DEFAULT_TORONTO_MAX_SOURCES;+ const prioritized = prioritizeSources(cameras, maxCount, [+ TORONTO_DOWNTOWN,+ ]);+ console.log(+ `[CCTV] Loaded Toronto camera sources: ${cameras.length} (using nearest ${prioritized.length})`,+ );+ return prioritized;+ } catch (error) {+ console.warn(+ '[CCTV] Toronto camera download error:',+ error?.message || error,+ );+ return [];+ }+}diff --cc src/data/dataCredits.jsindex d6f2f3ad4,f95070d04..a8f0b2d39--- a/src/data/dataCredits.js+++ b/src/data/dataCredits.js@@@ -247,15 -261,38 +261,44 @@@ export const DATA_CREDITS ='<a href="https://data.norge.no/nlod/en/2.0" target="_blank" rel="noopener">Norwegian licence for Open Government data (NLOD)</a> ' +'distributed by Statens vegvesen',},+ {+ key: 'nyc-cctv',+ html:+ 'CCTV cameras & frames (New York City, when enabled): ' ++ '<a href="https://webcams.nyctmc.org/" target="_blank" rel="noopener">NYC DOT Traffic Management Center</a>. ' ++ NYC_DOT_DISCLAIMER,+ },+ {+ key: 'toronto-cctv',+ html:+ 'Traffic cameras (Toronto): contains information licensed under the ' ++ '<a href="https://www.toronto.ca/city-government/data-research-maps/open-data/open-data-licence/" target="_blank" rel="noopener">Open Government Licence – Toronto</a>',+ },{key: 'gbfs',- html: 'Bikeshare availability: GBFS operator feeds (e.g. Austin BCycle)',+ html:+ 'Bikeshare availability: GBFS operator feeds ' ++ '(e.g. Austin BCycle; Bike Share Toronto, operated by the Toronto Parking Authority)',+ },+ {+ key: 'urbansharing-gbfs',+ html:+ 'City bikes (Norway): contains data under the ' ++ '<a href="https://data.norge.no/nlod/en/2.0" target="_blank" rel="noopener">Norwegian licence for Open Government data (NLOD)</a> ' ++ 'made available by Oslo Bysykkel, Bergen Bysykkel and Trondheim Bysykkel',+ },+ {+ key: 'entur-mobility-gbfs',+ html:+ 'City bikes (Stavanger, Skien/Porsgrunn): contains data under the ' ++ '<a href="https://data.norge.no/nlod/en/2.0" target="_blank" rel="noopener">Norwegian licence for Open Government data (NLOD)</a> ' ++ 'made available by Entur (Kolumbus Bysykkel, Farte Bysykkel)',+ },+ {+ key: 'jcdecaux-gbfs',+ html:+ 'City bikes (Lillestrøm): Bysykkel Lillestrøm, JCDecaux — ' ++ '<a href="https://developer.jcdecaux.com/files/Open-Licence-fr.pdf" target="_blank" rel="noopener">Licence Ouverte</a>',},{key: 'osrm-routing',