aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2021-04-11 02:02:41 +0200
committerGitHub <noreply@github.com>2021-04-11 02:02:41 +0200
commita42b447021a2f337d66d1e30d4880cd2be08932a (patch)
tree897812ad4adad44533c3693cacdb4e2b52cbfd96
parent79a93bcb2111b960c486da59f47e6c647c8930ae (diff)
parent0d96f25f2e3bce6613048be621d9a8c8e6c6ae01 (diff)
downloadPROJ-a42b447021a2f337d66d1e30d4880cd2be08932a.tar.gz
PROJ-a42b447021a2f337d66d1e30d4880cd2be08932a.zip
Merge pull request #2661 from OSGeo/backport-2660-to-8.0
[Backport 8.0] getCRSInfoList(): make result order deterministic (by increasing auth_name, code)
-rw-r--r--src/iso19111/factory.cpp29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/iso19111/factory.cpp b/src/iso19111/factory.cpp
index f533000a..3c93803e 100644
--- a/src/iso19111/factory.cpp
+++ b/src/iso19111/factory.cpp
@@ -5642,19 +5642,21 @@ AuthorityFactory::getDescriptionText(const std::string &code) const {
*/
std::list<AuthorityFactory::CRSInfo> AuthorityFactory::getCRSInfoList() const {
- const auto getSqlArea = [](const std::string &table_name) {
- return "JOIN usage u ON "
- "u.object_table_name = '" +
- table_name +
- "' AND "
+ const auto getSqlArea = [](const char* table_name) {
+ std::string sql(
+ "JOIN usage u ON u.object_table_name = '");
+ sql += table_name;
+ sql += "' AND "
"u.object_auth_name = c.auth_name AND "
"u.object_code = c.code "
"JOIN extent a "
"ON a.auth_name = u.extent_auth_name AND "
"a.code = u.extent_code ";
+ return sql;
};
- std::string sql = "SELECT c.auth_name, c.code, c.name, c.type, "
+ std::string sql = "SELECT * FROM ("
+ "SELECT c.auth_name, c.code, c.name, c.type, "
"c.deprecated, "
"a.west_lon, a.south_lat, a.east_lon, a.north_lat, "
"a.description, NULL FROM geodetic_crs c " +
@@ -5669,9 +5671,9 @@ std::list<AuthorityFactory::CRSInfo> AuthorityFactory::getCRSInfoList() const {
"c.deprecated, "
"a.west_lon, a.south_lat, a.east_lon, a.north_lat, "
"a.description, cm.name AS conversion_method_name FROM "
- "projected_crs c " +
- getSqlArea("projected_crs") +
- "LEFT JOIN conversion_table conv ON "
+ "projected_crs c ";
+ sql += getSqlArea("projected_crs");
+ sql += "LEFT JOIN conversion_table conv ON "
"c.conversion_auth_name = conv.auth_name AND "
"c.conversion_code = conv.code "
"LEFT JOIN conversion_method cm ON "
@@ -5685,8 +5687,8 @@ std::list<AuthorityFactory::CRSInfo> AuthorityFactory::getCRSInfoList() const {
sql += "SELECT c.auth_name, c.code, c.name, 'vertical', "
"c.deprecated, "
"a.west_lon, a.south_lat, a.east_lon, a.north_lat, "
- "a.description, NULL FROM vertical_crs c " +
- getSqlArea("vertical_crs");
+ "a.description, NULL FROM vertical_crs c ";
+ sql += getSqlArea("vertical_crs");
if (d->hasAuthorityRestriction()) {
sql += " WHERE c.auth_name = ?";
params.emplace_back(d->authority());
@@ -5695,12 +5697,13 @@ std::list<AuthorityFactory::CRSInfo> AuthorityFactory::getCRSInfoList() const {
sql += "SELECT c.auth_name, c.code, c.name, 'compound', "
"c.deprecated, "
"a.west_lon, a.south_lat, a.east_lon, a.north_lat, "
- "a.description, NULL FROM compound_crs c " +
- getSqlArea("compound_crs");
+ "a.description, NULL FROM compound_crs c ";
+ sql += getSqlArea("compound_crs");
if (d->hasAuthorityRestriction()) {
sql += " WHERE c.auth_name = ?";
params.emplace_back(d->authority());
}
+ sql += ") r ORDER BY auth_name, code";
auto sqlRes = d->run(sql, params);
std::list<AuthorityFactory::CRSInfo> res;
for (const auto &row : sqlRes) {