feat(sentinel1): Sentinel-1 SAR STAC -> self-hosted TiTiler tile template

Add GET /api/map/sentinel1?bbox=... which queries Planetary Computer STAC
(sentinel-1-grd, last 7d, most recent), signs the vv/hh COG with a SAS token,
and returns a same-origin /titiler/... XYZ tile template. Cache keyed on
quantized bbox + UTC day (20 min TTL). 429 -> 429 (Retry-After), no imagery
-> 404, other upstream errors -> 502.

Self-host TiTiler on the Pi (ghcr.io/developmentseed/titiler, arm64, 1G cap,
host loopback 8001 -> container 8000) instead of titiler.xyz. nginx
/titiler/ proxy snippet routes browser tiles to it; TITILER_PUBLIC_BASE and
TITILER_INTERNAL_URL are env-driven (no hardcoded hostnames).
This commit is contained in:
Sirius DevOps 2026-08-29 01:01:09 -04:00
commit 5212aaa5cd
6 changed files with 346 additions and 5 deletions

View file

@ -53,8 +53,9 @@ from keystore import KeyFormatError, delete_key, list_keys, set_key
from settings_store import SettingsError, get_app_settings, list_models, set_summary_model
from live_layers import (
fetch_aircraft, fetch_fire_incidents, fetch_fire_perimeters,
fetch_planespotters_photo, fetch_radar_meta, fetch_storms, fetch_trains,
fetch_vessels, fetch_weather_alerts, overlay_catalog, parse_bbox,
fetch_planespotters_photo, fetch_radar_meta, fetch_sentinel1, fetch_storms,
fetch_trains, fetch_vessels, fetch_weather_alerts, overlay_catalog,
parse_bbox, UpstreamRateLimited,
)
logging.basicConfig(level=logging.INFO)
@ -1405,6 +1406,33 @@ async def map_radar():
_upstream_or_502(exc, "radar")
@app.get("/api/map/sentinel1")
async def map_sentinel1(bbox: str = Query(..., description="minlon,minlat,maxlon,maxlat")):
"""Most recent Sentinel-1 GRD as a signed COG tile template (TiTiler).
Queries Planetary Computer only on demand; no tiles proxied through the Pi.
"""
_parse_bbox_query(bbox)
try:
result = await fetch_sentinel1(bbox)
except UpstreamRateLimited as exc:
headers = {"Retry-After": exc.retry_after} if exc.retry_after else None
raise HTTPException(
429, "Planetary Computer rate limit", headers=headers,
) from exc
except Exception as exc:
_upstream_or_502(exc, "sentinel1")
if result is None:
return JSONResponse(
status_code=404,
content={
"error": "no_imagery",
"message": "No Sentinel-1 GRD in the last 7 days for this bbox",
},
)
return overlay_json(result, 300)
@app.get("/api/aircraft")
async def list_aircraft(
bbox: str = Query(..., description="minlon,minlat,maxlon,maxlat"),