Skip to content

Commit

Permalink
Merge pull request #3846 from rouault/proj_alter_id_fix
Browse files Browse the repository at this point in the history
proj_alter_id(): make it replace an existing ID instead of appending a new one
  • Loading branch information
rouault authored Aug 9, 2023
2 parents 1a0a28d + a47da33 commit a654e42
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/iso19111/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,7 @@ void IdentifiedObject::Private::setIdentifiers(

pVal = properties.get(Identifier::CODE_KEY);
if (pVal) {
identifiers.clear();
identifiers.push_back(
Identifier::create(std::string(), properties));
}
Expand Down
7 changes: 7 additions & 0 deletions test/unit/test_c_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3524,6 +3524,13 @@ TEST_F(CApi, proj_alter_id) {

EXPECT_EQ(std::string(proj_get_id_auth_name(alteredObj, 0)), "auth");
EXPECT_EQ(std::string(proj_get_id_code(alteredObj, 0)), "code");

auto alteredObj2 = proj_alter_id(m_ctxt, alteredObj, "auth2", "code2");
ObjectKeeper keeper_alteredObj2(alteredObj2);
ASSERT_NE(alteredObj2, nullptr);

EXPECT_EQ(std::string(proj_get_id_auth_name(alteredObj2, 0)), "auth2");
EXPECT_EQ(std::string(proj_get_id_code(alteredObj2, 0)), "code2");
}

// ---------------------------------------------------------------------------
Expand Down

0 comments on commit a654e42

Please sign in to comment.