Skip to content

Share: exports and links show a comparison the way the screen does - #618

Draft
BhattaraiSijan wants to merge 5 commits into
developmentfrom
feat/share-comparison-mode
Draft

BhattaraiSijan wants to merge 5 commits into
developmentfrom
feat/share-comparison-mode

Conversation

@BhattaraiSijan

Copy link
Copy Markdown
Collaborator

Closes #614, #615, #616. Part of #613.

Summary

With comparison on, the Share button's three actions now produce what the screen shows. Before, all three succeeded and were silently wrong: the PNG/PDF held the bare basemap with no data, the legend band listed every switched-on layer at the global date, and the link opened a plain map with both sides' layers stacked.

  • PNG and PDF capture both sides (Share: PNG and PDF exports capture both sides of a comparison, the divider and the captions #614). A comparison is several WebGL surfaces, each readable only inside its own render step: the primary map, two clipped follower canvases (swipe) or two panes with their own basemap (side-by-side). The capture draws each surface's strip into one output canvas in order, awaiting each render, then paints the divider rule, its handle disc and the two captions, which the screen draws as DOM. A pure module next to the adapter owns the strip arithmetic and the chrome so it is tested without WebGL. Comparison off is the untouched path.
  • The legend band follows the sides (Share: the export legend band lists each side's layers with the date that side is pinned to #615). With comparison on, rows come from each side's layer ids rather than the layer panel's switches. Two different layers (layers mode) give one row per side under its caption, dated as that side is. The same layers on both sides (dates mode) give each layer once, with a date line naming both sides' dates, and No data at <date> for a side with nothing at its date. A side's pinned date is dated from the pin, not from the window core last requested for the layer.
  • The link carries the comparison (Share: the copied link reopens the comparison, sides, dates and divider included #616). The Comparison tool's getUrlString writes mode, layout, the two layers, the compare date, the swap and the divider position as a |-separated entry (the tools= list is split on commas). On load, once mission load registers the tool handlers, the tool reads its entry back over a new tool:getUrlState request, seeds its panel, asks core to show the plugin, and applies the divider after the enable settles, since enabling resets it. A layer the mission no longer draws leaves its side empty with a console warning.
  • Modern tools can write into links at all. The link's tools= entry was assembled from a list only the classic layout's init fills, so no modern tool could contribute. The modern controller now adds a tool to that list when it loads it and removes it when it destroys it. This is the one change outside the comparison code.

Not in this PR

  • The scale bar and north arrow in exports live on feat/scale-bar; comparison exports carry them once both branches are on development.
  • A visible notice in the panel when a link names a missing layer; today it is a console warning and an empty side.
  • Leaflet, which has no comparison mode.

Test plan

  • npx vitest run tests/unit src/essence: 218 files, 3684 tests pass
  • Air4US, layers mode, swipe at 50%: PNG and PDF show both layers, the rule with its disc, both captions, and a band with one row per side
  • Drag the divider to ~30% and export again; switch to side-by-side and export again
  • Dates mode: the band has one row per layer naming both dates; a date outside a layer's coverage reads "No data at …"
  • Comparison off: exports and link identical to before
  • Copy link during a swipe at ~30%, open in a new tab: the panel opens with the same layers, layout and divider
  • Same for dates mode and side-by-side
  • A link copied with comparison off opens as today

🤖 Generated with Claude Code

@BhattaraiSijan
BhattaraiSijan marked this pull request as draft November 5, 2026 20:43

This branch has not been deployed

No deployments
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.

Share: PNG and PDF exports capture both sides of a comparison, the divider and the captions

1 participant