Skip to content

planner: add the Weather data layer (temperature, rain, night lows) - #2348

Merged
timohueser merged 3 commits into
developfrom
claude/planner-weather-layer
Oct 3, 2026
Merged

timohueser merged 3 commits into
developfrom
claude/planner-weather-layer

Conversation

@timohueser

@timohueser timohueser commented Oct 3, 2026 •

Copy link
Copy Markdown
Owner

Summary

This adds the Weather data layer to the website planner. It follows the owner decisions on #2329 (layers Snow / Weather / Wind, one on the map at a time).

  • Registry: one line in layers/registry.ts on the climate archive. The layer requests nothing while it is off.
  • Map: a switch in the date bar selects Temperature or Rain.
    • Temperature shows the daytime highs of the week. Each pixel blends the four nearest cells. Each cell temperature moves to the pixel height with the lapse rate of that cell and month. The heights come from the DEM tiles that the relief loads.
    • Rain shows the ten-year wet-day share as days of 7 on a smooth scale.
    • Tiles decode once. A change of date or variable only paints the tiles again.
  • Year slider: three rows, High, Low and Rain, with the one-line label above them ("On the route, 14–20 May: highs 12–18 °C · lows 4–9 °C · rain on 3.2 of 7 days").
  • Night lows: a label at each overnight stop (trip day end), for example "Night 5–9 °C". The range is the weekly lows over the years without the lowest and the highest year, at the stop height. The night after day n is the layer date plus n − 1 days.
  • Profile strip: daytime high only. Rain has no strip.
  • Point chart (map callout and strip popover) follows the map variable:
    • Temperature: year × week rows for highs and lows, and the note "Valleys can be colder on clear nights".
    • Rain: a 52-week line of the mean wet days of 7, a band for most years (without the lowest and the highest year) and the layer week marked. The headline is, for example, "14–20 May: rain on about 3 of 7 days (1–5 in most years)". A short note says when the week usually has more or less rain than an average week of the cell.
    • "~9 km grid" is in the source line.

Changes to shared code

  • DataLayer gets one optional method, nights(samples, stops), and an optional strip.label. PlannerApp gives the trip day ends as stops. PlannerMap draws the labels as panel pills beside the day-end pins.
  • climate-source.ts: openClimate(url) keeps one source per archive URL, so Weather and Wind share the decoded tiles. It is the same function as in the Wind PR planner: add the Wind data layer #2349.
  • A map point reads its height from the most detailed decoded DEM tile, or else from the DEM tile of the view zoom. In Rain mode no tile is decoded yet, and the browser cache answers that fetch. A route keeps its profile heights.
  • climate-terrain.ts: tileHeights becomes demPixels plus pixelHeight. The layer caches decoded DEM tiles per DEM tile, so four map tiles share one fetch and one decode.
  • addDays in data-layer.ts, used by the date bar and the night dates.
  • LayerInspect: compact charts with more than one grid use 3 px rows.
  • RainWeeks.svelte: the rain chart, given to the point chart as Chart.extra.
  • pretest:planner gets VITE_PLANNER_CLIMATE_URL, so the journey builds with the layer in the menu. The budget is unchanged.

Verification (BW archive, local preview)

  • 2-day loop Freiburg – St. Märgen – Titisee – Notschrei – Freiburg (101.5 km), checked in May and January, light and dark: switch, map colours, slider rows, night label, strip, point chart, map callout, legend in the layer menu. No runtime console errors.

  • Requests while the layer is off: no climate request. Turning the layer on: 4 range requests on climate.pmtiles (header, directory, overview and detail data). The 6 terrain fetches are the same DEM URLs that the relief loaded. The tile Worker sends immutable caching for them, so the browser cache answers them. The local pmtiles server sends no cache header, so the browser revalidates them locally (304).

  • Paint time: 15 map tiles, mean 3 ms, longest 6 ms per 256 px tile.

  • Dark mode: the temperature stops from 0 to 30 °C are lighter, so May and January stay readable on the dark land colour.

Checks run

  • npx vitest run src/lib/planner src/components/planner: 30 files, 192 tests pass. The new weather.test.ts covers colour mapping, pixel blending and terrain correction, the year rows and label, the rain weeks and both charts, and the night labels.
  • svelte-check: no new findings. The 15 remaining errors are the missing wasm pkg/ builds in untouched files.
  • npm run test:planner: passes. The totals are unchanged from the budget (cloudflare=104).
  • obc suites check, obc prose --check: OK.
  • Not run: the full web suite and the other browser suites. CI runs them.

Public docs changed: no
Requirements: none

🤖 Generated with Claude Code

…lows

The Weather layer reads the climate archive. A switch in the date bar
selects the map: daytime highs, corrected to the terrain height of each
pixel, or the ten-year wet-day share. Both blend the four nearest cells.
The year slider has High, Rain and Low rows. The profile strip shows the
daytime high. The point chart shows the years of highs, lows and rain
against a typical week. A label at each overnight stop shows the night
lows of its week.

DataLayer gets one optional method, nights(), for the overnight labels,
and an optional strip label. The terrain helper caches decoded DEM tiles
per DEM tile, so four map tiles share one fetch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 74e209ba-6fee-4599-89e4-c3ec06429ad8
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

timohueser and others added 2 commits October 4, 2026 00:08
- A map point in Rain mode reads its height from the DEM tile of the
  view zoom, so highs and lows are at the point height.
- openClimate keeps one climate source per archive URL, so Weather and
  Wind share decoded tiles.
- The dark temperature ramp is lighter from 0 to 30 °C.
- The point chart follows the map variable: highs and lows, or rain.
- The rain chart is a 52-week line of the mean wet days of 7, with a
  band for most years and the layer week marked.
- The year slider rows are High, Low, Rain.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MapLibre rounds the zoom for raster sources, so the 512 px relief loads
round(zoom). The point height now reads that tile, which the browser
cache holds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@timohueser
timohueser merged commit 2f1bd43 into develop Oct 3, 2026
28 checks passed
@timohueser
timohueser deleted the claude/planner-weather-layer branch October 3, 2026 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant