Skip to content

A spy satellite simulator in your browser, except the data is real. Live open source spatial intelligence on a photorealistic 3D globe.

Merge upstream/main into feature/catalonia-cctv-cameras

ulihhhh5b4931572a94
diff --cc docs/CURRENT-STATE.md
index 9a113579d,67acfffce..942e0605f
--- a/docs/CURRENT-STATE.md
+++ b/docs/CURRENT-STATE.md
@@@ -2510,25 -2673,26 +2673,26 @@@ nearby place—always use station selec
requests use Play; a qualified Play-shaped tool call is normalized to Select so
its criteria cannot be silently ignored.
- | Layer | Source | File | Proxy | Update Interval |
- |-------|--------|------|-------|-----------------|
- | Live Flights ✈️ | OpenSky Network; bounded adsb.lol regional fallback | `src/data/flights.js` | `/api/opensky` (OAuth + fallback) | 30s |
- | Military Flights 🎖️ | adsb.lol /v2/mil | `src/data/militaryFlights.js` | `/api/adsblol/mil` | 15s |
- | Live AIS Vessels 🚢 | AISStream websocket | `src/data/aisLiveVessels.js` | `/api/ais-live` | 60s (+800ms visibility pass) |
- | Mapped Installations ⌖ | OpenStreetMap mapped context; on-demand Google Maps Places supplement | `src/data/militaryInstallations.js` | `/api/military-installations`, `/api/google/text-search` | viewport-driven + user search; while unavailable, auto-retry 30 s → 240 s backoff |
- | Earthquakes | USGS | `src/data/earthquakes.js` | — | 60s |
- | 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 | OSM Overpass (+ optional TomTom live flow) | `src/data/traffic.js` | `/api/overpass` + `/api/tomtom` | viewport-driven |
- | CCTV | Austin + Caltrans (CA) + TfL London + Ontario 511 + Fintraffic (FI) + DriveBC (BC) + TxDOT (TX) + Estonia (Tallinn, Tarktee) + Live Traffic NSW + Open Calgary Open Data + Catalonia (Servei Català de Trànsit) + 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 |
- | 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 |
- | Submarine Cables ◠ | TeleGeography public map (bundled) | `src/data/telegeographySubmarineCables.js` | — | static |
- | FIRMS Active Fires ▲ | NASA FIRMS live (VIIRS ×3 NRT, trailing 24h) | `src/data/firmsHeatmap.js` | `/api/firms` (`FIRMS_MAP_KEY`) | 10 min (proxy TTL 30 min) |
+ | Layer | Source | File | Proxy | Update Interval |
+ | ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------- | -------------------------------------------------------- | --------------------------------------------------------------------------------- |
+ | Live Flights ✈️ | OpenSky Network; bounded adsb.lol regional fallback | `src/data/flights.js` | `/api/opensky` (OAuth + fallback) | 30s |
+ | Military Flights 🎖️ | adsb.lol /v2/mil | `src/data/militaryFlights.js` | `/api/adsblol/mil` | 15s |
+ | Live AIS Vessels 🚢 | AISStream websocket | `src/data/aisLiveVessels.js` | `/api/ais-live` | 60s (+800ms visibility pass) |
+ | Mapped Installations ⌖ | OpenStreetMap mapped context; on-demand Google Maps Places supplement | `src/data/militaryInstallations.js` | `/api/military-installations`, `/api/google/text-search` | viewport-driven + user search; while unavailable, auto-retry 30 s → 240 s backoff |
+ | Earthquakes | USGS | `src/data/earthquakes.js` | — | 60s |
+ | 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 | OSM Overpass (+ optional TomTom live flow) | `src/data/traffic.js` | `/api/overpass` + `/api/tomtom` | viewport-driven |
-| CCTV | Austin + Caltrans (CA) + TfL London + Ontario 511 + Fintraffic (FI) + DriveBC (BC) + TxDOT (TX) + Estonia (Tallinn, Tarktee) + Live Traffic NSW + Open Calgary Open Data + 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 + Catalonia (Servei Català de Trànsit) + 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 |
+ | 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 |
+ | Submarine Cables ◠ | TeleGeography public map (bundled) | `src/data/telegeographySubmarineCables.js` | — | static |
+ | FIRMS Active Fires ▲ | NASA FIRMS live (VIIRS ×3 NRT, trailing 24h) | `src/data/firmsHeatmap.js` | `/api/firms` (`FIRMS_MAP_KEY`) | 10 min (proxy TTL 30 min) |
+ | Wind 🌬 | NOAA GFS 10 m wind (keyless, 0.25°→1° grid; animated particles) | `src/data/wind.js` | `/api/wind` | 1 h (forecast cycle) |
Directions is a keyless front end to the routing the voice agent already
uses. Its row chips are the whole interface: DRIVE / WALK / BIKE pick the
diff --cc server/providers/cctv/catalog.js
index c681d321c,ae0ab9afa..f679ba1fe
--- a/server/providers/cctv/catalog.js
+++ b/server/providers/cctv/catalog.js
@@@ -17,7 -17,7 +17,8 @@@ import
loadWarendorfSourcesFromCatalog,
loadNswSourcesFromOpenData,
loadCalgarySourcesFromOpenData,
+ loadCataloniaSourcesFromOpenData,
+ loadDelDOTSourcesFromOpenData,
} from './sources.js';
/** Env kill switch: unset or anything but "0" means enabled. */
@@@ -87,11 -87,11 +88,16 @@@ const LIVE_PACKS =
enabled: () => envEnabled('CCTV_CALGARY_ENABLED'),
load: loadCalgarySourcesFromOpenData,
},
+ {
+ name: 'catalonia',
+ enabled: () => envEnabled('CCTV_CATALONIA_ENABLED'),
+ load: loadCataloniaSourcesFromOpenData,
+ },
+ {
+ name: 'deldot',
+ enabled: () => envEnabled('CCTV_DELDOT_ENABLED'),
+ load: loadDelDOTSourcesFromOpenData,
+ },
];
/**
* Load CCTV sources from a local JSON file (CCTV_SOURCES_FILE env or default).
diff --cc server/providers/cctv/constants.js
index 4dfcbbd15,13578d0b8..c852df235
--- a/server/providers/cctv/constants.js
+++ b/server/providers/cctv/constants.js
@@@ -236,47 -236,14 +236,55 @@@ export const CALGARY_DOWNTOWN = { lat:
* body cannot be buffered without limit. */
export const CALGARY_MAX_CATALOG_BYTES = 4 * 1024 * 1024;
+/**
+ * Catalonia traffic cameras (Servei Català de Trànsit): one keyless WFS/GML
+ * XML list (verified 2026-09-15, hourly catalog refresh). The feed carries a
+ * `font` field naming the actual publisher per camera — SCT's own highway
+ * cameras plus hotlinked Barcelona (IMI) and Terrassa municipal cameras are
+ * kept, each confirmed to return a real frame. Frame URLs are checked
+ * against a host allowlist rather than one pinned origin, since each
+ * publisher serves from its own host.
+ */
+export const CATALONIA_CAMERAS_URL =
+ 'http://www.gencat.cat/transit/opendata/cameres.xml';
+/** Allowed image hosts, one per kept `font` publisher in the feed. */
+export const CATALONIA_IMAGE_HOSTS = Object.freeze(
+ new Set([
+ 'mct.gencat.cat', // SCT
+ 'www.bcn.cat', // IMI (Ajuntament de Barcelona)
+ 'emap.terrassa.cat', // Ajuntament de Terrassa
+ ]),
+);
+/** Per-`font` partner credit, shown beside the provider in the CCTV panel
+ * (same pattern as DriveBC's partner-supplied cameras). SCT is the feed's
+ * own publisher and carries no separate credit. */
+export const CATALONIA_FONT_CREDIT = Object.freeze({
+ IMI: 'Ajuntament de Barcelona',
+ Terrassa: 'Ajuntament de Terrassa',
+});
+/** Ground-elevation priors in metres, by `font`: the feed carries no
+ * elevation, and this pack spans sea level (Barcelona) to Terrassa's plateau
+ * (~270 m). The client's ground snap corrects these on 3D-tile stacks. */
+export const CATALONIA_FONT_ELEVATION_M = Object.freeze({
+ SCT: 80,
+ IMI: 20,
+ Terrassa: 270,
+});
+export const DEFAULT_CATALONIA_MAX_SOURCES = 150;
+/** Prioritization anchors: Barcelona and Terrassa. */
+export const CATALONIA_ANCHORS = [
+ { lat: 41.3874, lon: 2.1686 }, // Barcelona
+ { lat: 41.5636, lon: 2.0111 }, // Terrassa
+];
+
+ /** DelDOT CCTV: one keyless statewide JSON catalog; live video via RTMP-over-HTTP (rtmpt:80). */
+ export const DELDOT_CCTV_URL = 'https://tmc.deldot.gov/json/videocamera.json';
+ export const DEFAULT_DELDOT_MAX_SOURCES = 300;
+ export const DELDOT_ANCHORS = [
+ { lat: 39.7459, lon: -75.5466 }, // Wilmington (New Castle)
+ { lat: 39.1582, lon: -75.5244 }, // Dover (Kent)
+ { lat: 38.6906, lon: -75.3877 }, // Georgetown (Sussex)
+ ];
/** Camera CATALOGS change rarely; 15 min keeps multi-megabyte upstream list refetches (Austin rows.json + 4 Caltrans districts + TfL + Ontario 511) infrequent. Frames are fetched per-request and are unaffected. */
export const CCTV_SOURCE_CACHE_MS = 15 * 60 * 1000;
/** Per-provider catalog-fetch timeout. Bounds the worst-case refresh so one
diff --cc server/providers/cctv/sources.js
index 3f73e70bc,ad8a883da..f32b928a2
--- a/server/providers/cctv/sources.js
+++ b/server/providers/cctv/sources.js
@@@ -55,13 -55,10 +55,16 @@@ import
DEFAULT_CALGARY_MAX_SOURCES,
CALGARY_DOWNTOWN,
CALGARY_MAX_CATALOG_BYTES,
+ CATALONIA_CAMERAS_URL,
+ CATALONIA_IMAGE_HOSTS,
+ CATALONIA_FONT_CREDIT,
+ CATALONIA_FONT_ELEVATION_M,
+ DEFAULT_CATALONIA_MAX_SOURCES,
+ CATALONIA_ANCHORS,
CCTV_SOURCE_FETCH_TIMEOUT_MS,
+ DELDOT_CCTV_URL,
+ DEFAULT_DELDOT_MAX_SOURCES,
+ DELDOT_ANCHORS,
} from './constants.js';
import {
toFiniteNumber,
@@@ -1603,197 -1598,106 +1606,301 @@@ export async function loadCalgarySource
}
}
+/**
+ * Parse the Catalonia (`cameres.xml`) WFS/GML feed into raw feature records.
+ * Regex-based rather than a full XML parser — the feed is small (~160
+ * features) and this avoids a new dependency for one field set per feature.
+ *
+ * @param {string} xml
+ * @returns {Array<{fid:string, lat:number, lon:number, carretera:string, municipi:string, pk:string, link:string, font:string}>}
+ */
+export function parseCataloniaXml(xml) {
+ const out = [];
+ const blockRe = /<gml:featureMember>([\s\S]*?)<\/gml:featureMember>/g;
+ const tag = (block, name) => {
+ const match = new RegExp(`<cite:${name}>([^<]*)<\\/cite:${name}>`).exec(
+ block,
+ );
+ return match ? decodeNumericEntities(match[1]) : '';
+ };
+ let match;
+ while ((match = blockRe.exec(String(xml || ''))) !== null) {
+ const block = match[1];
+ const fidMatch = /<cite:cameres\s+fid="([^"]+)"/.exec(block);
+ const coordsMatch = /<gml:coordinates[^>]*>([^<]+)<\/gml:coordinates>/.exec(
+ block,
+ );
+ if (!fidMatch || !coordsMatch) continue;
+ const [lonRaw, latRaw] = coordsMatch[1].split(',');
+ out.push({
+ fid: fidMatch[1],
+ lon: toFiniteNumber(lonRaw),
+ lat: toFiniteNumber(latRaw),
+ carretera: tag(block, 'carretera'),
+ municipi: tag(block, 'municipi'),
+ pk: tag(block, 'pk'),
+ link: tag(block, 'link'),
+ font: tag(block, 'font'),
+ });
+ }
+ return out;
+}
+
+/**
+ * Validate and normalize one Catalonia feed `link` against the publisher
+ * host allowlist (CATALONIA_IMAGE_HOSTS), upgrading to https. Rejects
+ * anything else, including a host that merely resembles an allowed one.
+ *
+ * SCT's own `RenderService` frame link is a special case, for two stacked
+ * reasons (both verified 2026-09-15):
+ * 1. It always 302s to `TransitCamera`, on a Location the upstream
+ * hardcodes as plain http even when RenderService itself was requested
+ * over https. fetchWithinHost (media.js) only follows same-origin
+ * redirects — same scheme included, by design, to stop an upstream
+ * steering a host-pinned request into a plaintext downgrade — so that
+ * hop is refused and the camera would render as a placeholder.
+ * 2. mct.gencat.cat's TLS setup itself does not complete a handshake with
+ * Node's fetch/OpenSSL (`ERR_SSL_WRONG_SIGNATURE_TYPE`) even though it
+ * is reachable over https from other clients (e.g. curl) — an upstream
+ * server misconfiguration this proxy cannot route around.
+ * TransitCamera answers the frame directly over **http**, no redirect, and
+ * that is the only transport this host actually serves to this runtime — so
+ * this builds that URL itself from RenderService's `sctidcam` id instead of
+ * registering the (https, then-redirecting) RenderService link.
+ *
+ * @param {string} rawUrl
+ * @returns {string} Normalized URL, or '' if not accepted.
+ */
+export function normalizeCataloniaImageUrl(rawUrl) {
+ let parsed;
+ try {
+ parsed = new URL(String(rawUrl || '').trim());
+ } catch {
+ return '';
+ }
+ if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') return '';
+ if (!CATALONIA_IMAGE_HOSTS.has(parsed.hostname)) return '';
+
+ if (parsed.hostname === 'mct.gencat.cat') {
+ const camId = parsed.searchParams.get('sctidcam');
+ if (!camId) return '';
+ const direct = new URL('http://mct.gencat.cat/mct2bo/TransitCamera');
+ direct.searchParams.set('nom', camId);
+ direct.searchParams.set('visualitzacio', 'imatge');
+ return direct.toString();
+ }
+
+ parsed.protocol = 'https:';
+ return parsed.toString();
+}
+
+/**
+ * Human label for one Catalonia camera: "<road/place> (<municipality>)",
+ * skipping the parenthetical when the municipality is already named in the
+ * road/place text or when one half is missing.
+ *
+ * @param {string} carretera
+ * @param {string} municipi
+ * @returns {string}
+ */
+export function cataloniaCameraName(carretera, municipi) {
+ const road = String(carretera || '').trim();
+ const city = String(municipi || '').trim();
+ if (road && city) {
+ return road.toLowerCase().includes(city.toLowerCase())
+ ? road
+ : `${road} (${city})`;
+ }
+ return road || city || 'Càmera de trànsit';
+}
+
+/**
+ * Fetch Catalonia traffic cameras (Servei Català de Trànsit), keyless: one
+ * WFS/GML XML list. The feed carries a `font` field naming the real
+ * publisher per camera; only SCT's own highway cameras and the hotlinked
+ * Barcelona (IMI) and Terrassa municipal cameras are kept, each confirmed to
+ * return a real frame — frame URLs are checked against a host allowlist
+ * (CATALONIA_IMAGE_HOSTS), so a row from any other publisher is dropped.
+ * Each non-SCT camera carries its publisher as a `credit` alongside the
+ * shared `provider`. The feed carries no heading, so every camera takes the
+ * id-hash fallback, low-confidence pose (same as TfL and Fintraffic).
+ *
+ * @returns {Promise<Array<object>>} Normalized camera source objects.
+ */
+export async function loadCataloniaSourcesFromOpenData() {
+ try {
+ const resp = await fetch(CATALONIA_CAMERAS_URL, {
+ headers: { Accept: 'application/xml,text/xml,*/*' },
+ signal: AbortSignal.timeout(CCTV_SOURCE_FETCH_TIMEOUT_MS),
+ });
+ if (!resp.ok) {
+ console.warn('[CCTV] Catalonia camera download failed:', resp.status);
+ return [];
+ }
+ const xml = await resp.text();
+ const rows = parseCataloniaXml(xml);
+ if (!rows.length) return [];
+
+ const cameras = [];
+ for (const row of rows) {
+ if (!row.fid) continue;
+ if (!isLikelyCataloniaCoordinate(row.lat, row.lon)) continue;
+ const imageUrl = normalizeCataloniaImageUrl(row.link);
+ if (!imageUrl) continue;
+
+ const font = row.font.trim();
+ const cameraId = `cat-${row.fid
+ .replace(/^cameres\.fid-/, '')
+ .replace(/[^a-zA-Z0-9]/g, '')}`;
+
+ cameras.push({
+ id: cameraId,
+ name: cataloniaCameraName(row.carretera, row.municipi),
+ city: row.municipi.trim() || 'Catalunya',
+ cityId: 'catalunya',
+ provider: 'Servei Català de Trànsit',
+ lat: row.lat,
+ lon: row.lon,
+ headingDeg: fallbackHeadingFromId(cameraId),
+ headingConfidence: 'low',
+ pitchDeg: -18,
+ fovDeg: 44,
+ rangeM: 145,
+ mountHeightM: 8,
+ groundElevationM: CATALONIA_FONT_ELEVATION_M[font] ?? 80,
+ feedType: 'image',
+ url: imageUrl,
+ snapshotUrl: imageUrl,
+ sourceKind: 'catalonia-open-data',
+ license:
+ "Generalitat de Catalunya — Llicència oberta d'ús d'informació",
+ credit: CATALONIA_FONT_CREDIT[font] || '',
+ });
+ }
+
+ const unique = Array.from(
+ new Map(cameras.map((camera) => [camera.id, camera])).values(),
+ );
+ const maxRaw = Number(
+ process.env.CCTV_CATALONIA_MAX_SOURCES || DEFAULT_CATALONIA_MAX_SOURCES,
+ );
+ const maxCount = Number.isFinite(maxRaw)
+ ? Math.max(8, Math.min(600, Math.floor(maxRaw)))
+ : DEFAULT_CATALONIA_MAX_SOURCES;
+ const prioritized = prioritizeSources(unique, maxCount, CATALONIA_ANCHORS);
+ console.log(
+ `[CCTV] Loaded Catalonia camera sources: ${unique.length} (using nearest ${prioritized.length})`,
+ );
+ return prioritized;
+ } catch (error) {
+ console.warn(
+ '[CCTV] Catalonia camera download error:',
+ error?.message || error,
+ );
+ return [];
+ }
+}
++
+ export async function loadDelDOTSourcesFromOpenData() {
+ try {
+ const resp = await fetch(DELDOT_CCTV_URL, {
+ headers: { Accept: 'application/json' },
+ signal: AbortSignal.timeout(CCTV_SOURCE_FETCH_TIMEOUT_MS),
+ redirect: 'error',
+ });
+ if (!resp.ok) {
+ console.warn('[CCTV] DelDOT source download failed:', resp.status);
+ return [];
+ }
+ const payload = await readResponseJsonCapped(resp, 2 * 1024 * 1024);
+ const rows = Array.isArray(payload?.videoCameras)
+ ? payload.videoCameras
+ : [];
+ if (!rows.length) return [];
+
+ const cameras = [];
+ for (const row of rows) {
+ if (String(row?.status).toLowerCase() !== 'active') continue;
+ const lat = toFiniteNumber(row?.lat);
+ const lon = toFiniteNumber(row?.lon);
+ if (!Number.isFinite(lat) || !Number.isFinite(lon)) continue;
+ // Delaware bounding box — a bad upstream coord can't place a camera out of state.
+ if (lat < 38.4 || lat > 39.9 || lon < -75.85 || lon > -75.0) continue;
+
+ // Prefer the catalog's HTTPS HLS transport; no subprocess is required.
+ let stream;
+ try {
+ stream = new URL(String(row?.urls?.m3u8s || ''));
+ } catch {
+ continue;
+ }
+ if (
+ stream.origin !== 'https://video.deldot.gov' ||
+ stream.username ||
+ stream.password ||
+ !/^\/live\/[A-Za-z0-9_.-]+\/playlist\.m3u8$/.test(stream.pathname)
+ )
+ continue;
+ const streamUrl = stream.href;
+
+ const id = String(row?.id || '').trim();
+ if (!/^[A-Za-z0-9_-]{1,80}$/.test(id)) continue;
+ const cameraId = `deldot-${id.toLowerCase()}`;
+ const title = String(row?.title || '').trim();
+
+ // Title carries an unambiguous travel token for ~1 in 5 cameras
+ // ("US 13 SB @ ..."). directionToHeading (allowBare=false) matches only
+ // NB/SB/EB/WB, never a bare "W"/"N" street prefix — "W NORTH ST" yields
+ // no heading and falls back.
+ const heading = directionToHeading(title);
+ const hasHeading = Number.isFinite(heading);
+
+ cameras.push({
+ id: cameraId,
+ name: title || `DelDOT ${id}`,
+ city: String(row?.county ? `${row.county} County` : 'Delaware'),
+ cityId: `deldot-${String(row?.county || 'de')
+ .toLowerCase()
+ .replace(/\s+/g, '-')}`,
+ provider: 'DelDOT',
+ lat,
+ lon,
+ headingDeg: hasHeading ? heading : fallbackHeadingFromId(cameraId),
+ headingConfidence: hasHeading ? 'high' : 'low',
+ // Fabricated RAW PRIOR poses (same personalities as Austin/Caltrans);
+ // the client ground-snap + manual calibration own the truth.
+ pitchDeg: hasHeading ? -24 : -18,
+ fovDeg: hasHeading ? 56 : 44,
+ rangeM: hasHeading ? 210 : 145,
+ mountHeightM: hasHeading ? 10 : 8,
+ groundElevationM: 10, // Estimated prior; client ground resolution owns placement.
+ feedType: 'hls',
+ url: streamUrl,
+ snapshotUrl: '',
+ sourceKind: 'deldot-open-data',
+ license: 'Public DelDOT traffic camera',
+ });
+ }
+
+ const unique = Array.from(
+ new Map(cameras.map((camera) => [camera.id, camera])).values(),
+ );
+ const maxRaw = Number(
+ process.env.CCTV_DELDOT_MAX_SOURCES || DEFAULT_DELDOT_MAX_SOURCES,
+ );
+ const maxCount = Number.isFinite(maxRaw)
+ ? Math.max(8, Math.min(400, Math.floor(maxRaw)))
+ : DEFAULT_DELDOT_MAX_SOURCES;
+ const prioritized = prioritizeSources(unique, maxCount, DELDOT_ANCHORS);
+ console.log(
+ `[CCTV] Loaded DelDOT camera sources: ${unique.length} Active (using nearest ${prioritized.length})`,
+ );
+ return prioritized;
+ } catch (error) {
+ console.warn(
+ '[CCTV] DelDOT source download error:',
+ error?.message || error,
+ );
+ return [];
+ }
+ }