From 7f0946ab38ad7dd5077a3970e7ed5f647365fa7b Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Wed, 15 Sep 2021 00:28:25 +0200 Subject: isEquivalentTo(): improve comparison of datum names based on official name and aliases (preparation for EPSG v10.035 update) --- src/iso19111/datum.cpp | 33 ++++++++++++++++++++++++--------- src/iso19111/factory.cpp | 23 +++++++++++++++++++++++ 2 files changed, 47 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/iso19111/datum.cpp b/src/iso19111/datum.cpp index 96952866..ebef94a2 100644 --- a/src/iso19111/datum.cpp +++ b/src/iso19111/datum.cpp @@ -1401,17 +1401,32 @@ bool GeodeticReferenceFrame::hasEquivalentNameToUsingAlias( if (dbContext) { if (!identifiers().empty()) { const auto &id = identifiers().front(); - auto aliasesResult = + + const std::string officialNameFromId = dbContext->getName( + "geodetic_datum", *(id->codeSpace()), id->code()); + const auto aliasesResult = dbContext->getAliases(*(id->codeSpace()), id->code(), nameStr(), "geodetic_datum", std::string()); - const char *otherName = other->nameStr().c_str(); - for (const auto &aliasResult : aliasesResult) { - if (metadata::Identifier::isEquivalentName( - otherName, aliasResult.c_str())) { - return true; - } - } - return false; + + const auto isNameMatching = + [&aliasesResult, &officialNameFromId](const std::string &name) { + const char *nameCstr = name.c_str(); + if (metadata::Identifier::isEquivalentName( + nameCstr, officialNameFromId.c_str())) { + return true; + } else { + for (const auto &aliasResult : aliasesResult) { + if (metadata::Identifier::isEquivalentName( + nameCstr, aliasResult.c_str())) { + return true; + } + } + } + return false; + }; + + return isNameMatching(nameStr()) && + isNameMatching(other->nameStr()); } else if (!other->identifiers().empty()) { auto otherGRF = dynamic_cast(other); if (otherGRF) { diff --git a/src/iso19111/factory.cpp b/src/iso19111/factory.cpp index 4ea9d2ad..f4228532 100644 --- a/src/iso19111/factory.cpp +++ b/src/iso19111/factory.cpp @@ -3430,6 +3430,29 @@ std::list DatabaseContext::getAliases( // --------------------------------------------------------------------------- +/** \brief Return the 'name' column of a table for an object + * + * @param tableName Table name/category. + * @param authName Authority name of the object. + * @param code Code of the object + * @return Name (or empty) + * @throw FactoryException + */ +std::string DatabaseContext::getName(const std::string &tableName, + const std::string &authName, + const std::string &code) const { + std::string sql("SELECT name FROM \""); + sql += replaceAll(tableName, "\"", "\"\""); + sql += "\" WHERE auth_name = ? AND code = ?"; + auto res = d->run(sql, {authName, code}); + if (res.empty()) { + return std::string(); + } + return res.front()[0]; +} + +// --------------------------------------------------------------------------- + /** \brief Return the 'text_definition' column of a table for an object * * @param tableName Table name/category. -- cgit v1.2.3 From 85f496b26702bf6566296072795e821d70156c09 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Wed, 15 Sep 2021 00:32:58 +0200 Subject: Database: update to EPSG v10.035 This seriously impacts French CRS users with the introduction of new datums, geodetic CRS and projected CRS based on "RGF 93 v2" and "RGF 93 v2b", and the previous single "RGF 93" being renamed as "RGF 93 v1". To be noted too, the addition of a null transformation between NAD83(2011) and WGS 84, which impacts a number of tests in the test suite. --- src/iso19111/operation/coordinateoperationfactory.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/iso19111/operation/coordinateoperationfactory.cpp b/src/iso19111/operation/coordinateoperationfactory.cpp index 1b1cae9b..b59eeb91 100644 --- a/src/iso19111/operation/coordinateoperationfactory.cpp +++ b/src/iso19111/operation/coordinateoperationfactory.cpp @@ -883,12 +883,12 @@ struct SortFunction { b_name.find("NTF (Paris) to NTF (1)") != std::string::npos) { return false; } - if (a_name.find("NTF (Paris) to RGF93 (1)") != std::string::npos && - b_name.find("NTF (Paris) to RGF93 (2)") != std::string::npos) { + if (a_name.find("NTF (Paris) to RGF93 v1 (1)") != std::string::npos && + b_name.find("NTF (Paris) to RGF93 v1 (2)") != std::string::npos) { return true; } - if (a_name.find("NTF (Paris) to RGF93 (2)") != std::string::npos && - b_name.find("NTF (Paris) to RGF93 (1)") != std::string::npos) { + if (a_name.find("NTF (Paris) to RGF93 v1 (2)") != std::string::npos && + b_name.find("NTF (Paris) to RGF93 v1 (1)") != std::string::npos) { return false; } -- cgit v1.2.3