Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

geod does not output decimeter, centimeter or milimeter distances #1074

Closed
kbevers opened this issue Jul 11, 2018 · 1 comment · Fixed by #1075
Closed

geod does not output decimeter, centimeter or milimeter distances #1074

kbevers opened this issue Jul 11, 2018 · 1 comment · Fixed by #1075
Labels

Comments

@kbevers
Copy link
Member

kbevers commented Jul 11, 2018

I shall explain by example:

C:\dev\build\proj>echo 68.719315436111117 -52.793336961111109 68.719314987800004 -52.793337262100003 | bin\Release\geod.exe -I +ellps=GRS80 +units=m
-166d17'38.046" 13d42'21.953"   0.051

C:\dev\build\proj>echo 68.719315436111117 -52.793336961111109 68.719314987800004 -52.793337262100003 | bin\Release\geod.exe -I +ellps=GRS80 +units=dm
-166d17'38.046" 13d42'21.953"   0.051

C:\dev\build\proj>echo 68.719315436111117 -52.793336961111109 68.719314987800004 -52.793337262100003 | bin\Release\geod.exe -I +ellps=GRS80 +units=cm
-166d17'38.046" 13d42'21.953"   0.051

C:\dev\build\proj>echo 68.719315436111117 -52.793336961111109 68.719314987800004 -52.793337262100003 | bin\Release\geod.exe -I +ellps=GRS80 +units=mm
-166d17'38.046" 13d42'21.953"   0.051

Here I would expect the third value to change with each call to geod. Other units suchs as US feet works as expected:

(posetta) C:\dev\build\proj4>echo 68.719315436111117 -52.793336961111109 68.719314987800004 -52.793337262100003 | bin\Release\geod.exe -I +ellps=GRS80 +units=us-ft
-166d17'38.046" 13d42'21.953"   0.169

I am okay with geod not being able to convert to dm, cm or mm but right now the application advertises that it can do it:

C:\dev\build\proj4>bin\Release\geod.exe -lu
          km 1000.                Kilometer
           m 1.                   Meter
          dm 1/10                 Decimeter
          cm 1/100                Centimeter
          mm 1/1000               Millimeter
         kmi 1852.0               International Nautical Mile
          in 0.0254               International Inch
          ft 0.3048               International Foot
          yd 0.9144               International Yard
          mi 1609.344             International Statute Mile
        fath 1.8288               International Fathom
          ch 20.1168              International Chain
        link 0.201168             International Link
       us-in 1./39.37             U.S. Surveyor's Inch
       us-ft 0.304800609601219    U.S. Surveyor's Foot
       us-yd 0.914401828803658    U.S. Surveyor's Yard
       us-ch 20.11684023368047    U.S. Surveyor's Chain
       us-mi 1609.347218694437    U.S. Surveyor's Statute Mile
      ind-yd 0.91439523           Indian Yard
      ind-ft 0.30479841           Indian Foot
      ind-ch 20.11669506          Indian Chain

The problem is likely to originate in the "1/x" conversion factor values. The us-in unit follows this pattern at least.

@kbevers kbevers added the bug label Jul 11, 2018
@cffk
Copy link
Contributor

cffk commented Jul 11, 2018

This should be straightforward to fix. geod should just use the double factor field of PJ_UNITS, instead of decoding the check* to_meter field. I'll take a crack at this.

cffk added a commit to cffk/proj.4 that referenced this issue Jul 11, 2018
Previously, unit conversion using atof(unit_list[i].to_meter) which
gives the wrong answer with, e.g., "1/10".  Now it directly uses
unit_list[i].factor (e.g., 0.1).

Also fix all the conversion factors for the US Surveyor units so that
they are the closest doubles.  E.g., the conversion factors for US
feet are

        factor              rel error
    old 0.304800609601219   6e-16
        12/39.37            1e-16  
    now 1200/3937.0         5e-17

Maybe someone should check the Indian units (but it's possible that
India and Pakistan have different standards).
cffk added a commit that referenced this issue Jul 12, 2018
Fix #1074.  Fix unit conversion factors for geod.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants