Skip to content

Commit 545d1e1

Browse files
authored
Merge pull request #4594 from rouault/fix_4591
proj_clone(): fix insufficient propagation of FORCE_OVER=YES
2 parents e4f7a49 + 687f463 commit 545d1e1

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/iso19111/c_api.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,20 +557,24 @@ PJ *proj_clone(PJ_CONTEXT *ctx, const PJ *obj) {
557557
newPj->descr = "Set of coordinate operations";
558558
newPj->ctx = ctx;
559559
newPj->copyStateFrom(*obj);
560+
ctx->forceOver = obj->over != 0;
560561
const int old_debug_level = ctx->debug_level;
561562
ctx->debug_level = PJ_LOG_NONE;
562563
for (const auto &altOp : obj->alternativeCoordinateOperations) {
563564
newPj->alternativeCoordinateOperations.emplace_back(
564565
PJCoordOperation(ctx, altOp));
565566
}
567+
ctx->forceOver = false;
566568
ctx->debug_level = old_debug_level;
567569
}
568570
return newPj;
569571
}
570572
return nullptr;
571573
}
572574
try {
575+
ctx->forceOver = obj->over != 0;
573576
PJ *newPj = pj_obj_create(ctx, NN_NO_CHECK(obj->iso_obj));
577+
ctx->forceOver = false;
574578
if (newPj) {
575579
newPj->copyStateFrom(*obj);
576580
}

test/unit/gie_self_tests.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,6 +1309,10 @@ TEST(gie, proj_create_crs_to_crs_from_pj_force_over) {
13091309
auto output = proj_trans(P, PJ_FWD, input);
13101310
auto output_over = proj_trans(P, PJ_FWD, input_over);
13111311

1312+
auto P_clone = proj_clone(ctx, P);
1313+
auto output_clone_over = proj_trans(P_clone, PJ_FWD, input_over);
1314+
proj_destroy(P_clone);
1315+
13121316
auto input_inv = proj_trans(P, PJ_INV, output);
13131317
auto input_over_inv = proj_trans(P, PJ_INV, output_over);
13141318

@@ -1320,6 +1324,8 @@ TEST(gie, proj_create_crs_to_crs_from_pj_force_over) {
13201324
EXPECT_NEAR(output.xyz.x, 15584728.711058298, 1e-8);
13211325
EXPECT_NEAR(output_over.xyz.x, -24490287.974520184, 1e-8);
13221326

1327+
EXPECT_EQ(output_clone_over.xyz.x, output_over.xyz.x);
1328+
13231329
// The distance from 140 to 180 and -220 to -180 should be pretty much
13241330
// the same.
13251331
auto dx_o = fabs(output.xyz.x - 20037508.342789244);

0 commit comments

Comments
 (0)