aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>2020-03-30 21:05:40 +0000
committergithub-actions[bot] <github-actions[bot]@users.noreply.github.com>2020-03-30 21:05:40 +0000
commit80546db0a9b09fab875710f0a73b2bbbbc5d192e (patch)
tree129d2b92de9cb04dece384fb7ed6672ea553aaa0 /src
parent21bbf920f4a0b02935fbf416b44ad0853f6d5647 (diff)
downloadPROJ-80546db0a9b09fab875710f0a73b2bbbbc5d192e.tar.gz
PROJ-80546db0a9b09fab875710f0a73b2bbbbc5d192e.zip
ESRI_WKT ingestion: make sure to identify to non-deprecated EPSG entry when possible (fixes #2116)
Diffstat (limited to 'src')
-rw-r--r--src/iso19111/factory.cpp36
1 files changed, 27 insertions, 9 deletions
diff --git a/src/iso19111/factory.cpp b/src/iso19111/factory.cpp
index 1c836367..1add5810 100644
--- a/src/iso19111/factory.cpp
+++ b/src/iso19111/factory.cpp
@@ -5293,18 +5293,36 @@ std::string AuthorityFactory::getOfficialNameFromAlias(
if (res.empty()) {
return std::string();
}
- const auto &row = res.front();
- outTableName = row[0];
- outAuthName = row[1];
- outCode = row[2];
- sql = "SELECT name FROM \"";
- sql += replaceAll(outTableName, "\"", "\"\"");
- sql += "\" WHERE auth_name = ? AND code = ?";
- res = d->run(sql, {outAuthName, outCode});
+
+ params.clear();
+ sql.clear();
+ bool first = true;
+ for (const auto &row : res) {
+ if (!first)
+ sql += " UNION ALL ";
+ first = false;
+ outTableName = row[0];
+ outAuthName = row[1];
+ outCode = row[2];
+ sql += "SELECT name, ? AS table_name, auth_name, code, deprecated "
+ "FROM \"";
+ sql += replaceAll(outTableName, "\"", "\"\"");
+ sql += "\" WHERE auth_name = ? AND code = ?";
+ params.emplace_back(outTableName);
+ params.emplace_back(outAuthName);
+ params.emplace_back(outCode);
+ }
+ sql = "SELECT name, table_name, auth_name, code FROM (" + sql +
+ ") x ORDER BY deprecated LIMIT 1";
+ res = d->run(sql, params);
if (res.empty()) { // shouldn't happen normally
return std::string();
}
- return res.front()[0];
+ const auto &row = res.front();
+ outTableName = row[1];
+ outAuthName = row[2];
+ outCode = row[3];
+ return row[0];
}
}