Skip to content

Commit f2db489

Browse files
committed
Use compound crs workaround only on proj < 9.6
Upstream bug was fixed in OSGeo/PROJ#4333
1 parent 203508a commit f2db489

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/core/proj/qgscoordinatetransform.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,10 @@ QgsRectangle QgsCoordinateTransform::transformBoundingBox( const QgsRectangle &r
639639
ProjData projData = d->threadLocalProjData();
640640
PJ_CONTEXT *projContext = QgsProjContext::get();
641641

642+
#if PROJ_VERSION_MAJOR< 9 || (PROJ_VERSION_MAJOR==9 && PROJ_VERSION_MINOR<6)
643+
// if source or destination crs include vertical components, we need to demote them to
644+
// 2d crs first, otherwise proj_trans_bounds fails on proj < 9.6 (see https://github.com/OSGeo/PROJ/pull/4333)
645+
642646
QgsProjUtils::proj_pj_unique_ptr srcCrs( proj_get_source_crs( projContext, projData ) );
643647
QgsProjUtils::proj_pj_unique_ptr destCrs( proj_get_target_crs( projContext, projData ) );
644648

@@ -648,13 +652,12 @@ QgsRectangle QgsCoordinateTransform::transformBoundingBox( const QgsRectangle &r
648652
if ( QgsProjUtils::hasVerticalAxis( srcCrs.get() ) ||
649653
QgsProjUtils::hasVerticalAxis( destCrs.get() ) )
650654
{
651-
// if source or destination crs include vertical components, we need to demote them to
652-
// 2d crs first, otherwise proj_trans_bounds fails
653655
srcCrsHorizontal = QgsProjUtils::crsToHorizontalCrs( srcCrs.get() );
654656
destCrsHorizontal = QgsProjUtils::crsToHorizontalCrs( destCrs.get() );
655657
transform2D.reset( proj_create_crs_to_crs_from_pj( projContext, srcCrsHorizontal.get(), destCrsHorizontal.get(), nullptr, nullptr ) );
656658
projData = transform2D.get();
657659
}
660+
#endif
658661

659662
double transXMin = 0;
660663
double transYMin = 0;

0 commit comments

Comments
 (0)