From 6dca8bdc057a454b599438c6caf92825880f3a87 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Thu, 20 Jan 2022 17:32:36 +0100 Subject: 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. --- test/unit/test_factory.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'test/unit/test_factory.cpp') diff --git a/test/unit/test_factory.cpp b/test/unit/test_factory.cpp index 9abade09..63931a5d 100644 --- a/test/unit/test_factory.cpp +++ b/test/unit/test_factory.cpp @@ -2763,6 +2763,47 @@ TEST_F(FactoryWithTmpDatabase, lookForGridInfo) { // --------------------------------------------------------------------------- +TEST_F(FactoryWithTmpDatabase, + lookForGridInfo_from_old_name_with_new_grid_available) { + createStructure(); + + ASSERT_TRUE(execute("INSERT INTO grid_alternatives(original_grid_name," + "proj_grid_name, " + "old_proj_grid_name, " + "proj_grid_format, " + "proj_method, " + "inverse_direction, " + "package_name, " + "url, direct_download, open_license, directory) " + "VALUES (" + "'NOT-YET-IN-GRID-TRANSFORMATION-original_grid_name', " + "'tests/egm96_15_uncompressed_truncated.tif', " + "'old_name.gtx', " + "'NTv2', " + "'hgridshift', " + "0, " + "NULL, " + "'url', 1, 1, NULL);")) + << last_error(); + + std::string fullFilename; + std::string packageName; + std::string url; + bool directDownload = false; + bool openLicense = false; + bool gridAvailable = false; + EXPECT_TRUE(DatabaseContext::create(m_ctxt)->lookForGridInfo( + "old_name.gtx", false, fullFilename, packageName, url, directDownload, + openLicense, gridAvailable)); + EXPECT_TRUE( + fullFilename.find("tests/egm96_15_uncompressed_truncated.tif") != + std::string::npos) + << fullFilename; + EXPECT_EQ(gridAvailable, true); +} + +// --------------------------------------------------------------------------- + TEST_F(FactoryWithTmpDatabase, custom_geodetic_crs) { createStructure(); populateWithFakeEPSG(); -- cgit v1.2.3