Repository navigation
Description
AI usage
- Fable 5.1 supported the creation of this ticket.
- This ticket has been (mostly) written by myself (human), and is aimed at being read by humans.
Example of problem
+proj=alsk fwd (140 W, 60 N) = 665040.800 -383489.801 inv -> -139.99988618 59.99995133
+proj=alsk +ellps=clrk66 fwd (140 W, 60 N) = 665040.800 -383489.801 inv -> -140.00000000 60.00000000
+proj=alsk +R=6370997 fwd (140 W, 60 N) = 662599.055 -382708.191 inv -> -140.00000000 60.00000000
+proj=gs50 fwd (100 W, 40 N) = 1672352.402 -347454.748 inv -> -99.99980068 39.99992783
+proj=gs50 +ellps=clrk66 fwd (100 W, 40 N) = 1672352.402 -347454.748 inv -> -100.00000000 40.00000000
+proj=gs48 fwd (120 W, 45 N) = -1863484.184 894632.102 inv -> -119.97122854 44.99640670
+proj=gs48 +ellps=clrk66 fwd (120 W, 45 N) = -1863548.718 894402.079 inv -> -119.97095025 44.99637412
+proj=gs48 +R=6370997 fwd (120 W, 45 N) = -1857681.173 915305.567 inv -> -120.00000000 45.00000000The misses are the radius ratios: for alsk and gs50 on the default GRS80 the setup switches to Clarke 1866
(a = 6378206.4, 6378137 / 6378206.4 = 0.999989), about 7 m and 17 m at those points; for gs48 the setup forces the
sphere a = 6370997 (6378137 / 6370997 = 1.00112), about 2.3 km. Passing +ellps=clrk66 to alsk/gs50, or
+R=6370997 to gs48, pre-sets the same a, and the round trips close to 1e-8 degrees. (echo -140 60 | proj +proj=alsk | invproj +proj=alsk -f %.8f shows that at the command line.)
Problem description
pj_init_ctx runs pj_calc_ellipsoid_params() (init.cpp:584), which sets P->ra = 1. / P->a (ell_set.cpp:618),
before the projection's own setup. PJ_PROJECTION(gs48) then assigns P->a = 6370997. (mod_ster.cpp:186), and alsk
and gs50 assign P->a = 6378206.4 or 6370997. (lines 214, 218, 250, 254) without touching P->ra. The forward
multiplies by P->a (fwd.cpp:142-143) and the inverse by P->ra (inv.cpp:92-93), so a round trip through any of the
three comes back scaled by a_old / a_new unless the user happened to pass the very radius the projection forces.
nzmg (nzmg.cpp:117, P->ra = 1. / (P->a = 6378388.0);) and healpix (healpix.cpp:667-668) do reset P->ra when
they change P->a; mod_ster.cpp seems to have forgotten this step.
Expected Output
Forward and inverse are each other's inverse for any +ellps/+R the user passes, as they are for nzmg.
Proposed fix
Reset the reciprocal wherever P->a is reassigned in mod_ster.cpp, as nzmg does:
P->a = 6370997.;
P->ra = 1. / P->a;or recompute the derived parameters with pj_calc_ellipsoid_params(P, P->a, P->es) after the reassignment, which also covers P->b, P->rb, P->one_es and P->rone_es. (Note: three more sites for alsk/gs50's 6378206.4 and 6370997.)
A round-trip test for the three projections on the default ellipsoid in test/gie/builtins.gie
(they currently have forward expectations only, or expectations taken on the forced radius) would keep this from happening again.
Environment Information
- PROJ version (
proj): 9.7.0 - Operation System Information: MacOS Sequoia 15.7.7
Installation method
- conda, apt-get, from source, etc...
Activity
jjimenezshaw commentedon Nov 5, 2026
to be fixed at the same time as #4932 , right?
mapprehension commentedon Nov 6, 2026
Right. Thanks, both of you.