Skip to content

Commit a654e42

Browse files
authored
Merge pull request OSGeo#3846 from rouault/proj_alter_id_fix
proj_alter_id(): make it replace an existing ID instead of appending a new one
2 parents 1a0a28d + a47da33 commit a654e42

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/iso19111/common.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,7 @@ void IdentifiedObject::Private::setIdentifiers(
761761

762762
pVal = properties.get(Identifier::CODE_KEY);
763763
if (pVal) {
764+
identifiers.clear();
764765
identifiers.push_back(
765766
Identifier::create(std::string(), properties));
766767
}

test/unit/test_c_api.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3524,6 +3524,13 @@ TEST_F(CApi, proj_alter_id) {
35243524

35253525
EXPECT_EQ(std::string(proj_get_id_auth_name(alteredObj, 0)), "auth");
35263526
EXPECT_EQ(std::string(proj_get_id_code(alteredObj, 0)), "code");
3527+
3528+
auto alteredObj2 = proj_alter_id(m_ctxt, alteredObj, "auth2", "code2");
3529+
ObjectKeeper keeper_alteredObj2(alteredObj2);
3530+
ASSERT_NE(alteredObj2, nullptr);
3531+
3532+
EXPECT_EQ(std::string(proj_get_id_auth_name(alteredObj2, 0)), "auth2");
3533+
EXPECT_EQ(std::string(proj_get_id_code(alteredObj2, 0)), "code2");
35273534
}
35283535

35293536
// ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)