HexaWetter v1.3.0: Add precipitation map feature, update README, and enhance UI elements
This commit is contained in:
@@ -22,6 +22,9 @@ from app.config import (
|
||||
DEFAULT_LON,
|
||||
DEFAULT_PLACE,
|
||||
DWD_WMS_URL,
|
||||
PRECIP_MAP_HOURS_DEFAULT,
|
||||
PRECIP_MAP_SPAN_DEG,
|
||||
PRECIP_MAP_STEP_DEG,
|
||||
RADAR_PRODUCT,
|
||||
RATE_LIMIT_PER_MINUTE,
|
||||
RAW_RADAR_DIR,
|
||||
@@ -40,9 +43,10 @@ from app.security import (
|
||||
validate_security_config,
|
||||
verify_request_api_key,
|
||||
)
|
||||
from app.services.precipitation_map import get_precipitation_map
|
||||
from app.services.warnings import fetch_warnings_for_location
|
||||
from app.services.weather import get_forecast, get_observations
|
||||
from app.services.wms import fetch_wms_time_steps
|
||||
from app.services.wms import fetch_wms_time_steps, fetch_wms_time_steps_quick
|
||||
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
@@ -200,6 +204,22 @@ async def forecast(
|
||||
raise HTTPException(status_code=502, detail=f"Forecast source unavailable: {exc}") from exc
|
||||
|
||||
|
||||
@app.get("/api/forecast/precipitation-map")
|
||||
async def forecast_precipitation_map(
|
||||
lat: float = Query(DEFAULT_LAT, ge=-90, le=90),
|
||||
lon: float = Query(DEFAULT_LON, ge=-180, le=180),
|
||||
hours: int = Query(PRECIP_MAP_HOURS_DEFAULT, ge=6, le=24),
|
||||
span_deg: float = Query(PRECIP_MAP_SPAN_DEG, ge=1.5, le=6.0),
|
||||
step_deg: float = Query(PRECIP_MAP_STEP_DEG, ge=0.15, le=0.5),
|
||||
) -> dict[str, Any]:
|
||||
try:
|
||||
return await get_precipitation_map(lat, lon, hours=hours, span_deg=span_deg, step_deg=step_deg)
|
||||
except httpx.HTTPError as exc:
|
||||
raise HTTPException(status_code=502, detail=f"Precipitation map unavailable: {exc}") from exc
|
||||
except Exception as exc:
|
||||
raise HTTPException(status_code=502, detail=f"Precipitation map error: {exc}") from exc
|
||||
|
||||
|
||||
@app.get("/api/observations")
|
||||
async def observations(
|
||||
lat: float = Query(DEFAULT_LAT, ge=-90, le=90),
|
||||
@@ -291,8 +311,11 @@ async def radar_wms() -> dict[str, Any]:
|
||||
async def radar_wms_times(
|
||||
layer: str = Query("dwd:Niederschlagsradar"),
|
||||
minutes: int = Query(120, ge=15, le=180),
|
||||
quick: bool = Query(False),
|
||||
) -> dict[str, Any]:
|
||||
try:
|
||||
if quick:
|
||||
return await fetch_wms_time_steps_quick(layer, minutes=minutes)
|
||||
return await fetch_wms_time_steps(layer, minutes=minutes)
|
||||
except Exception as exc:
|
||||
raise HTTPException(status_code=502, detail=f"WMS time dimension unavailable: {exc}") from exc
|
||||
|
||||
Reference in New Issue
Block a user