diff --git a/src/apps/cs2cs.cpp b/src/apps/cs2cs.cpp index d4485fbe5b..f115e1ea20 100644 --- a/src/apps/cs2cs.cpp +++ b/src/apps/cs2cs.cpp @@ -171,7 +171,7 @@ static void process(FILE *fid) if (data.u != HUGE_VAL) { - if (srcIsLongLat) { + if (srcIsLongLat && fabs(srcToRadians - M_PI / 180) < 1e-10) { /* dmstor gives values to radians. Convert now to the SRS unit */ data.u /= srcToRadians; @@ -922,10 +922,10 @@ int main(int argc, char **argv) { } /* set input formatting control */ - if (!srcIsLongLat) - informat = strtod; - else { + if (srcIsLongLat && fabs(srcToRadians - M_PI / 180) < 1e-10) informat = dmstor; + else { + informat = strtod; } if (!destIsLongLat && !oform) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 52fe455758..f41f664ce6 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -72,7 +72,7 @@ proj_add_gie_test("GIGS-5101.4-jhs-etmerc" "gigs/5101.4-jhs-etmerc.gie") # Same as above, but using etmerc instead of tmerc #proj_add_gie_test("GIGS-5101.4-jhs" "gigs/5101.4-jhs.gie") proj_add_gie_test("GIGS-5102.1" "gigs/5102.1.gie") -#proj_add_gie_test("GIGS-5102.2" "gigs/5102.2.gie") +proj_add_gie_test("GIGS-5102.2" "gigs/5102.2.gie") proj_add_gie_test("GIGS-5103.1" "gigs/5103.1.gie") proj_add_gie_test("GIGS-5103.2" "gigs/5103.2.gie") proj_add_gie_test("GIGS-5103.3" "gigs/5103.3.gie") diff --git a/test/cli/testvarious b/test/cli/testvarious index ce50615ec4..2d6701c3ab 100755 --- a/test/cli/testvarious +++ b/test/cli/testvarious @@ -120,6 +120,12 @@ $EXE +proj=utm +zone=11 +datum=WGS84 +pm=3 \ 500000 3000000 EOF echo "##############################################################" >> ${OUT} +echo Test input in grad >> ${OUT} +# +$EXE EPSG:4807 EPSG:27572 -E >>${OUT} <> ${OUT} echo Test geocentric x/y/z generation. >> ${OUT} # $EXE +proj=latlong +datum=WGS84 \ diff --git a/test/cli/tv_out.dist b/test/cli/tv_out.dist index 0ba7035c02..3fc3cc1f0c 100644 --- a/test/cli/tv_out.dist +++ b/test/cli/tv_out.dist @@ -31,6 +31,9 @@ Test support for the lon_wrap switch. Test simple prime meridian handling within a projection. 500000 3000000 113dW 27d7'20.891"N 0.000 ############################################################## +Test input in grad +64.44444444 2.9586342556 760724.02 3457334.86 0.00 +############################################################## Test geocentric x/y/z generation. 0d00'00.001"W 0d00'00.001"N 0.0 6378137.00 -0.03 0.03 0d00'00.001"W 0d00'00.001"N 10.0 6378147.00 -0.03 0.03 diff --git a/test/gigs/5102.2.gie.failing b/test/gigs/5102.2.gie similarity index 84% rename from test/gigs/5102.2.gie.failing rename to test/gigs/5102.2.gie index db812dbde1..d41280e1d4 100644 --- a/test/gigs/5102.2.gie.failing +++ b/test/gigs/5102.2.gie @@ -1,14 +1,20 @@ -------------------------------------------------------------------------------- Test 5102 (part 2), Lambert Conic Conformal (1SP), v2-0_2011-06-28. - -------------------------------------------------------------------------------- - + + +use_proj4_init_rules true -------------------------------------------------------------------------------- -operation +proj=pipeline - +step +init=epsg:4807 +inv +# We need to add this grad->rad step as +init=epsg:4807 assumes +# degrees (if front operation), or radians (if non-front), as this was the case +# in PROJ < 6 era +# Note: "cs2cs EPSG:4807 EPSG:27572" does the right job. +operation +proj=pipeline \ + +step +proj=unitconvert +xy_in=grad +xy_out=rad \ + +step +init=epsg:4807 +inv \ +step +init=epsg:27572 -------------------------------------------------------------------------------- tolerance 0.03 m @@ -88,9 +94,13 @@ accept 9.6253009222 58.8888888889 expect 1183926.705 2923124.876 -------------------------------------------------------------------------------- -operation +proj=pipeline - +step +init=epsg:27572 +inv - +step +init=epsg:4807 +# We need to add this rad->grad step as +init=epsg:4807 assumes +# degrees (if last operation), or radians (if non-last), as this was the case +# in PROJ < 6 era +operation +proj=pipeline \ + +step +init=epsg:27572 +inv \ + +step +init=epsg:4807 \ + +step +proj=unitconvert +xy_in=rad +xy_out=grad -------------------------------------------------------------------------------- tolerance 0.03 m accept 760724.023 3457334.864 @@ -169,8 +179,12 @@ accept 1183926.705 2923124.876 expect 9.6253009222 58.8888888889 -------------------------------------------------------------------------------- -operation +proj=pipeline - +step +init=epsg:4807 +inv +# We need to add this grad->rad step as +init=epsg:4807 assumes +# degrees (if front operation), or radians (if non-front), as this was the case +# in PROJ < 6 era +operation +proj=pipeline \ + +step +proj=unitconvert +xy_in=grad +xy_out=rad \ + +step +init=epsg:4807 +inv \ +step +init=epsg:27572 -------------------------------------------------------------------------------- tolerance 0.006 m @@ -249,4 +263,4 @@ tolerance 0.006 m accept 9.6253009222 58.8888888889 roundtrip 1000 - +