Skip to content

MapWinGIS6 — Map Model and Basic Navigation - #37

Merged
pmeems merged 2 commits into
developmentfrom
phase-3-multi-layer-rendering
Oct 31, 2026
Merged

pmeems merged 2 commits into
developmentfrom
phase-3-multi-layer-rendering

Conversation

@pmeems

@pmeems pmeems commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Phase 3 of the Map Model and Basic Navigation plan: multi-layer rendering.

Stacked on #35 (Phase 2, viewport), which is stacked on #34 (Phase 1, map model). Merge those first.

Motivation

Before this change the control kept one dataset, one render scene, and its own extent-fitting ViewTransform. Two layers could not be shown together, and the view state lived in ActiveX instead of in Core.

What changes

  • mwg::MapView (Core). It owns the Map, the one Viewport that all layers are drawn through, and the render scene. It is now the only map and view state: the control has no extent or transform of its own.
  • rendering::CreateMapRenderScene (Core). It builds an owned snapshot of all visible layers, bottom layer first. Each layer is converted separately. Hidden layers, empty layers, and layers that fail (for example, non-polygon layers) are listed in skippedLayers and do not block the others.
  • Backends take the scene plus a Viewport. ViewTransform is now just a per-frame copy of the viewport, using the same arithmetic as Viewport::MapToScreen. GDI checks each layer before drawing it, skips a layer it cannot draw, and reports it through GetFailedLayers and RenderingStatus. OpenGL still renders the whole frame or falls back to GDI.
  • Redraws. Map changes go through MapView, which marks the scene stale. Each mutator returns whether the frame changed, and the control calls FireViewChange only when it did. A resize keeps the center and resolution and does not rebuild the scene.
  • Resizing. The viewport follows WM_SIZE, and also the drawn bounds, because windowless hosts never send WM_SIZE. Sizes are clamped to Viewport::kMaxDimension. A fit requested before the control has a size, or while it is minimized, happens on the first resize that gives it a size.
  • COM behavior change. LoadVectorDataset now adds the dataset's first layer on top of the map instead of replacing what is loaded. FeatureCount is the total over all layers. Until navigation is exposed (Phase 5), every load fits the view to the whole map. Non-polygon layers are still rejected at load time.

Design decisions

  • MapView lives in Core rather than in the control, so the Phase 4 navigation code can build on one tested owner of the map and viewport (plan decisions 1 and 4).
  • The render scene holds no view state, so view changes never re-read data.
  • One backend draws the whole frame, so every layer gets the same transform and the same pixel conventions.

Testing

  • Debug|x64 builds with 0 warnings and 0 errors.
  • 255 of 258 native tests pass; the other 3 are the usual opt-in skips. New tests: MapRenderSceneTests, MapViewTests, and multi-layer GDI/OpenGL pixel tests.
  • The opt-in rendering baseline passes.
  • The registration-free C# host passes all 14 checks.

Remaining limitations are listed in the plan under Phase 3. The main ones: there are no COM methods to remove or hide layers yet, the scene is rebuilt for all layers on any map change, and there is no clipping, so GDI skips a layer whose device coordinates go out of range at deep zoom.

@pmeems
pmeems added this pull request to stack #36 October 31, 2026 11:45
@pmeems
pmeems force-pushed the phase-3-multi-layer-rendering branch from 9e9b90b to efed8b2 Compare October 31, 2026 11:52
Base automatically changed from phase-2-viewport-and-coordinate-transformations to development October 31, 2026 15: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>
@pmeems
pmeems force-pushed the phase-3-multi-layer-rendering branch from efed8b2 to 0b0c8ff Compare October 31, 2026 15:44
Validate loads before changing the view, cache feature totals, expose ClearLayers, and isolate drawing target sizes and layer errors. Add regression tests and update documentation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@pmeems
pmeems merged commit a941665 into development Oct 31, 2026
1 check passed
@pmeems
pmeems deleted the phase-3-multi-layer-rendering branch October 31, 2026 16:15
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