Skip to content
Permalink
Browse files

Avoid some more unnecessary work

(cherry picked from commit 5b2f2cc)
  • Loading branch information
nyalldawson committed Mar 13, 2020
1 parent a2b53be commit e1c2ddc9b236a547f3ca775d192cdc8af7156dce
Showing with 21 additions and 3 deletions.
  1. +12 −3 src/core/qgscoordinatetransform_p.cpp
  2. +9 −0 src/core/qgscoordinatetransformcontext.cpp
@@ -264,9 +264,18 @@ void QgsCoordinateTransformPrivate::calculateTransforms( const QgsCoordinateTran
{
// recalculate datum transforms from context
#if PROJ_VERSION_MAJOR >= 6
mProjCoordinateOperation = context.calculateCoordinateOperation( mSourceCRS, mDestCRS );
mShouldReverseCoordinateOperation = context.mustReverseCoordinateOperation( mSourceCRS, mDestCRS );
mAllowFallbackTransforms = context.allowFallbackTransform( mSourceCRS, mDestCRS );
if ( mSourceCRS.isValid() && mDestCRS.isValid() )
{
mProjCoordinateOperation = context.calculateCoordinateOperation( mSourceCRS, mDestCRS );
mShouldReverseCoordinateOperation = context.mustReverseCoordinateOperation( mSourceCRS, mDestCRS );
mAllowFallbackTransforms = context.allowFallbackTransform( mSourceCRS, mDestCRS );
}
else
{
mProjCoordinateOperation.clear();
mShouldReverseCoordinateOperation = false;
mAllowFallbackTransforms = false;
}
#else
Q_NOWARN_DEPRECATED_PUSH
QgsDatumTransform::TransformPair transforms = context.calculateDatumTransforms( mSourceCRS, mDestCRS );
@@ -191,6 +191,9 @@ QgsDatumTransform::TransformPair QgsCoordinateTransformContext::calculateDatumTr
QString QgsCoordinateTransformContext::calculateCoordinateOperation( const QgsCoordinateReferenceSystem &source, const QgsCoordinateReferenceSystem &destination ) const
{
#if PROJ_VERSION_MAJOR>=6
if ( !source.isValid() || !destination.isValid() )
return QString();

d->mLock.lockForRead();
QgsCoordinateTransformContextPrivate::OperationDetails res = d->mSourceDestDatumTransforms.value( qMakePair( source, destination ), QgsCoordinateTransformContextPrivate::OperationDetails() );
if ( res.operation.isEmpty() )
@@ -210,6 +213,9 @@ QString QgsCoordinateTransformContext::calculateCoordinateOperation( const QgsCo
bool QgsCoordinateTransformContext::allowFallbackTransform( const QgsCoordinateReferenceSystem &source, const QgsCoordinateReferenceSystem &destination ) const
{
#if PROJ_VERSION_MAJOR>=6
if ( !source.isValid() || !destination.isValid() )
return false;

d->mLock.lockForRead();
QgsCoordinateTransformContextPrivate::OperationDetails res = d->mSourceDestDatumTransforms.value( qMakePair( source, destination ), QgsCoordinateTransformContextPrivate::OperationDetails() );
if ( res.operation.isEmpty() )
@@ -229,6 +235,9 @@ bool QgsCoordinateTransformContext::allowFallbackTransform( const QgsCoordinateR
bool QgsCoordinateTransformContext::mustReverseCoordinateOperation( const QgsCoordinateReferenceSystem &source, const QgsCoordinateReferenceSystem &destination ) const
{
#if PROJ_VERSION_MAJOR>=6
if ( !source.isValid() || !destination.isValid() )
return false;

d->mLock.lockForRead();
QgsCoordinateTransformContextPrivate::OperationDetails res = d->mSourceDestDatumTransforms.value( qMakePair( source, destination ), QgsCoordinateTransformContextPrivate::OperationDetails() );
if ( !res.operation.isEmpty() )

0 comments on commit e1c2ddc

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