aboutsummaryrefslogtreecommitdiff
path: root/test/unit/test_c_api.cpp
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2020-03-12 23:10:20 +0100
committerEven Rouault <even.rouault@spatialys.com>2020-03-13 08:45:56 +0100
commitf0d6b64fee8b796ec038929187b7b725f62a5ba8 (patch)
treeb32badffae5470b2f318d4a0a98cc27443bbd75a /test/unit/test_c_api.cpp
parentca3caf0e976e95a739963567057654cb8909bfb9 (diff)
downloadPROJ-f0d6b64fee8b796ec038929187b7b725f62a5ba8.tar.gz
PROJ-f0d6b64fee8b796ec038929187b7b725f62a5ba8.zip
Add proj_get_suggested_operation()
Return the index of the operation that would be the most appropriate to transform the specified coordinates. This operation may use resources that are not locally available, depending on the search criteria used by proj_create_operations(). This could be done by using proj_create_operations() with a punctual bounding box, but this function is faster when one needs to evaluate on many points with the same (source_crs, target_crs) tuple.
Diffstat (limited to 'test/unit/test_c_api.cpp')
-rw-r--r--test/unit/test_c_api.cpp34
1 files changed, 29 insertions, 5 deletions
diff --git a/test/unit/test_c_api.cpp b/test/unit/test_c_api.cpp
index 0f1b906e..f274af57 100644
--- a/test/unit/test_c_api.cpp
+++ b/test/unit/test_c_api.cpp
@@ -1348,12 +1348,36 @@ TEST_F(CApi, proj_create_operations) {
EXPECT_EQ(proj_list_get(m_ctxt, res, -1), nullptr);
EXPECT_EQ(proj_list_get(m_ctxt, res, proj_list_get_count(res)), nullptr);
- auto op = proj_list_get(m_ctxt, res, 0);
- ASSERT_NE(op, nullptr);
- ObjectKeeper keeper_op(op);
- EXPECT_FALSE(proj_coordoperation_has_ballpark_transformation(m_ctxt, op));
+ {
+ auto op = proj_list_get(m_ctxt, res, 0);
+ ASSERT_NE(op, nullptr);
+ ObjectKeeper keeper_op(op);
+ EXPECT_FALSE(
+ proj_coordoperation_has_ballpark_transformation(m_ctxt, op));
+ EXPECT_EQ(proj_get_name(op), std::string("NAD27 to NAD83 (3)"));
+ }
+
+ {
+ PJ_COORD coord;
+ coord.xy.x = 40;
+ coord.xy.y = -100;
+ int idx = proj_get_suggested_operation(m_ctxt, res, PJ_FWD, coord);
+ ASSERT_GE(idx, 0);
+ ASSERT_LT(idx, proj_list_get_count(res));
+ auto op = proj_list_get(m_ctxt, res, idx);
+ ASSERT_NE(op, nullptr);
+ ObjectKeeper keeper_op(op);
+ // Transformation for USA
+ EXPECT_EQ(proj_get_name(op), std::string("NAD27 to NAD83 (1)"));
+ }
- EXPECT_EQ(proj_get_name(op), std::string("NAD27 to NAD83 (3)"));
+ {
+ PJ_COORD coord;
+ coord.xy.x = 40;
+ coord.xy.y = 10;
+ int idx = proj_get_suggested_operation(m_ctxt, res, PJ_FWD, coord);
+ EXPECT_GE(idx, -1);
+ }
}
// ---------------------------------------------------------------------------