From ed679900c66d8c634afaab82c54d625968875af6 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Thu, 12 Sep 2019 12:30:26 +0200 Subject: [PATCH] proj_trans_generic(): properly set coordinate time to HUGE_VAL when no value is passed to the function --- src/4D_api.cpp | 3 ++- test/unit/gie_self_tests.cpp | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/4D_api.cpp b/src/4D_api.cpp index ffef8d81e0..70eaac6ae4 100644 --- a/src/4D_api.cpp +++ b/src/4D_api.cpp @@ -362,6 +362,7 @@ size_t proj_trans_generic ( PJ_COORD coord = {{0,0,0,0}}; size_t i, nmin; double null_broadcast = 0; + double invalid_time = HUGE_VAL; if (nullptr==P) return 0; @@ -379,7 +380,7 @@ size_t proj_trans_generic ( if (0==nx) x = &null_broadcast; if (0==ny) y = &null_broadcast; if (0==nz) z = &null_broadcast; - if (0==nt) t = &null_broadcast; + if (0==nt) t = &invalid_time; /* nothing to do? */ if (0==nx+ny+nz+nt) diff --git a/test/unit/gie_self_tests.cpp b/test/unit/gie_self_tests.cpp index 399f51e5ac..15db814aca 100644 --- a/test/unit/gie_self_tests.cpp +++ b/test/unit/gie_self_tests.cpp @@ -771,4 +771,30 @@ TEST(gie, proj_create_crs_to_crs_outside_area_of_use) { proj_destroy(P); } +// --------------------------------------------------------------------------- + +TEST(gie, proj_trans_generic) { + // GDA2020 to WGS84 (G1762) + auto P = proj_create( + PJ_DEFAULT_CTX, + "+proj=pipeline +step +proj=axisswap +order=2,1 " + "+step +proj=unitconvert +xy_in=deg +xy_out=rad " + "+step +proj=cart +ellps=GRS80 " + "+step +proj=helmert +x=0 +y=0 +z=0 +rx=0 +ry=0 +rz=0 +s=0 +dx=0 " + "+dy=0 +dz=0 +drx=-0.00150379 +dry=-0.00118346 +drz=-0.00120716 " + "+ds=0 +t_epoch=2020 +convention=coordinate_frame " + "+step +inv +proj=cart +ellps=WGS84 " + "+step +proj=unitconvert +xy_in=rad +xy_out=deg " + "+step +proj=axisswap +order=2,1"); + double lat = -60; + double lon = 120; + proj_trans_generic(P, PJ_FWD, &lat, sizeof(double), 1, &lon, sizeof(double), + 1, nullptr, 0, 0, nullptr, 0, 0); + // Should be a no-op when the time is unknown (or equal to 2020) + EXPECT_NEAR(lat, -60, 1e-9); + EXPECT_NEAR(lon, 120, 1e-9); + + proj_destroy(P); +} + } // namespace