Skip to content

Commit

Permalink
qgscoordinatetransform_p.cpp: avoid issues when opening projects usin…
Browse files Browse the repository at this point in the history
…g PROJ < 7 grid names (fixes #45470)

Only use proj_coordoperation_is_instantiable() if PROJ networking is enabled.
The reason is that proj_coordoperation_is_instantiable() in PROJ < 9.0
does not work properly when a coordinate operation refers to a PROJ < 7 grid name (gtx/gsb)
but the user has installed PROJ >= 7 GeoTIFF grids.
Cf OSGeo/PROJ#3025.
When networking is not enabled, proj_create() will check that all grids are
present, so proj_coordoperation_is_instantiable() is not necessary.
  • Loading branch information
rouault authored and nyalldawson committed Jan 23, 2022
1 parent 4f48163 commit 1cae722
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/core/proj/qgscoordinatetransform_p.cpp
Expand Up @@ -288,7 +288,20 @@ ProjData QgsCoordinateTransformPrivate::threadLocalProjData()
if ( !mProjCoordinateOperation.isEmpty() )
{
transform.reset( proj_create( context, mProjCoordinateOperation.toUtf8().constData() ) );
if ( !transform || !proj_coordoperation_is_instantiable( context, transform.get() ) )
// Only use proj_coordoperation_is_instantiable() if PROJ networking is enabled.
// The reason is that proj_coordoperation_is_instantiable() in PROJ < 9.0
// does not work properly when a coordinate operation refers to a PROJ < 7 grid name (gtx/gsb)
// but the user has installed PROJ >= 7 GeoTIFF grids.
// Cf https://github.com/OSGeo/PROJ/pull/3025.
// When networking is not enabled, proj_create() will check that all grids are
// present, so proj_coordoperation_is_instantiable() is not necessary.
if ( !transform
#if PROJ_VERSION_MAJOR >= 7
|| (
proj_context_is_network_enabled( context ) &&
!proj_coordoperation_is_instantiable( context, transform.get() ) )
#endif
)
{
if ( sMissingGridUsedByContextHandler )
{
Expand Down

0 comments on commit 1cae722

Please sign in to comment.