aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2022-01-20 17:32:36 +0100
committerEven Rouault <even.rouault@spatialys.com>2022-01-20 17:32:39 +0100
commit6dca8bdc057a454b599438c6caf92825880f3a87 (patch)
treea2c160f92a73e6e216ef9176a2107e6aedccda26 /src
parent2fc66ca67d4e2264b2e3e19bbef53e7daf19c62c (diff)
downloadPROJ-6dca8bdc057a454b599438c6caf92825880f3a87.tar.gz
PROJ-6dca8bdc057a454b599438c6caf92825880f3a87.zip
lookForGridInfo(): make it work properly when passed the old PROJ name
Fixes https://github.com/qgis/QGIS/issues/45470 That is, if the file for the old PROJ name is not found, but the file for the new PROJ name is found, then use the later for fullFilename and gridAvailable.
Diffstat (limited to 'src')
-rw-r--r--src/iso19111/factory.cpp26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/iso19111/factory.cpp b/src/iso19111/factory.cpp
index 3088f468..52c3f82b 100644
--- a/src/iso19111/factory.cpp
+++ b/src/iso19111/factory.cpp
@@ -3272,7 +3272,9 @@ bool DatabaseContext::lookForGridInfo(
"grid_alternatives.open_license, "
"grid_packages.open_license AS package_open_license, "
"grid_alternatives.direct_download, "
- "grid_packages.direct_download AS package_direct_download "
+ "grid_packages.direct_download AS package_direct_download, "
+ "grid_alternatives.proj_grid_name, "
+ "grid_alternatives.old_proj_grid_name "
"FROM grid_alternatives "
"LEFT JOIN grid_packages ON "
"grid_alternatives.package_name = grid_packages.package_name "
@@ -3286,6 +3288,28 @@ bool DatabaseContext::lookForGridInfo(
openLicense = (row[3].empty() ? row[4] : row[3]) == "1";
directDownload = (row[5].empty() ? row[6] : row[5]) == "1";
+ const auto &proj_grid_name = row[7];
+ const auto &old_proj_grid_name = row[8];
+ if (proj_grid_name != old_proj_grid_name &&
+ old_proj_grid_name == projFilename) {
+ std::string fullFilenameNewName;
+ fullFilenameNewName.resize(2048);
+ if (d->pjCtxt() == nullptr) {
+ d->setPjCtxt(pj_get_default_ctx());
+ }
+ int errno_before = proj_context_errno(d->pjCtxt());
+ bool gridAvailableWithNewName =
+ pj_find_file(d->pjCtxt(), proj_grid_name.c_str(),
+ &fullFilenameNewName[0],
+ fullFilenameNewName.size() - 1) != 0;
+ proj_context_errno_set(d->pjCtxt(), errno_before);
+ fullFilenameNewName.resize(strlen(fullFilenameNewName.c_str()));
+ if (gridAvailableWithNewName) {
+ gridAvailable = true;
+ fullFilename = fullFilenameNewName;
+ }
+ }
+
if (considerKnownGridsAsAvailable &&
(!packageName.empty() || (!url.empty() && openLicense))) {
gridAvailable = true;