Changesets · Branches · Tags · Compare
| Changeset | c80d57aec328febe438b765283aaee0361ac45eeda6c384c90c0f972cc7ea64e |
|---|---|
| Author | Beckam White <beckam2908@gmail.com> · 2026-05-23 02:16 +10:00 |
| Committer | Beckam White <beckam2908@gmail.com> · 2026-05-23 02:16 +10:00 |
| Parents | a9d91f04b07f |
2 files changed
added src/app/api/cctv/australia.ts +22 −0
| @@ -0,0 +1,22 @@ | ||
| 1 | +import { CctvCamera } from "./types"; | |
| 2 | + | |
| 3 | +export async function fetchAustraliaCameras(): Promise<CctvCamera[]> { | |
| 4 | + try { | |
| 5 | + const res = await fetch('https://www.livetraffic.com/datajson/all-feeds-web.json', { signal: AbortSignal.timeout(12000) }); | |
| 6 | + if (!res.ok) return []; | |
| 7 | + const data = await res.json(); | |
| 8 | + return (data || []).filter((event: { eventType: string; }) => event.eventType === 'liveCams').map((cam: { path: string; geometry: { coordinates: number[] }; properties: { title: string; region: string; href: string }; }) => { | |
| 9 | + return { | |
| 10 | + id: cam.path, | |
| 11 | + lat: cam.geometry.coordinates[1], | |
| 12 | + lng: cam.geometry.coordinates[0], | |
| 13 | + name: cam.properties.title || 'Australia Camera', | |
| 14 | + city: cam.properties.region || 'Australia', | |
| 15 | + country: 'Australia', | |
| 16 | + feed_url: cam.properties.href || '', | |
| 17 | + source: 'Live Traffic', | |
| 18 | + | |
| 19 | + }; | |
| 20 | + }).filter((c: { lat: number; lng: number; }) => c.lat && c.lng); | |
| 21 | + } catch { return []; } | |
| 22 | +} | |
| No newline at the end of the file |
modified src/app/api/cctv/route.ts +8 −6
| @@ -6,6 +6,7 @@ | ||
| 6 | 6 | import { fetchMacedoniaCameras } from './macedonia'; |
| 7 | 7 | import { fetchTurkeyCameras } from './turkey'; |
| 8 | 8 | import { fetchRomaniaCameras } from './romania'; |
| 9 | +import { fetchAustraliaCameras } from './australia'; | |
| 9 | 10 | |
| 10 | 11 | /** |
| 11 | 12 | * OSIRIS — Worldwide CCTV Camera API v2 |
| @@ -52,7 +53,7 @@ | ||
| 52 | 53 | // ── US-WEST: Caltrans California Districts ── |
| 53 | 54 | async function fetchCaltransCameras(): Promise<any[]> { |
| 54 | 55 | const allCams: any[] = []; |
| 55 | - for (const dist of ['d03','d04','d05','d06','d07','d08','d10','d11','d12']) { | |
| 56 | + for (const dist of ['d03', 'd04', 'd05', 'd06', 'd07', 'd08', 'd10', 'd11', 'd12']) { | |
| 56 | 57 | try { |
| 57 | 58 | const res = await fetch(`https://cwwp2.dot.ca.gov/data/${dist}/cctv/cctvStatus${dist.toUpperCase()}.json`, { signal: AbortSignal.timeout(8000) }); |
| 58 | 59 | if (!res.ok) continue; |
| @@ -72,7 +73,7 @@ | ||
| 72 | 73 | // ── CANADA: Ottawa, Toronto, Montreal ── |
| 73 | 74 | async function fetchCanadaCameras(): Promise<any[]> { |
| 74 | 75 | const cams: any[] = []; |
| 75 | - | |
| 76 | + | |
| 76 | 77 | // Ottawa MTO Highway Cameras |
| 77 | 78 | try { |
| 78 | 79 | const res = await fetch('https://511on.ca/api/v2/get/cameras', { signal: AbortSignal.timeout(10000), headers: { 'Accept': 'application/json' } }); |
| @@ -220,7 +221,7 @@ | ||
| 220 | 221 | // ── EUROPE: Netherlands, Germany, France ── |
| 221 | 222 | async function fetchEuropeCameras(): Promise<any[]> { |
| 222 | 223 | const cams: any[] = []; |
| 223 | - | |
| 224 | + | |
| 224 | 225 | // Netherlands Rijkswaterstaat |
| 225 | 226 | try { |
| 226 | 227 | const res = await fetch('https://opendata.ndw.nu/cameras.json', { signal: AbortSignal.timeout(8000) }); |
| @@ -245,7 +246,7 @@ | ||
| 245 | 246 | // ── ASIA/PACIFIC ── |
| 246 | 247 | async function fetchAsiaCameras(): Promise<any[]> { |
| 247 | 248 | const cams: any[] = []; |
| 248 | - | |
| 249 | + | |
| 249 | 250 | // Singapore Live Traffic Images |
| 250 | 251 | try { |
| 251 | 252 | const res = await fetch('https://api.data.gov.sg/v1/transport/traffic-images', { signal: AbortSignal.timeout(10000) }); |
| @@ -287,6 +288,7 @@ | ||
| 287 | 288 | 'macedonia': fetchMacedoniaCameras, |
| 288 | 289 | 'turkey': fetchTurkeyCameras, |
| 289 | 290 | 'romania': fetchRomaniaCameras, |
| 291 | + 'australia': fetchAustraliaCameras, | |
| 290 | 292 | }; |
| 291 | 293 | |
| 292 | 294 | // Determine which regions to fetch based on viewport bounds |
| @@ -325,7 +327,7 @@ | ||
| 325 | 327 | if ((lat > -10 && lat < 60 && lng > 60 && lng < 150)) regions.push('asia'); |
| 326 | 328 | // Australia explicitly |
| 327 | 329 | if (lat > -45 && lat < -10 && lng > 110 && lng < 155) regions.push('asia'); |
| 328 | - | |
| 330 | + | |
| 329 | 331 | return regions.length > 0 ? regions : ['uk', 'us-east']; // Default fallback |
| 330 | 332 | } |
| 331 | 333 | |
| @@ -338,7 +340,7 @@ | ||
| 338 | 340 | const radius = parseFloat(searchParams.get('radius') || '10'); |
| 339 | 341 | |
| 340 | 342 | let regionsToFetch: string[]; |
| 341 | - | |
| 343 | + | |
| 342 | 344 | if (region === 'all') { |
| 343 | 345 | regionsToFetch = Object.keys(REGION_FETCHERS); |
| 344 | 346 | } else if (region) { |