Hydro Stations & Forest Fire Danger

This page documents how stations-by-river-fire.html combines live FOEN hydro data with FOEN forest fire danger to show, for each measuring station, both river conditions and the current forest fire danger.

Back to the stations & fire danger view

Data sources

Hydro stations and discharge

Forest fire danger (regions)

Region geometries (for spatial matching)

Client‑side logic

All logic runs in the browser; there is no server‑side code.

  1. Fetch hydro stations
    • Posts the hydro SPARQL query to HYDRO_ENDPOINT.
    • Parses the JSON SPARQL results into station objects.
    • Extracts and parses station_geom_wkt into lon/lat using a small WKT POINT parser.
  2. Fetch forest fire regions
    • Posts the fire‑regions SPARQL query to FIRE_ENDPOINT.
    • For each region, keeps: regionId, regionName, levelId (1–5), cantonName, cantonAbbr, and validFrom.
  3. Fetch region geometries
    • For each region ID, requests GeoJSON from the MapServer.
    • Requests are parallelised with a small concurrency limit (default 8) to avoid overloading the service.
    • Stores a map regionId → { geometry, bbox }.
  4. Spatial join: station → fire region
    • For each station with valid lon/lat:
      • Builds a point [lon, lat].
      • Iterates through regions:
        • If a region has a bbox, first checks if the point lies inside that box.
        • Runs a point‑in‑polygon test against the MultiPolygon geometry:
        • Uses a standard ray‑casting algorithm for each linear ring.
        • Outer ring must contain the point; inner rings (holes) must not.
      • On the first match, attaches a fire object to the station with regionId, regionName, levelId, cantonName, cantonAbbr, and validFrom.
  5. Dive suitability status
    • Reuses the same logic as stations-by-river.html:
    • Computes a status (ok, caution, nogo, unknown) from discharge, okMax, and nogoMin.
    • Renders a coloured status dot with an explanatory tooltip.

Rendering and UI

Disclaimers