Skip to content

Compare two map layers, and two dates, side by side - #336

Open
sandesh-sp wants to merge 4 commits into
developmentfrom
feat/compare-tool-core
Open

Compare two map layers, and two dates, side by side#336
sandesh-sp wants to merge 4 commits into
developmentfrom
feat/compare-tool-core

Conversation

@sandesh-sp

Copy link
Copy Markdown
Collaborator

Purpose

Adds a two-sided comparison mode to the map so a user can hold two layer sets — or the same layers at two different dates — against each other in one viewport.

Two layouts share a single draggable divider:

  • swipe — one camera, one basemap. Both sides draw the same view and the divider wipes between them, so a place is seen under one layer or the other.
  • sideBySide — two cameras locked to the same centre and zoom, each with its own basemap, in panes that meet at the divider without overlapping. A place is seen under both layers at once, once per pane.

Either side can be pinned to its own ISO instant. MapComparison turns that instant into per-layer prop overrides and hands them to the engine; the engine applies what it is given to that side's layer clones and derives nothing itself. A side left unpinned follows the global timeline like any other layer.

Everything is driven through the mmgisAPI event bus — no plugin code is hardcoded in the core, and the engine surface is optional methods on IMapEngine, so an engine that does not implement them degrades to a warning rather than a crash.

Proposed Changes

  • [ADD] MapComparison controller — owns the divider DOM, the layout, the divider position, and each side's layers/date.
  • [ADD] comparisonTimePins.ts — turns a per-side date into the layer prop overrides that redraw that side at that instant.
  • [ADD] sideBySide layout in DeckGLAdapter: a second deck instance with its own basemap, cameras locked to the same centre/zoom, panes clipped to meet at the divider.
  • [ADD] mmgisAPI requests map:comparison:enable / disable / setLeftSide / setRightSide / setLayout / setDividerPosition / getState, and events map:comparison:dividerMoved / layoutChanged.
  • [ADD] setComparisonLayout / getComparisonLayout and the layout, leftLayerProps, rightLayerProps fields on ComparisonConfig in IMapEngine.
  • [ADD] Bearing and pitch accessors on DeckGLAdapter, needed to keep the two side-by-side cameras in lockstep.
  • [ADD] 6 unit spec files covering the layout switch, date pinning, divider behaviour, and the deck.gl prop/side-by-side plumbing.
  • [CHANGE] vitest.config.ts aliases PDFViewer to a stub — it holds JSX in a .js file, which Vite's default .js loader will not parse, and anything reaching Layers_ pulls it in transitively.

Issues

  • None linked.

Testing

Full unit suite on macOS (Darwin 25.5.0), Node 20:

$ npx vitest run
 Test Files  98 passed (98)
      Tests  1472 passed (1472)
   Duration  11.36s

Of those, 6 files / ~90 tests are new here and cover this feature directly: mapComparisonLayout, mapComparisonDates, comparisonTimePins, deckGLSideBySide, deckGLComparisonProps.

Still worth a live smoke test on a real mission config before merge — dragging the divider in both layouts, and confirming a date-pinned side redraws against tiles for that date.

Comparison mode gains a second layout: 'sideBySide' draws two panes that
meet at the divider, each with its own camera locked to the same centre
and zoom and its own basemap, alongside the existing 'swipe' wipe over a
single view.

Each side can also be pinned to its own date. MapComparison turns a
side's ISO instant into per-layer prop overrides and hands them to the
engine, which applies them to that side's layer clones without deriving
anything itself.

Exposed through the mmgisAPI bus as 'map:comparison:setLayout' and the
'layout'/'leftDate'/'rightDate' fields on enable.
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