Repository navigation
MapWinGIS6 — Map Model and Basic Navigation - #35
Merged
pmeems merged 1 commit intoOct 31, 2026
Merged
Conversation
Base automatically changed from
phase-1-map-model-and-layer-collection
to
development
October 31, 2026 11:52
Introduce mwg::Viewport: a pixel size plus a center/resolution view that converts between map and screen coordinates, fits extents with padding while preserving aspect ratio, and clamps to documented limits. Add ToPixel for the single rounding step, viewport tests, and architecture docs. Co-authored-by: Junie <junie@jetbrains.com>
pmeems
force-pushed
the
phase-2-viewport-and-coordinate-transformations
branch
from
October 31, 2026 11:52
e8ee36b to
54a55c9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 2 of the Map Model and Basic Navigation plan. Stacked on #34.
Motivation
Multi-layer rendering (Phase 3) and navigation (Phases 4 and 5) need one reusable map-to-screen transformation in Core. Today the only transformation is
activex::ViewTransform, which lives in the OCX and is rebuilt from the dataset extent on every draw.What changes
mwg::Viewport(mapwingis/map/Viewport.h) holds a pixel size plus a view (center and map units per pixel). It providesMapToScreen,ScreenToMap,VisibleExtent,FitExtent(extent, padding),SetView, andSetSize.MapPoint,ScreenPoint,PixelPointandToPixel, the only place where screen coordinates are rounded.ViewportTests.cppwith 36 tests. No window and no ActiveX.docs/ARCHITECTURE.md.Key design decisions
(i, j)covers[i, i+1) x [j, j+1), and Y points down.FitExtentmaps the extent edges to the centers of the outermost pixels, so rounding never pushes boundary geometry out of the viewport.InvalidArgument. Non-finite points or overflowing results returnstd::nullopt. Invalid extents and zero-sized viewports makeFitExtentreturnfalsewithout changing the view. A zero-sized viewport keeps its view.[1e-10 × max(1, |center|), 1e9], and size to 65536 px. Because the minimum resolution scales with the center, a pixel always spans many representable doubles.Extent,Viewportis small and copyable, so renderers and navigation code can take snapshots of it.Map. Callers fit it toMap::GetExtent().Dependencies / follow-up
phase-1-map-model-and-layer-collection(MapWinGIS6 — Map Model and Basic Navigation #34).ViewTransformfor now. Replacing it withViewportand choosing the owner of the map/viewport pair is Phase 3.Build: Debug|x64, 0 warnings. Tests: 226 passed, 3 skipped (opt-in suites).