You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement Phase 1 of the vector-layer projection plan so Core can represent CRS values and track layer/map projection state.
Context and design
Adds immutable mwg::Projection with EPSG-first identity, WKT/PROJ4 support, autodetection, and stateless transforms.
Replaces VectorLayer::ProjectionWkt() with VectorLayer::Projection().
Adopts the first known layer CRS in Map and preserves it across remove/clear until explicitly changed.
Validation
CMake Debug x64 and MSBuild Debug x64 built successfully. CTest passed all 524 non-interactive cases; the opt-in real embankments dataset resolved to EPSG:28992. README and Core architecture/porting docs were updated. No project-memory change was needed because the verified decisions are captured in authoritative documentation.
The reason will be displayed to describe this comment to others. Learn more.
Independent review: recommend addressing the findings below before merging. CI was still in progress at review time. Final decision is with the human reviewer.
The reason will be displayed to describe this comment to others. Learn more.
Severity: Major | Confidence: High
Issue:Epsg() accepts numeric IDs from any authority and falls back to the nested GEOGCS ID. GDAL's AutoIdentifyEPSG() can populate that nested ID even when it cannot identify the projected CRS; one example is a custom Lambert Conformal Conic on a base WGS 84 CRS tagged EPSG:4326.
Impact: The projected CRS can report 4326 and IsSame(Projection::FromEpsg(4326)) then returns true for coordinates in metres versus degrees. A root ESRI or private numeric identifier can likewise be presented as an EPSG code.
Fix: Read the authority name and code only from the full CRS, require the EPSG authority, and continue to full-CRS FindMatches when no EPSG ID is available. Apply the same authority check to matches. Add cases with an identified base CRS and a non-EPSG root ID.
The reason will be displayed to describe this comment to others. Learn more.
Severity: Major | Confidence: High
Issue: After OGR has reported that the definitions differ, a matching CRS name or projection method still makes IsSame() return true. For example, two custom Transverse Mercator CRSs with different central meridians or false eastings can share a method and have no EPSG IDs.
Impact: A host using this predicate to decide whether to transform a layer can leave its coordinates untransformed and silently place it in the wrong location.
Fix: Do not use shared names or methods as sufficient evidence of equivalence. If aliases must be accepted, normalize the definitions and then compare the datum, axes, units, and conversion parameters. Add a negative test for two unidentified definitions with the same method and different parameters.
The reason will be displayed to describe this comment to others. Learn more.
Severity: Major | Confidence: High
Issue: The GeoJSON branch treats the absence of crs as unknown, but RFC 7946 section 4 defines WGS 84 longitude/latitude and removed the crs member. GDAL 3.12.4 already supplies the default CRS. The extra probe also reopens and scans the entire file in this ordinary case; async ActiveX loading reaches it both in the worker's candidate map and again in the UI-thread commit.
Impact: Standard GeoJSON fails to seed the map with its known CRS, and loading a large local or VSI GeoJSON can block the control thread even after background preparation finishes.
Fix: Use the driver-provided GeoJSON SRS without reopening the source. Assert that an RFC 7946 fixture reports WGS 84, and use a format that can genuinely omit its CRS for the unknown-CRS test.
The reason will be displayed to describe this comment to others. Learn more.
Severity: Major | Confidence: High
Issue: A non-null OGR SRS does not always mean the source defines a CRS. GDAL 3.12.4 returns synthetic SRS objects for the GeoPackage reserved IDs 0 (undefined geographic) and -1 (undefined Cartesian). Those reach projection construction here, unlike the GDAL-specific undefined SRS used by the new null-CRS fixture, which the driver returns as null.
Impact: An otherwise valid GeoPackage with a standard undefined SRS is treated as having a known CRS, blocking the map from adopting the first genuinely known CRS that follows it.
Fix: Recognize the GeoPackage undefined SRS sentinels and return an empty projection for them. Exercise standard IDs 0 and -1 in dataset and map adoption tests.
The reason will be displayed to describe this comment to others. Learn more.
Severity: Major | Confidence: High
Issue: Converting the layer's SRS to WKT and reparsing it drops its coordinate epoch. GDAL's GeoPackage reader sets the epoch from the epoch column on the SRS object; exportToWkt() serializes the CRS definition, not that per-dataset epoch. OGR's transformation initialization reads the epoch from the SRS object.
Impact: A dynamic-CRS vector layer can be transformed at the wrong epoch even though the source supplies the correct one.
Fix: Add an internal path that clones the driver's OGRSpatialReference directly into the projection value, preserving its coordinate epoch without exposing GDAL in public headers. Cover it with an epoch-bearing GeoPackage fixture.
The reason will be displayed to describe this comment to others. Learn more.
Severity: Major | Confidence: High
Issue: Projection adoption is committed in Map::AddLayer() before MapView::AddLayer() can fail while fitting the extent. Its catch block rolls back by calling RemoveLayer(), which now intentionally retains the projection. The ActiveX load paths use the same remove-only rollback after a fit failure.
Impact: Adding the first known-CRS layer can fail and leave the map with no layers but with the rejected layer's CRS. A subsequent successful add then cannot adopt its own CRS.
Fix: Include CRS adoption in the layer-load transaction: defer adoption until fit/commit succeeds, or restore the previous projection in rollback paths. Test a failed initial fit followed by a successful add in a different CRS.
The reason will be displayed to describe this comment to others. Learn more.
Not changed: a transactionally correct fix requires coordinated rollback changes in MapView and/or ActiveX, which are outside the explicitly approved comment-file/test scope; confirmation is required.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Critical flaws in CRS identification and equivalence checks can incorrectly treat distinct coordinate systems as compatible, making coordinate-compatibility decisions unsafe.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Unresolved CRS-handling defects can retain a rejected layer’s projection, incorrectly treat distinct CRSs as equivalent or empty, and corrupt or lose coordinate epochs during WKT import/export.
Restore the prior projection when adding a layer fails
src/MapWinGIS.Core/src/map/Map.cpp:132
If the initial FitToMap() throws, MapView::AddLayer() removes the new layer but leaves its newly adopted projection behind. The failed load can therefore leave an empty map with the rejected layer's CRS, preventing the next successful layer from supplying its own. Save and restore the previous projection in the rollback at src/MapWinGIS.Core/src/map/MapView.cpp:162-166, while preserving projection persistence for ordinary layer removal.
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
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.
Motivation
Implement Phase 1 of the vector-layer projection plan so Core can represent CRS values and track layer/map projection state.
Context and design
mwg::Projectionwith EPSG-first identity, WKT/PROJ4 support, autodetection, and stateless transforms.VectorLayer::ProjectionWkt()withVectorLayer::Projection().Mapand preserves it across remove/clear until explicitly changed.Validation
CMake Debug x64 and MSBuild Debug x64 built successfully. CTest passed all 524 non-interactive cases; the opt-in real embankments dataset resolved to EPSG:28992. README and Core architecture/porting docs were updated. No project-memory change was needed because the verified decisions are captured in authoritative documentation.