diff options
| -rw-r--r-- | src/iso19111/c_api.cpp | 8 | ||||
| -rw-r--r-- | test/unit/gie_self_tests.cpp | 12 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/iso19111/c_api.cpp b/src/iso19111/c_api.cpp index 240d11b3..79732bab 100644 --- a/src/iso19111/c_api.cpp +++ b/src/iso19111/c_api.cpp @@ -1736,6 +1736,10 @@ PJ *proj_get_source_crs(PJ_CONTEXT *ctx, const PJ *obj) { } return nullptr; } + if (!obj->alternativeCoordinateOperations.empty()) { + return proj_get_source_crs(ctx, + obj->alternativeCoordinateOperations[0].pj); + } proj_log_error(ctx, __FUNCTION__, "Object is not a BoundCRS or a CoordinateOperation"); return nullptr; @@ -1771,6 +1775,10 @@ PJ *proj_get_target_crs(PJ_CONTEXT *ctx, const PJ *obj) { } return nullptr; } + if (!obj->alternativeCoordinateOperations.empty()) { + return proj_get_target_crs(ctx, + obj->alternativeCoordinateOperations[0].pj); + } proj_log_error(ctx, __FUNCTION__, "Object is not a BoundCRS or a CoordinateOperation"); return nullptr; diff --git a/test/unit/gie_self_tests.cpp b/test/unit/gie_self_tests.cpp index 91a3069c..5936791e 100644 --- a/test/unit/gie_self_tests.cpp +++ b/test/unit/gie_self_tests.cpp @@ -680,6 +680,18 @@ TEST(gie, proj_create_crs_to_crs_PULKOVO42_ETRS89) { EXPECT_EQ(P->fwd3d, nullptr); EXPECT_EQ(P->fwd4d, nullptr); + // get source CRS even if the P object is in a dummy state + auto src_crs = proj_get_source_crs(PJ_DEFAULT_CTX, P); + EXPECT_TRUE(src_crs != nullptr); + EXPECT_EQ(proj_get_name(src_crs), std::string("Pulkovo 1942(58)")); + proj_destroy(src_crs); + + // get target CRS even if the P object is in a dummy state + auto target_crs = proj_get_target_crs(PJ_DEFAULT_CTX, P); + EXPECT_TRUE(target_crs != nullptr); + EXPECT_EQ(proj_get_name(target_crs), std::string("ETRS89")); + proj_destroy(target_crs); + // Romania c.xyz.x = 45; // Lat c.xyz.y = 25; // Long |
