Skip to content
Permalink
Browse files

Use proj_normalize_for_visualization on proj >= 6.1

  • Loading branch information
nyalldawson committed Apr 1, 2019
1 parent 83dc159 commit e2396aadf35624edb7a623b7735f1a74361a4481
Showing with 11 additions and 0 deletions.
  1. +11 −0 src/core/qgscoordinatetransform_p.cpp
@@ -171,6 +171,8 @@ bool QgsCoordinateTransformPrivate::initialize()
ProjData res = threadLocalProjData();

#if PROJ_VERSION_MAJOR>=6
#if PROJ_VERSION_MINOR<1
// because proj 6.0 does not have proj_normalize_for_visualization - we have to handle this manually and inefficiently!
PJ_CONTEXT *context = QgsProjContext::get();
QgsProjUtils::proj_pj_unique_ptr sourceCrs( proj_get_source_crs( context, res ) );
if ( sourceCrs )
@@ -179,6 +181,7 @@ bool QgsCoordinateTransformPrivate::initialize()
if ( destCrs )
mDestAxisOrderSwapped = QgsProjUtils::axisOrderIsSwapped( destCrs.get() );
#endif
#endif

#ifdef COORDINATE_TRANSFORM_VERBOSE
QgsDebugMsg( "From proj : " + mSourceCRS.toProj4() );
@@ -279,8 +282,16 @@ ProjData QgsCoordinateTransformPrivate::threadLocalProjData()
locker.changeMode( QgsReadWriteLocker::Write );

#if PROJ_VERSION_MAJOR>=6
#if PROJ_VERSION_MINOR>=1
QgsProjUtils::proj_pj_unique_ptr transform( proj_create_crs_to_crs( context, mSourceProjString.toUtf8().constData(), mDestProjString.toUtf8().constData(), nullptr ) );
// transform may have either the source or destination CRS using swapped axis order. For QGIS, we ALWAYS need regular x/y axis order
ProjData res = proj_normalize_for_visualization( context, transform.get() );
mProjProjections.insert( reinterpret_cast< uintptr_t>( context ), res );
#else
// proj 6.0 does not have proj_normalize_for_visualization - we have to handle this manually and inefficiently!
ProjData res = proj_create_crs_to_crs( context, mSourceProjString.toUtf8().constData(), mDestProjString.toUtf8().constData(), nullptr );
mProjProjections.insert( reinterpret_cast< uintptr_t>( context ), res );
#endif
#else
#ifdef USE_THREAD_LOCAL
QPair<projPJ, projPJ> res = qMakePair( pj_init_plus_ctx( mProjContext.get(), mSourceProjString.toUtf8() ),

0 comments on commit e2396aa

Please sign in to comment.
You can’t perform that action at this time.