Fix pj_obj_create() grid alternative resolution when old_proj_grid_name is NULL#4701
Merged
rouault merged 1 commit intoOSGeo:masterfrom Mar 7, 2026
Conversation
…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
approved these changes
Mar 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The commit changed pj_obj_create() to pass nullptr as the database context to PROJStringFormatter::create(), which prevents substitutePROJAlternativeGridNames() from resolving grid names via the grid_alternatives table. The reson for the change was to add support for that plain pipeline strings should work without a proj.db.
Example: proj_create_from_database("EPSG","9484") returns a pipeline with the original grid name
href2008a.bininstead of the CDN nameno_kv_href2008a.tif, causing downstream failures.Fix: Use the database context if it is already open (e.g. when called from proj_create_from_database), but do not open it otherwise — preserving the original intent of 63c491e that plain pipeline strings work without proj.db.