Add NASA GIBS satellite basemap world map tab (Leaflet)
Some checks failed
build-and-deploy / build (push) Failing after 5s
Some checks failed
build-and-deploy / build (push) Failing after 5s
Interactive world map panel for the dashboard: - Vendored Leaflet 1.9.4 under app/static/vendor/leaflet/ (served via new /static mount on the FastAPI app) - New Map tab: GIBS WMTS raster basemap (BlueMarble_ShadedRelief_Bathymetry, VIIRS/MODIS/Aqua CorrectedReflectance_TrueColor, VIIRS_DayNightBand), layer picker + UTC date selector (Latest/-7d/-30d quick picks) - /api/map/layers: curated GIBS catalog (tms, format, has_time, max_zoom) - /api/map/times: per-layer date windows from GIBS Domains XML (6h cache, graceful 502 on GIBS hiccup; static layers 422) - Fire hotspots (existing /api/fires) + open cameras (/api/cameras) as toggleable bbox-scoped overlays; dark UI matching dashboard theme
This commit is contained in:
parent
91f436390b
commit
3aa6f265bb
10 changed files with 1142 additions and 2 deletions
47
app/main.py
47
app/main.py
|
|
@ -21,6 +21,7 @@ from uuid import UUID
|
|||
import structlog
|
||||
from fastapi import FastAPI, HTTPException, Query
|
||||
from fastapi.responses import FileResponse, HTMLResponse
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
from sqlalchemy import and_, func, select, text
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
|
|
@ -841,6 +842,52 @@ async def index():
|
|||
return FileResponse(str(STATIC_DIR / "index.html"))
|
||||
|
||||
|
||||
# ── NASA GIBS basemap map tab ─────────────────────────────────────────────
|
||||
|
||||
@app.get("/api/map/layers")
|
||||
async def map_layers():
|
||||
"""Curated NASA GIBS raster basemap layers for the map tab.
|
||||
|
||||
Each entry has everything the browser needs to render the WMTS tiles:
|
||||
id — GIBS layer identifier (used in the tile URL path)
|
||||
title — human-readable display name
|
||||
tms — GIBS tile matrix set (GoogleMapsCompatible_LevelN)
|
||||
format — tile image extension (jpeg|png)
|
||||
has_time — whether the layer has a Time dimension (=> date selector)
|
||||
max_zoom — highest native zoom served by that tile matrix set
|
||||
"""
|
||||
from gibs_map import MAP_LAYERS
|
||||
return {"layers": MAP_LAYERS}
|
||||
|
||||
|
||||
@app.get("/api/map/times")
|
||||
async def map_layer_times(
|
||||
layer: str = Query(..., description="GIBS layer identifier, e.g. VIIRS_SNPP_CorrectedReflectance_TrueColor"),
|
||||
):
|
||||
"""Available date windows for a time-aware GIBS layer.
|
||||
|
||||
Parsed from the layer's Domains XML (GIBS serves nearest-time tiles even
|
||||
for dates slightly outside a window, but we surface the real ranges so
|
||||
the UI can clamp the picker and flag out-of-range picks).
|
||||
"""
|
||||
from gibs_map import _LAYER_BY_ID, fetch_layer_domain
|
||||
|
||||
meta = _LAYER_BY_ID.get(layer)
|
||||
if not meta:
|
||||
raise HTTPException(404, f"Unknown GIBS layer: {layer}")
|
||||
if not meta["has_time"]:
|
||||
raise HTTPException(422, f"Layer '{layer}' is static (no Time dimension)")
|
||||
try:
|
||||
domain = await fetch_layer_domain(meta["id"], meta["tms"])
|
||||
except Exception as exc: # network / GIBS hiccup → degrade gracefully
|
||||
logger.warning("gibs_domain_fetch_failed", layer=layer, error=str(exc))
|
||||
raise HTTPException(502, f"GIBS time domain unavailable: {exc}")
|
||||
return {"layer": layer, **domain}
|
||||
|
||||
|
||||
app.mount("/static", StaticFiles(directory=str(STATIC_DIR)), name="static")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import uvicorn
|
||||
uvicorn.run(app, host="0.0.0.0", port=8000)
|
||||
|
|
|
|||
Loading…
Reference in a new issue