feat(satellites): CelesTrak GP JSON satellites API with SGP4 propagation

GET /api/satellites?groups=stations,weather returns last-known satellite
positions propagated from CelesTrak GP JSON (OMM mean elements, not TLE)
via the real sgp4 library (TEME->geodetic), not two-body Kepler.

- Fetch gp.php?GROUP=...&FORMAT=JSON at most once per 2h per group,
  cached with a last-good blob fallback for 403 / stale responses.
- SatNOGS TLE fallback only when the CelesTrak cache is empty.
- bbox viewport culling; unknown group -> 400.
- overlay_catalog() gains id=satellites (kind=points, /api/satellites).
- OMM path handles NORAD cat numbers >= 100000 (no TLE round-trip).
This commit is contained in:
Sirius DevOps 2026-08-31 21:42:50 -04:00
commit 6b5eec3824
5 changed files with 526 additions and 0 deletions

View file

@ -59,6 +59,7 @@ from live_layers import (
fetch_storms, fetch_trains, fetch_vessels, fetch_weather_alerts,
overlay_catalog, parse_bbox, UpstreamRateLimited,
)
from satellites import fetch_satellites, parse_groups, DEFAULT_GROUPS
logging.basicConfig(level=logging.INFO)
logger = structlog.get_logger("osint.dashboard")
@ -1764,6 +1765,35 @@ async def map_gpsjam(
return overlay_json(fc, 3600)
@app.get("/api/satellites")
async def list_satellites(
groups: str | None = Query(None, description="Comma-separated CelesTrak groups"),
bbox: str | None = Query(None, description="minlon,minlat,maxlon,maxlat"),
limit: int = Query(2000, ge=1, le=5000),
):
"""Last-known satellite positions from CelesTrak GP JSON, SGP4-propagated.
Default groups are ``stations,weather`` (tens of objects). The GP element
blob is fetched at most once per 2 hours per group and cached; positions
are re-propagated on every request. Falls back to the last good blob on a
CelesTrak 403 / stale response, and to SatNOGS TLE only when the cache is
empty. Unknown groups 400.
"""
try:
group_list = parse_groups(groups if groups is not None else ",".join(DEFAULT_GROUPS))
except ValueError as exc:
raise HTTPException(400, str(exc)) from exc
if bbox:
_parse_bbox_query(bbox)
try:
payload = await fetch_satellites(group_list, bbox=bbox, limit=limit)
except ValueError as exc:
raise HTTPException(422, str(exc)) from exc
except Exception as exc:
_upstream_or_502(exc, "satellites")
return overlay_json(payload, 30)
@app.get("/api/map/times")
async def map_layer_times(
layer: str = Query(..., description="GIBS layer identifier, e.g. VIIRS_SNPP_CorrectedReflectance_TrueColor"),