aboutsummaryrefslogtreecommitdiff
path: root/test/unit/test_c_api.cpp
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2019-09-26 12:16:15 +0200
committerEven Rouault <even.rouault@spatialys.com>2019-09-26 12:23:56 +0200
commit24405e60078abf9693a9d1a058824c4edd8d4f2b (patch)
tree16a2109f41570bf2a083961e6726ca9fd6259b99 /test/unit/test_c_api.cpp
parent6da6b21d6d01d9bc6973600c2fd336a2a515306b (diff)
downloadPROJ-24405e60078abf9693a9d1a058824c4edd8d4f2b.tar.gz
PROJ-24405e60078abf9693a9d1a058824c4edd8d4f2b.zip
proj_create_crs_to_crs(): fix when there are only transformations with ballpark steps
Currently we would discard all operations, resulting in a PJ object with zero candidates. Better use those operations if nothing better is available. Was seen on transforming from ETRS89 / UTM zone 31N + EGM96 height to WGS 84 (G1762). The horizontal transformation from ETRS89 to WGS 84 (G1762) is a ballpark one.
Diffstat (limited to 'test/unit/test_c_api.cpp')
-rw-r--r--test/unit/test_c_api.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/unit/test_c_api.cpp b/test/unit/test_c_api.cpp
index bd59358e..483ecdbd 100644
--- a/test/unit/test_c_api.cpp
+++ b/test/unit/test_c_api.cpp
@@ -3997,4 +3997,30 @@ TEST_F(CApi, proj_crs_create_bound_vertical_crs_to_WGS84) {
"+vunits=m +no_defs +type=crs");
}
+// ---------------------------------------------------------------------------
+
+TEST_F(CApi, proj_create_crs_to_crs_with_only_ballpark_transformations) {
+ // ETRS89 / UTM zone 31N + EGM96 height to WGS 84 (G1762)
+ auto P =
+ proj_create_crs_to_crs(m_ctxt, "EPSG:25831+5773", "EPSG:7665", nullptr);
+ ObjectKeeper keeper_P(P);
+ ASSERT_NE(P, nullptr);
+ auto Pnormalized = proj_normalize_for_visualization(m_ctxt, P);
+ ObjectKeeper keeper_Pnormalized(Pnormalized);
+ ASSERT_NE(Pnormalized, nullptr);
+
+ PJ_COORD coord;
+ coord.xyzt.x = 500000;
+ coord.xyzt.y = 4500000;
+ coord.xyzt.z = 0;
+ coord.xyzt.t = 0;
+ coord = proj_trans(Pnormalized, PJ_FWD, coord);
+ EXPECT_NEAR(coord.xyzt.x, 3.0, 1e-9);
+ EXPECT_NEAR(coord.xyzt.y, 40.65085651660555, 1e-9);
+ if (coord.xyzt.z != 0) {
+ // z will depend if the egm96_15.gtx grid is there or not
+ EXPECT_NEAR(coord.xyzt.z, 47.04784081844435, 1e-3);
+ }
+}
+
} // namespace