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:
co-authored by
Claude Opus 5.5
parent
aa5b71d853
commit
af00139079
@@ -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)}
|
||||
|
||||
Reference in New Issue
Block a user