Skip to content

MapWinGIS6 — Map Model and Basic Navigation - #38

Merged
pmeems merged 4 commits into
developmentfrom
phase-4-programmatic-navigation
Oct 31, 2026
Merged

pmeems merged 4 commits into
developmentfrom
phase-4-programmatic-navigation

Conversation

@pmeems

@pmeems pmeems commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Phase 4 of the map model and basic navigation plan: programmatic navigation in Core. Stacked on #37 (Phase 3).

Motivation

Phase 5 needs mouse-wheel zoom, drag-to-pan, and zoom-to-map/layer in the ActiveX control. This PR puts navigation math in Core, where tests need no window, COM, or renderer. Hosts use the return values to decide whether to redraw.

Changes

  • Viewport primitives: Pan(dx, dy) takes a map-unit delta. Zoom(factor) divides the resolution around the center, and ZoomOut(factor) multiplies it directly without an inexact reciprocal. ZoomAt(anchor, factor) keeps the map coordinate under a screen point in place unless the limits intervene.
  • MapView navigation builds on the Phase 3 FitToMap. New calls are ZoomToLayer(LayerId, padding), ZoomIn, ZoomOut, ZoomAt, and Pan. The center-zoom calls require a factor above 1 and default to kDefaultZoomFactor = 2.
  • Pending fits support both map and layer requests. A new fit replaces the previous request. A missing layer or an invalid extent cancels it. Navigation that changes the view cancels it, but navigation that returns false preserves it.

Design decisions

Zoom-to-map uses only visible layers. Zoom-to-layer also fits a hidden layer because the caller names it. Empty maps, missing layers, and layers without a valid extent return false and keep the view. Non-finite input and invalid factors or padding throw InvalidArgument.

Resize can propagate an extent-read error while completing a pending fit. The new size stays applied, the pending fit is discarded, and the center and resolution stay unchanged. The host must redraw after this error. The public header and architecture documentation describe this contract.

ZoomAt clamps the requested resolution against the old center, then clamps it again against the new center. Moving the center can raise the minimum resolution and move the anchored coordinate, even without center clamping. This limit behavior is documented and tested.

Pan takes map units and does not depend on input events. Phase 5 converts pixel drag deltas itself. ZoomAt requires a valid viewport, while pan and center zoom only require a view.

Tests

The updated Debug x64 solution builds with 0 warnings. The native suite runs 304 tests: 301 pass and 3 opt-in tests skip. The skips are the network GDAL test, registered ActiveX hosting check, and rendering performance baseline.

Navigation tests cover map and layer fitting, padding, hidden and empty layers, missing layers, factors, centers, anchors, pan deltas, and limits. The review follow-up adds 10 tests and extends existing cases. Pending fits now have coverage for replacement in both directions, cancellation by pan and center zoom, and cancellation by missing or empty layers.

Unchanged navigation at a resolution limit preserves the pending fit. ZoomAt also preserves it on a zero-sized viewport because that call cannot change the view. A changing ZoomAt cannot coexist with a pending fit: fits only wait when the viewport has no size. The tests cover this reachable state rather than changing the viewport-validity contract.

Additional tests cover anchor movement when the new center raises the minimum resolution and direct zoom-out multiplication, including overflow and resolution limits. README.md, docs/ARCHITECTURE.md, and docs/TESTING.md describe the current behavior.

Known limits

COM and mouse navigation remain Phase 5 work. There is no clipping, so deep zoom can push a layer past the GDI coordinate range. There are no snapped scales or navigation history.

@pmeems
pmeems added this pull request to stack #36 October 31, 2026 11:45
@pmeems
pmeems force-pushed the phase-4-programmatic-navigation branch from 32e0968 to 32d3aa4 Compare October 31, 2026 11:52
pmeems and others added 2 commits October 31, 2026 16:44
Add mwg::MapView as the single owner of the map, its viewport, and its render scene, and CreateMapRenderScene to build an owned multi-layer scene with per-layer skip reasons. GDI and OpenGL backends now draw every layer through the same Viewport; GDI skips only layers it cannot draw. The ActiveX control delegates loading, resizing, and redraw decisions to MapView and no longer keeps its own extent or transform. LoadVectorDataset now adds a layer on top of the map.

Co-authored-by: Junie <junie@jetbrains.com>
Add Pan, Zoom, and anchored ZoomAt to Viewport, and ZoomToLayer, ZoomIn, ZoomOut, ZoomAt, and Pan to MapView on top of the existing FitToMap. Every operation returns whether the view changed, clamps to the viewport limits, and handles empty maps, missing layers, and invalid extents without changing the view. A pending fit can target the map or one layer, and navigation that changes the view cancels it.

Co-authored-by: Junie <junie@jetbrains.com>
@pmeems
pmeems force-pushed the phase-4-programmatic-navigation branch from 32d3aa4 to 57186bf Compare October 31, 2026 15:44
Base automatically changed from phase-3-multi-layer-rendering to development October 31, 2026 16:15
pmeems and others added 2 commits October 31, 2026 17:20
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Cancel deferred fits for missing layers, document resize error state and anchored zoom limits, and multiply zoom-out resolution directly.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@pmeems
pmeems merged commit a98fa44 into development Oct 31, 2026
1 check passed
@pmeems
pmeems deleted the phase-4-programmatic-navigation branch October 31, 2026 17:04
@pmeems
pmeems restored the phase-4-programmatic-navigation branch October 31, 2026 17:26
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