Skip to content

[Backport 9.8] Fix pj_obj_create() grid alternative resolution when old_proj_grid_name is NULL#4703

Merged
rouault merged 1 commit into9.8from
backport-4701-to-9.8
Mar 7, 2026
Merged

[Backport 9.8] Fix pj_obj_create() grid alternative resolution when old_proj_grid_name is NULL#4703
rouault merged 1 commit into9.8from
backport-4701-to-9.8

Conversation

@rouault
Copy link
Copy Markdown
Member

@rouault rouault commented Mar 7, 2026

Backport #4701
Authored by: @phaarnes

…olution

When pj_obj_create() exports a coordinate operation to a PROJ string, it
previously passed nullptr as the database context to PROJStringFormatter.
This prevented substitutePROJAlternativeGridNames() from resolving grid
names via the grid_alternatives table.

For grid transformations where old_proj_grid_name is NULL (153 entries in
the standard PROJ database), the file-level fallback (getProjGridName)
cannot resolve the grid because it queries old_proj_grid_name. Only
lookForGridAlternative (which queries original_grid_name) can resolve
these grids, but it requires a database context.

This change adds getDatabaseContextIfOpen() to projCppContext, which
returns the cached database context if already opened (e.g. from a prior
proj_create_from_database call), without attempting to open proj.db.
This preserves the original intent of commit 63c491e that callers
using plain pipeline strings can run without proj.db.

Adds a test for EPSG:9484 (grid href2008a.bin -> no_kv_href2008a.tif)
which has a NULL old_proj_grid_name.
@rouault rouault added this to the 9.8,1 milestone Mar 7, 2026
@rouault rouault merged commit 25efd86 into 9.8 Mar 7, 2026
57 of 61 checks passed
@rouault rouault deleted the backport-4701-to-9.8 branch March 7, 2026 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants