WIP: list credits for all serving providers; pin 511NY imagery to https

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Logan Cusano
2026-10-04 17:56:09 -04:00
co-authored by Claude Opus 5.5
parent aa5b71d853
commit af00139079
3 changed files with 20 additions and 9 deletions
+5 -1
View File
@@ -62,9 +62,13 @@ class Ny511Provider(CameraProvider):
async def fetch_catalog(self) -> List[Camera]:
rows = await ny511._fetch("getcameras", ny511.normalize_camera)
# Hosts for the 511x imagery are unverified, so pin the scheme at least:
# only https URLs reach the browser.
def https(u):
return u if isinstance(u, str) and u.startswith("https://") else None
out = [
make_camera("ny511", r["id"], r["lat"], r["lon"], name=r["name"], roadway=r["roadway"],
direction=r["direction"], image_url=r["image_url"], video_url=r["video_url"])
direction=r["direction"], image_url=https(r["image_url"]), video_url=https(r["video_url"]))
for r in rows
]
return require_parsed(len(rows), out, "511NY")
+8 -6
View File
@@ -181,18 +181,20 @@ async def cameras_in_bbox(bbox: BBox) -> dict:
"""Cameras from every SERVING provider whose coverage meets ``bbox``.
Providers that are off are never fetched."""
conf = await get_settings()
live = [pid for pid, cat in CATALOGS.items()
if effective(PROVIDERS[pid], conf.get(pid))[0] and bbox_intersects(PROVIDERS[pid].meta.coverage, bbox)]
serving = [pid for pid in CATALOGS if effective(PROVIDERS[pid], conf.get(pid))[0]]
live = [pid for pid in serving if bbox_intersects(PROVIDERS[pid].meta.coverage, bbox)]
await asyncio.gather(*(CATALOGS[pid].get() for pid in live))
cams: List[Camera] = []
providers = []
for pid in live:
# Every SERVING provider is listed (credits included) even when the bbox
# misses it, so a client holding one of its cameras from another view can
# still render the required attribution. Only intersecting ones are fetched.
for pid in serving:
cat = CATALOGS[pid]
hits = in_bbox(cat.items, bbox)
hits = in_bbox(cat.items, bbox) if pid in live else []
room = max(0, MAX_ITEMS - len(cams))
cams.extend(hits[:room])
providers.append({"id": pid, "name": PROVIDERS[pid].meta.name, **credit(pid),
"fetched_at": cat.fetched_at, "error": cat.error,
"total_in_bbox": len(hits), "truncated": len(hits) > room})
return {"cameras": cams, "providers": providers,
"serving_count": sum(1 for pid in CATALOGS if effective(PROVIDERS[pid], conf.get(pid))[0])}
return {"cameras": cams, "providers": providers, "serving_count": len(serving)}