Fix Oblique Mercator natural-origin offset to use the central-line azimuth - #130
Merged
pomadchin merged 1 commit intoAug 3, 2026
Conversation
…imuth
The natural-origin (uc) offset was computed from the rectified bearing
(Gamma) via cosrot, but Snyder's Hotine Oblique Mercator defines it with
the central-line azimuth (alpha):
u_c = (A / B) * atan(sqrt(D^2 - 1) / cos(alpha_c))
When Gamma equals alpha the two agree, which is why this went unnoticed.
For definitions where the rectified bearing differs from the azimuth --
notably the ESRI "Local" / mine-grid convention of an explicit +gamma=0
with a non-zero azimuth -- the projection centre was displaced along the
central line (e.g. ~2.5 km), so the false easting/northing no longer
landed on the centre.
Use cos(alpha) for the offset. This is a no-op when Gamma == alpha and
matches PROJ output when Gamma != alpha.
Adds a regression test (Proj4VariousTest#testObliqueMercatorExplicitGamma)
covering +gamma=0 with a non-zero azimuth, with reference coordinates
computed by PROJ.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Sergei Malyshko <sergei.malyshko@navvis.com>
pomadchin
self-requested a review
July 28, 2026 14:18
Member
|
Thanks for rising up a PR! Also could I ask you to sign https://www.eclipse.org/legal/eca/? (ECA form link) that would help us to make the ECA bot happy. |
Member
|
Thanks, that's a great catch! |
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.
Summary
Fixes the Oblique Mercator (
+proj=omerc) natural-origin offset so that the projection centre maps to the false easting/northing when+gammadiffers from+alpha— in particular for definitions with an explicit+gamma=0and a non-zero azimuth (the ESRI "Local" / mine-grid convention).Root cause
In
ObliqueMercatorProjection.initialize(), the natural-origin (uc) offset is computed withcosrot = cos(Gamma)(the rectified bearing γ):Snyder's Hotine Oblique Mercator (and PROJ) define this offset from the central-line azimuth α:
project()computes the point's along-line coordinate from the natural azimuth (singam/cosgam), so the offset must be based on α, not γ. When γ = α the two coincide (the common case, and why this went unnoticed — e.g. the standard EPSG omerc grids store+gammaequal to+alpha). But when γ ≠ α — e.g.+gamma=0with a non-zero azimuth —u_0no longer cancels the centre's coordinate, and the centre is displaced along the central line.Impact (before the fix)
For a grid like
+proj=omerc +lat_0=-20 +lonc=140 +alpha=30 +gamma=0 +k=1 +x_0=200000 +y_0=300000 +ellps=GRS80, the centre(140, -20)should map to(200000, 300000). Before the fix it was off by ~2.5 km in the along-line direction (larger for larger azimuths). This is the ESRIPROJECTION["Local"]mine-grid convention (origin + scale + azimuth, no rectification), which is common for Australian survey grids.Fix
Use
cos(alpha)for the offset. This is a no-op when γ == α (verified by the full existing test suite) and matches PROJ output when γ ≠ α.Test
Adds
Proj4VariousTest#testObliqueMercatorExplicitGamma, covering+gamma=0with a non-zero azimuth. It asserts the centre maps exactly to the false easting/northing and checks two further points; reference coordinates were computed with PROJ. With the fix the centre error is 0 and the points agree with PROJ to < 1e-4 m; before the fix the centre was ~2.5 km off.Full
coresuite: 65 run, 0 failures, 0 errors, 2 skipped (pre-existing).Related note (not addressed here)
The
Gammafield defaults to0.0rather thanNaN, so thegzi = Double.isNaN(Gamma)guard is always "provided" and theif (gzi == 0) Gamma = alpha;default (rectified bearing defaults to the azimuth when+gammais omitted) never runs. That affects the rotation for the+gamma-omitted case and the unreachable two-point setup. I've kept this PR focused on the offset bug; happy to open a separate issue/PR for theGammadefault if useful.