Add a default-off Layers row that fetches GET /api/map/sentinel1?bbox= only when enabled, then L.tileLayer(tileUrl) at opacity 0.8. HUD hints for 404/429/502; moveend refetch while on. Same-origin tileUrl as-is.
41 lines
1.5 KiB
Python
41 lines
1.5 KiB
Python
"""Sentinel-1 SAR layer: Leaflet toggle contract (no browser STAC/TiTiler)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parent.parent
|
|
HTML = (ROOT / "app/static/index.html").read_text()
|
|
|
|
|
|
def test_sentinel1_toggle_default_off():
|
|
assert 'id="lp-sentinel-on"' in HTML
|
|
assert 'id="sentinel-1-sar"' in HTML
|
|
assert "Sentinel-1 SAR (Cloud-Penetrating)" in HTML
|
|
on = HTML.split('id="lp-sentinel-on"', 1)[1].split(">", 1)[0]
|
|
assert "checked" not in on
|
|
|
|
|
|
def test_sentinel1_fetches_backend_not_planetary_computer():
|
|
assert "/api/map/sentinel1?bbox=" in HTML
|
|
assert "titiler.xyz" not in HTML
|
|
js = HTML.split("async function loadSentinel1", 1)[1].split("function loadThermal", 1)[0]
|
|
assert "planetarycomputer" not in js.lower()
|
|
assert "stac" not in js.lower()
|
|
|
|
|
|
def test_sentinel1_hud_errors_not_alert():
|
|
js = HTML.split("async function loadSentinel1", 1)[1].split("function loadThermal", 1)[0]
|
|
assert "alert(" not in js
|
|
assert "No Sentinel-1 imagery for this view in the last 7 days." in js
|
|
assert "retry later" in js
|
|
assert "opacity: sentinelOpacity" in js
|
|
assert "maxZoom: 18" in js
|
|
assert "L.tileLayer(body.tileUrl" in js
|
|
|
|
|
|
def test_sentinel1_not_fetched_on_init_unless_on():
|
|
init = HTML.split("function initMap", 1)[1].split("function readMapPrefs", 1)[0]
|
|
assert "loadSentinel1()" not in init
|
|
refresh = HTML.split("function refreshLiveOverlays", 1)[1].split("function addExtraAttrib", 1)[0]
|
|
assert "if (sentinelOn) loadSentinel1();" in refresh
|