Skip to content

Commit

Permalink
Merge pull request #1604 from rouault/fix_proj_trans_generic_unknown_…
Browse files Browse the repository at this point in the history
…time

proj_trans_generic(): properly set coordinate time to HUGE_VAL when no value is passed to the function
  • Loading branch information
rouault committed Sep 12, 2019
2 parents 1e0f573 + ed67990 commit 9350d9e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/4D_api.cpp
Expand Up @@ -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;
Expand All @@ -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)
Expand Down
26 changes: 26 additions & 0 deletions test/unit/gie_self_tests.cpp
Expand Up @@ -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

0 comments on commit 9350d9e

Please sign in to comment.