From 2c3a7c8bcc711cf34b79885edbf1e5dccacc5757 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Tue, 10 Dec 2019 14:36:07 +0100 Subject: ob_tran: restore traditional handling of +to_meter with pj_transform() and proj utility (fixes #1782) Fixes side-effect of https://github.com/OSGeo/PROJ/issues/1525 that went in 6.1.1 The correction is horribly hacky. Sorry... --- test/unit/pj_transform_test.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'test/unit/pj_transform_test.cpp') diff --git a/test/unit/pj_transform_test.cpp b/test/unit/pj_transform_test.cpp index b3a061b4..1f4473c1 100644 --- a/test/unit/pj_transform_test.cpp +++ b/test/unit/pj_transform_test.cpp @@ -614,4 +614,38 @@ TEST(proj_api_h, pj_set_finder) { pj_set_finder(nullptr); } +// --------------------------------------------------------------------------- + +TEST(pj_transform_test, ob_tran_to_meter_as_dest) { + auto src = pj_init_plus( + "+ellps=WGS84 +a=57.29577951308232 +proj=eqc +lon_0=0.0 +no_defs"); + auto dst = pj_init_plus("+ellps=WGS84 +proj=ob_tran +o_proj=latlon " + "+o_lon_p=0.0 +o_lat_p=90.0 +lon_0=360.0 " + "+to_meter=0.0174532925199433 +no_defs"); + double x = 2 * DEG_TO_RAD; + double y = 49 * DEG_TO_RAD; + EXPECT_EQ(pj_transform(src, dst, 1, 0, &x, &y, nullptr), 0); + EXPECT_NEAR(x, 2 * DEG_TO_RAD, 1e-12) << x / DEG_TO_RAD; + EXPECT_NEAR(y, 49 * DEG_TO_RAD, 1e-12) << y / DEG_TO_RAD; + pj_free(src); + pj_free(dst); +} + +// --------------------------------------------------------------------------- + +TEST(pj_transform_test, ob_tran_to_meter_as_srouce) { + auto src = pj_init_plus("+ellps=WGS84 +proj=ob_tran +o_proj=latlon " + "+o_lon_p=0.0 +o_lat_p=90.0 +lon_0=360.0 " + "+to_meter=0.0174532925199433 +no_defs"); + auto dst = pj_init_plus( + "+ellps=WGS84 +a=57.29577951308232 +proj=eqc +lon_0=0.0 +no_defs"); + double x = 2 * DEG_TO_RAD; + double y = 49 * DEG_TO_RAD; + EXPECT_EQ(pj_transform(src, dst, 1, 0, &x, &y, nullptr), 0); + EXPECT_NEAR(x, 2 * DEG_TO_RAD, 1e-12) << x / DEG_TO_RAD; + EXPECT_NEAR(y, 49 * DEG_TO_RAD, 1e-12) << y / DEG_TO_RAD; + pj_free(src); + pj_free(dst); +} + } // namespace -- cgit v1.2.3