Skip to content

fix(crs): EPSG:900913 WKT without a shift reads as PROJ does; a set-aside WGS 84 shift is said - #2961

Merged
pick2510 merged 2 commits into
opengeos:mainfrom
pick2510:terrio-crs-0.3-notes
Nov 25, 2026
Merged

pick2510 merged 2 commits into
opengeos:mainfrom
pick2510:terrio-crs-0.3-notes

Conversation

@pick2510

@pick2510 pick2510 commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #2933, from its review (threads on wkt.rs).

  • EPSG:900913 without a shift. GDAL 1's 900913 WKT without its PROJ4 extension and without a TOWGS84 still read as Web Mercator, because read_root took the code straight away when the file gave no shift. It is now compared with Web Mercator as a shifted one is (places_as at 10°E 45°N), so it reads as Mercator on the WGS 84 ellipsoid. PROJ 9.9.0 (conda-forge, pyproj 3.8.0, network off) puts 6 679 169.4476 m E, 5 621 521.4862 m N at 60°E 45.1923152°N for it, with a shift, a shift of zero or none; the test now covers all three.
  • A WGS 84 code's shift is said. A UTM text on WGS 84 with TOWGS84[1,2,3] reads as EPSG:32631 (as PROJ 9.9.0 transforms it: 3°E 45.1534772°N), and now says so: "the file's own shift to WGS 84 is set aside, as EPSG:32631 has none, as in PROJ". Asserted through read_wkt; a zero shift stays without a note.
  • Stale test comments: "not with another" and a PROJ 9.8.1 citation now name PROJ 9.9.0, re-checked.

Refs #2032 (terrio-crs release)

Round 1: the same rule for a code beside the text (read_wkt_over_code: GeoPackage, File Geodatabase, PDF), shared with read_root (by_code_note). Only 900913 is compared without a shift; a row coded 3857 is still read by its code, and 3857's own text without its extension stays Web Mercator (PROJ 9.9.0 reads it by its name). The change sits in the shared WKT reader, so it reaches every surface that opens these files (desktop, web, CLI, Python, Assistant).

Summary by CodeRabbit

  • Bug Fixes
    • Improved coordinate system detection for Web Mercator text when file-shift information is present or absent, including cases where EPSG:3857 or EPSG:900913 is specified.
    • Clarified reporting when a file shift is specified but no corresponding shift is available in the selected EPSG definition.
    • Corrected handling of EPSG:900913 text with shift information that differs from standard Web Mercator parameters.

…WGS 84 shift is said

GDAL 1's EPSG:900913 text without its PROJ4 extension and without TOWGS84 read as Web Mercator,
21 km off at 45°N from PROJ 9.9.0's ellipsoidal Mercator: the Web Mercator comparison now runs
without a shift too. A file's shift on a code without one (WGS 84's) is set aside with a note.
Stale test comments and a PROJ 9.8.1 citation updated.

Refs opengeos#2032 (terrio-crs release)
@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

WKT reading now uses a shared helper to decide when an EPSG code represents the WKT. It also reports when a nonzero file shift is set aside. Tests cover EPSG:32631 and Web Mercator cases.

Changes: WKT reading

Layer / File(s) Summary
Code selection and shift notices
crates/data/src/raster/wkt.rs
A shared helper selects EPSG codes based on the file shift and whether the WKT matches the code. For EPSG:900913, WKT without a PROJ4 extension is read as parameter-based Mercator; EPSG:3857 remains Web Mercator without the extension. When the selected EPSG definition has no bundled shift, a nonzero file shift is reported as set aside. Tests cover these cases and EPSG:32631.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related issues

Possibly related PRs

  • opengeos/RustGIS#1837: This PR changes handling of Web Mercator codes and set-aside shift notices for WKT with a known code.
  • opengeos/RustGIS#1845: This PR adds notices for WKT shifts that are set aside when reading layers by code.
  • opengeos/RustGIS#1668: This PR reports when reading by EPSG code drops a file-declared shift.

Suggested reviewers: pawelkra, giswqs

Merge Risk: Minimal · up to 57934

WKT reading now selects EPSG codes more consistently and reports when a nonzero file shift is set aside. No merge-blocking risk was found, and tests cover the changed cases.

Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Description check Inconclusive The description is detailed and covers the change: EPSG:900913 text without a shift now compares with Web Mercator, a WGS 84 code's set-aside shift is noted, stale test comments are corrected, and the… Add the template's UI evidence statement, for example 'No visible UI change.', so reviewers see that the UI check was considered. Add a '## Related issue' entry, for example 'Part of #2032' or 'Follow-up to #2933', instead of leaving it onl…
Passed Passed checks: 3 passed

Check name Status Explanation
Title check Passed The title names the main change: EPSG:900913 WKT without a shift is now read as PROJ reads it, and a set-aside WGS 84 shift is now reported. It matches the raw summary and objectives, which describe b…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: EPSG:900913 WKT without a shift is now read as PROJ reads it, and a set-aside WGS 84 shift is now reported. It matches the raw summary and objectives, which describe both behaviors. It is long (94 characters), but it is specific and related to the changeset.

Full details: Description check

Explanation

The description is detailed and covers the change: EPSG:900913 text without a shift now compares with Web Mercator, a WGS 84 code's set-aside shift is noted, stale test comments are corrected, and the round 1 follow-up for read_wkt_over_code is described. It gives PROJ 9.9.0 reference values and names the affected tests. It has no Testing section heading, but it does state the tests and verification method (PROJ 9.9.0 with conda-forge, pyproj 3.8.0, network off). The UI evidence section is missing. The description does not say 'No visible UI change' or include the template's UI evidence line, though the change is in a shared reader and no UI is affected. The Related issue section is absent, but it references #2933 and #2032 in the body.

Resolution

Add the template's UI evidence statement, for example 'No visible UI change.', so reviewers see that the UI check was considered. Add a '## Related issue' entry, for example 'Part of #2032' or 'Follow-up to #2933', instead of leaving it only in the body text. Restructure the content under '## Summary' and '## Testing' headings to match the template. In the Testing section, list the commands used, such as 'cargo xtask ci' or the specific test names, in addition to the PROJ 9.9.0 comparison values.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit reads the WKT line by line
EPSG codes fall into place
A shift gets a note when set aside
Web Mercator keeps its name
The rabbit hops home, pleased with the parse

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 9bfd6020-5e7a-43a5-97f9-477893ff0ef9
Commits

Reviewing files that changed from the base of the PR and between 2e9a605 and 579342b.

Files selected for processing: 1

  • crates/data/src/raster/wkt.rs

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

@github-actions

Copy link
Copy Markdown
Contributor

Code review

PR #2961 is a one-file change to crates/data/src/raster/wkt.rs. It makes EPSG:900913 without a shift read as Mercator on the WGS 84 ellipsoid, as PROJ does, and says when a file's WGS 84 shift is set aside for a code that has none. I could not run the test suite (no shell here), so the findings below come from reading the code.

Bugs

  • read_wkt_over_code was not updated to match read_root (wkt.rs:305, inline). For a 3857 or 900913 code with no shift in the text, it still returns None, so the GeoPackage, File Geodatabase and PDF callers use Web Mercator. The same text through read_wkt now reads as ellipsoidal Mercator. The doc comment's "same rule applies" no longer holds. A drop-in suggestion and a test request are in the inline comment. Confidence: about 75%. Category: bug.

Security

  • None found.

Performance

  • None significant. places_as now runs for every Web Mercator-coded WKT with no shift. That is one pair of transformers per read, which is fine for a read path.

Quality

  • set_aside in read_root repeats the shift check in set_aside_note and code_with_shift. Consider one helper. Confidence: high.
  • note.map_or(said.clone(), …) clones said eagerly. map_or_else(|| said.clone(), …) avoids that, or the string can be built once. Confidence: high, minor.
  • The set-aside message says "as EPSG:900913 has none" when the code is 900913. This is accurate, but it may read oddly to users. Confidence: low.
  • The PR body does not say which surfaces (desktop, CLI, Python, browser, ribbon, Assistant/MCP) the change reaches. Since the change sits in the shared reader, a line saying so would meet the "Reach every surface" rule. Confidence: medium. This is a PR-description point, not a code defect.

AGENTS.md

  • No violations found in non-test code. There is no unwrap outside tests, no new platform code, and nothing touches a saved format or a command surface.
  • Open question, not a rule break: a file coded 3857 or 900913 that has an ellipsoidal WGS 84 Mercator, no PROJ4 extension and no shift used to read as Web Mercator. It now reads as a custom CRS about 21 km off. This matches PROJ, but no notice is given, and no test covers a 3857-coded text without the extension. The author should confirm this change is intended and check the "Never silent" rule. Confidence: about 50%.

Already raised earlier: none. There are no prior review threads on this PR, so I did not skip any concerns.

Change size

Compared with main (merge base b595175 to PR head 2e9a605), covering the whole PR.

Measure Value
Files changed 1 (0 added, 1 modified, 0 removed, 0 renamed)
Size before 355.1 KB
Size after 356.3 KB
Total size change +1.3 KB
Path Before After Change
crates/data/src/raster/wkt.rs 355.1 KB 356.3 KB +1.3 KB

@github-actions

Copy link
Copy Markdown
Contributor

📖 Docs preview

Item Value
Preview https://preview.rustgis.app/pr-2961/
Web app https://preview.rustgis.app/pr-2961/app/
Commit 2e9a605

GitHub Pages takes a minute or two to publish a new commit. Newer commits from the fork aren't published until a maintainer adds the preview label (once per commit).

@pick2510
pick2510 added this pull request to the merge queue Nov 25, 2026
…he same 900913 and set-aside rules

read_wkt_over_code shares read_root's rule (by_code_note): GDAL 1's EPSG:900913 without a shift is
compared with Web Mercator there too, and a shift set aside on a code without one is said. Only
900913 is compared without a shift: EPSG:3857's own text is Web Mercator for PROJ by its name, and
a row coded 3857 is still read by its code.
@pick2510

Copy link
Copy Markdown
Contributor Author

Review round 1, fixed in 579342b:

  • read_wkt_over_code now shares read_root's rule (by_code_note): a 900913 text beside its code without a shift reads as ellipsoidal Mercator there too, and a set-aside WGS 84 shift is said. Tests for both through read_wkt_over_code.
  • Open AGENTS.md question: narrowed to 900913. A GeoPackage row coded 3857 with another definition is still read by its code (explicit_method_1028_warns_for_known_geopackage_authorities), and EPSG:3857's own text without its extension stays Web Mercator with no note, as PROJ 9.9.0 reads it by its name (test added).
  • map_or(said.clone(), …): gone.
  • Reach: the PR body now says the change is in the shared WKT reader, so every surface that opens these files gets it.
  • Declined: one helper for the shift check. code_with_shift is already that helper; set_aside_note works on a code that may have no Crs.

Comment on lines +5187 to +5188
let beside = read_wkt_over_code(pseudo, 3857).unwrap_or(Ok((Crs::WebMercator, None)));
assert_eq!(beside, Ok((Crs::WebMercator, None)));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assertion can't fail on the None case. unwrap_or(Ok((Crs::WebMercator, None))) turns None into the expected value, so the test passes whether read_wkt_over_code reads the text (Some(Ok(..))) or defers to the code (None). That is the intended outcome, but the test should say it. Asserting it directly also makes a regression to Some(Err(..)) show up with its message.

Suggested change
let beside = read_wkt_over_code(pseudo, 3857).unwrap_or(Ok((Crs::WebMercator, None)));
assert_eq!(beside, Ok((Crs::WebMercator, None)));
let beside = read_wkt_over_code(pseudo, 3857);
assert!(beside.clone().is_none_or(|r| r == Ok((Crs::WebMercator, None))), "{beside:?}");

Category: quality

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merged already, so no follow-up for this: None is meant to pass. It means the caller uses the code, and 3857 is Web Mercator, so either outcome reads the text as Web Mercator with no note, which is what the test checks. A wrong reading (Some(Ok(custom)) or a note) still fails it.

@github-actions

Copy link
Copy Markdown
Contributor

Code review

I read the diff, the changed functions in crates/data/src/raster/wkt.rs (read_wkt_over_code, read_root, by_code_note, places_as, read_system, projected) and their three callers (pdf.rs, source/mod.rs, filegdb.rs). There were no prior review threads, so nothing was skipped as already raised.

Checked: the refactor of read_wkt_over_code keeps the old outcome for every case except the new GDAL 1 EPSG:900913 path. The old files_shift.is_none() || places_as(..) gate is now by_code_note, and it returns the same result in both callers. Each caller already handles Some(Ok(custom)). The new notes are emitted, and the clean input (zero shift) stays silent, as the AGENTS.md rule requires. projected() does not map "Google Mercator" names to Web Mercator, so the new places_as check is what decides that case.

Bugs: none found. Confidence in the logic is high on the traced paths.

Security: none found.

Performance: (low, not posted inline) places_as builds two PROJ transformers and now runs for every GDAL 1 EPSG:900913 text without a shift, where it used to short-circuit. On the fall-through path it runs twice, once in read_wkt_over_code and again in read_root. The cost is small because these texts are rare. Confidence: medium.

Quality:

  • wkt.rs:5187-5188: the unwrap_or in the pseudo assertion accepts None silently. Posted inline with a suggestion. Confidence: high.
  • wkt.rs:538: the doc line runs to about 118 characters, against the roughly 100-column wrapping of its neighbours. rustfmt allows 140, so this is cosmetic. Confidence: high.

AGENTS.md: no breaks found. The new notes go through the shared reader and so reach every surface. The note strings are English format!s, matching the existing notes in this module.

Open question (low confidence, not verified): existing files coded EPSG:900913 with no TOWGS84 and no PROJ4 extension used to read as Web Mercator. They now read as Mercator on the WGS 84 ellipsoid. The positions move by about 21 km at 45°N, and no notice is given. The PR says PROJ 9.9.0 reads them this way, and I have no PROJ or network here to confirm. The author should confirm the PROJ output before merge, since this changes positions for existing data.

Change size

Compared with the base branch: the whole PR against main (merge base b595175 to PR head 579342b).

Measure Value
Files changed 1 (modified 1, added 0, removed 0, renamed 0)
Size before 355.1 KB
Size after 358.8 KB
Total size change +3.7 KB
Path Before After Change
crates/data/src/raster/wkt.rs 355.1 KB 358.8 KB +3.7 KB

Merged via the queue into opengeos:main with commit c0c5362 Nov 25, 2026
4 checks passed
@pick2510
pick2510 deleted the terrio-crs-0.3-notes branch November 25, 2026 20:43
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