diff --git a/src/iso19111/common.cpp b/src/iso19111/common.cpp index 9172498615..02bb376959 100644 --- a/src/iso19111/common.cpp +++ b/src/iso19111/common.cpp @@ -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)); } diff --git a/test/unit/test_c_api.cpp b/test/unit/test_c_api.cpp index 6aca219f6b..de460cdc43 100644 --- a/test/unit/test_c_api.cpp +++ b/test/unit/test_c_api.cpp @@ -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"); } // ---------------------------------------------------------------------------