Ticket #138 (assigned defect)

Opened 4 months ago

Last modified 3 months ago

spherical tmerc with negative northing gives inverted latitude

Reported by: dstahlke Owned by: warmerdam
Priority: major Milestone:
Component: Core Version: Development (trunk)
Keywords: tmerc Cc:

Description

It would seem the coordinate (0,-1) would give a result close to (lon_0,lat_0). However, the latitude is inverted in the case where northing is negative and the globe is spherical. If I make the globe elliptical, then it works fine.

~/Desktop/proj$ echo 0 -1 | invproj +proj=tmerc +lat_0=32.936 +lon_0=-117.038 +k=0.9996 +x_0=0 +y_0=0 +a=6378137 +b=6378137 +units=m +no_defs
117d2'16.8"W    32d56'9.568"S
~/Desktop/proj$ echo 0 -1 | invproj +proj=tmerc +lat_0=32.936 +lon_0=-117.038 +k=0.9996 +x_0=0 +y_0=0 +a=6378137 +b=6378136 +units=m +no_defs
117d2'16.8"W    32d56'9.568"N

I believe the problem is related to line 126 of PJ_tmerc.c where the test "xy.y < 0" is done. I don't know enough about proj.4 to give a proper fix.

As a workaround, the spherical function can be disabled and the elliptical version used always. On line 139 of PJ_tmerc.c, change "if(P->es)" to "if(1 P->es)".

Change History

Changed 4 months ago by dstahlke

The formatting didn't come out properly for the workaround. It should read as follows: on line 139 of PJ_tmerc.c, change if(P->es) to if(1 || P->es).

Changed 3 months ago by warmerdam

  • status changed from new to assigned

I have confirmed this is not a regression since 4.7 and I'm not too confident of the suggested solution so I'm not going to take action before 4.8 but this is a fairly serious problem.

Changed 3 months ago by warmerdam

  • keywords tmerc added
Note: See TracTickets for help on using tickets.