@@ -1694,6 +1694,37 @@ TEST_F(CApi, transformation_from_boundCRS) {
16941694
16951695// ---------------------------------------------------------------------------
16961696
1697+ TEST_F (CApi,
1698+ proj_create_from_database_grid_alternative_null_old_proj_grid_name) {
1699+ // EPSG:9484 uses grid "href2008a.bin" whose grid_alternatives entry has
1700+ // proj_grid_name = "no_kv_href2008a.tif" but old_proj_grid_name IS NULL.
1701+ // Without the database context in pj_obj_create(),
1702+ // substitutePROJAlternativeGridNames() cannot resolve the grid name,
1703+ // leaving the original "href2008a.bin" in the PROJ string. With the fix,
1704+ // the CDN name "no_kv_href2008a.tif" is used instead.
1705+ //
1706+ // Enable network so that pj_obj_create() sets defer_grid_opening=true,
1707+ // allowing the pipeline to be created even without the grid file on disk.
1708+ proj_context_set_enable_network (m_ctxt, 1 );
1709+
1710+ auto op = proj_create_from_database (m_ctxt, " EPSG" , " 9484" ,
1711+ PJ_CATEGORY_COORDINATE_OPERATION, false ,
1712+ nullptr );
1713+ ASSERT_NE (op, nullptr );
1714+ ObjectKeeper keeper (op);
1715+
1716+ auto info = proj_pj_info (op);
1717+ ASSERT_NE (info.definition , nullptr );
1718+ EXPECT_TRUE (std::string (info.definition ).find (" no_kv_href2008a.tif" ) !=
1719+ std::string::npos)
1720+ << " Expected CDN grid name 'no_kv_href2008a.tif' in definition, got: "
1721+ << info.definition ;
1722+
1723+ proj_context_set_enable_network (m_ctxt, 0 );
1724+ }
1725+
1726+ // ---------------------------------------------------------------------------
1727+
16971728TEST_F (CApi, proj_coordoperation_get_grid_used) {
16981729 auto op = proj_create_from_database (m_ctxt, " EPSG" , " 1312" ,
16991730 PJ_CATEGORY_COORDINATE_OPERATION, true ,
0 commit comments