aboutsummaryrefslogtreecommitdiff
path: root/test/unit/test_c_api.cpp
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2020-04-16 00:44:39 +0200
committerGitHub <noreply@github.com>2020-04-16 00:44:39 +0200
commit000fa21d070e64200bc877b9d14444262e1a14b5 (patch)
tree6d5dd2c3841bb87ec0816e6c9e9593b5091731a3 /test/unit/test_c_api.cpp
parentc91966953d9ad327cbb3b9d80842cc0d3957df42 (diff)
parent4be093e9d23b53915ed88a1c0da06f6833456a69 (diff)
downloadPROJ-000fa21d070e64200bc877b9d14444262e1a14b5.tar.gz
PROJ-000fa21d070e64200bc877b9d14444262e1a14b5.zip
Merge pull request #2155 from rouault/fix_2143
createOperations(): do not remove ballpark transformation if there are only grid based operations, even if they cover the whole area of use (fixes #2143)
Diffstat (limited to 'test/unit/test_c_api.cpp')
-rw-r--r--test/unit/test_c_api.cpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/test/unit/test_c_api.cpp b/test/unit/test_c_api.cpp
index da95e523..9e477ef3 100644
--- a/test/unit/test_c_api.cpp
+++ b/test/unit/test_c_api.cpp
@@ -1600,6 +1600,63 @@ TEST_F(CApi, proj_create_operations_with_pivot) {
// ---------------------------------------------------------------------------
+TEST_F(CApi, proj_create_operations_allow_ballpark_transformations) {
+ auto ctxt = proj_create_operation_factory_context(m_ctxt, nullptr);
+ ASSERT_NE(ctxt, nullptr);
+ ContextKeeper keeper_ctxt(ctxt);
+
+ auto source_crs = proj_create_from_database(
+ m_ctxt, "EPSG", "4267", PJ_CATEGORY_CRS, false, nullptr); // NAD27
+ ASSERT_NE(source_crs, nullptr);
+ ObjectKeeper keeper_source_crs(source_crs);
+
+ auto target_crs = proj_create_from_database(
+ m_ctxt, "EPSG", "4258", PJ_CATEGORY_CRS, false, nullptr); // ETRS89
+ ASSERT_NE(target_crs, nullptr);
+ ObjectKeeper keeper_target_crs(target_crs);
+
+ proj_operation_factory_context_set_spatial_criterion(
+ m_ctxt, ctxt, PROJ_SPATIAL_CRITERION_PARTIAL_INTERSECTION);
+
+ proj_operation_factory_context_set_grid_availability_use(
+ m_ctxt, ctxt, PROJ_GRID_AVAILABILITY_IGNORED);
+
+ // Default: allowed implictly
+ {
+ auto res = proj_create_operations(m_ctxt, source_crs, target_crs, ctxt);
+ ASSERT_NE(res, nullptr);
+ ObjListKeeper keeper_res(res);
+
+ EXPECT_EQ(proj_list_get_count(res), 1);
+ }
+
+ // Allow explictly
+ {
+ proj_operation_factory_context_set_allow_ballpark_transformations(
+ m_ctxt, ctxt, true);
+
+ auto res = proj_create_operations(m_ctxt, source_crs, target_crs, ctxt);
+ ASSERT_NE(res, nullptr);
+ ObjListKeeper keeper_res(res);
+
+ EXPECT_EQ(proj_list_get_count(res), 1);
+ }
+
+ // Disallow
+ {
+ proj_operation_factory_context_set_allow_ballpark_transformations(
+ m_ctxt, ctxt, false);
+
+ auto res = proj_create_operations(m_ctxt, source_crs, target_crs, ctxt);
+ ASSERT_NE(res, nullptr);
+ ObjListKeeper keeper_res(res);
+
+ EXPECT_EQ(proj_list_get_count(res), 0);
+ }
+}
+
+// ---------------------------------------------------------------------------
+
TEST_F(CApi, proj_context_set_database_path_null) {
EXPECT_TRUE(