aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2021-03-10 19:01:41 +0100
committerEven Rouault <even.rouault@spatialys.com>2021-03-10 19:44:56 +0100
commit1e47f2bda51fda1ab424c04da7d2c33a38c10e87 (patch)
treeee6153d2f984ceb4a1a5e74652eb4ac5e7d240bb /test
parent47dd37ff798d454d8e1fd00cd93478642981e2b0 (diff)
downloadPROJ-1e47f2bda51fda1ab424c04da7d2c33a38c10e87.tar.gz
PROJ-1e47f2bda51fda1ab424c04da7d2c33a38c10e87.zip
Make proj_lp_dist() and proj_geod() work on a PJ* CRS object
Diffstat (limited to 'test')
-rw-r--r--test/unit/test_c_api.cpp25
1 files changed, 15 insertions, 10 deletions
diff --git a/test/unit/test_c_api.cpp b/test/unit/test_c_api.cpp
index 26e4eae2..1b08e884 100644
--- a/test/unit/test_c_api.cpp
+++ b/test/unit/test_c_api.cpp
@@ -175,18 +175,23 @@ TEST_F(CApi, proj_create) {
EXPECT_NE(obj, nullptr);
// Check that functions that operate on 'non-C++' PJ don't crash
- PJ_COORD coord;
- coord.xyzt.x = 0;
- coord.xyzt.y = 0;
- coord.xyzt.z = 0;
- coord.xyzt.t = 0;
- EXPECT_EQ(proj_trans(obj, PJ_FWD, coord).xyzt.x,
+ constexpr double DEG_TO_RAD = .017453292519943296;
+ PJ_COORD coord1;
+ coord1.xyzt.x = 2 * DEG_TO_RAD;
+ coord1.xyzt.y = 49 * DEG_TO_RAD;
+ coord1.xyzt.z = 0;
+ coord1.xyzt.t = 0;
+ PJ_COORD coord2;
+ coord2.xyzt.x = 2 * DEG_TO_RAD;
+ coord2.xyzt.y = 50 * DEG_TO_RAD;
+ coord2.xyzt.z = 0;
+ coord2.xyzt.t = 0;
+ EXPECT_EQ(proj_trans(obj, PJ_FWD, coord1).xyzt.x,
std::numeric_limits<double>::infinity());
- EXPECT_EQ(proj_geod(obj, coord, coord).xyzt.x,
- std::numeric_limits<double>::infinity());
- EXPECT_EQ(proj_lp_dist(obj, coord, coord),
- std::numeric_limits<double>::infinity());
+ // and those ones actually work just fine
+ EXPECT_NEAR(proj_geod(obj, coord1, coord2).xyzt.x, 111219.409, 1e-3);
+ EXPECT_NEAR(proj_lp_dist(obj, coord1, coord2), 111219.409, 1e-3);
auto info = proj_pj_info(obj);
EXPECT_EQ(info.id, nullptr);