Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/4D_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1416,8 +1416,18 @@ static int target_crs_lon_lat_order(PJ_CONTEXT *transformer_ctx,
"Unable to retrieve target CRS");
return -1;
}
PJ *coord_system_pj =
proj_crs_get_coordinate_system(transformer_ctx, target_crs);
PJ *coord_system_pj;
if (proj_get_type(target_crs) == PJ_TYPE_COMPOUND_CRS) {
PJ *horiz_crs = proj_crs_get_sub_crs(transformer_ctx, target_crs, 0);
if (!horiz_crs)
return -1;
coord_system_pj =
proj_crs_get_coordinate_system(transformer_ctx, horiz_crs);
proj_destroy(horiz_crs);
} else {
coord_system_pj =
proj_crs_get_coordinate_system(transformer_ctx, target_crs);
}
proj_destroy(target_crs);
if (coord_system_pj == nullptr) {
proj_context_log_debug(transformer_ctx,
Expand Down
21 changes: 21 additions & 0 deletions test/unit/test_c_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6515,6 +6515,27 @@ TEST_F(CApi, proj_trans_bounds__south_pole) {

// ---------------------------------------------------------------------------

TEST_F(CApi, proj_trans_bounds_to_compound_crs) {
// EPSG:9707 = "WGS 84 + EGM96 height"
auto P = proj_create_crs_to_crs(m_ctxt, "EPSG:4326", "EPSG:9707", nullptr);
ObjectKeeper keeper_P(P);
ASSERT_NE(P, nullptr);
double out_left;
double out_bottom;
double out_right;
double out_top;
int success =
proj_trans_bounds(m_ctxt, P, PJ_FWD, 40, -120, 64, -80, &out_left,
&out_bottom, &out_right, &out_top, 0);
EXPECT_TRUE(success == 1);
EXPECT_NEAR(out_left, 40, 1e-8);
EXPECT_NEAR(out_bottom, -120, 1e-8);
EXPECT_NEAR(out_right, 64, 1e-8);
EXPECT_NEAR(out_top, -80, 1e-8);
}

// ---------------------------------------------------------------------------

TEST_F(CApi, proj_crs_has_point_motion_operation) {
auto ctxt = proj_create_operation_factory_context(m_ctxt, nullptr);
ASSERT_NE(ctxt, nullptr);
Expand Down