Skip to content
Permalink
Browse files

Avoid doing unnecessary work calculating coordinate transform when the

src and dest CRSes are equal

(cherry picked from commit 96252f3)
(cherry picked from commit a2b53be)
  • Loading branch information
nyalldawson committed Mar 13, 2020
1 parent 69c4ffe commit abcb9b9762e2f7ec479e5cb9c80a8bd44fff6f8f
Showing with 13 additions and 17 deletions.
  1. +13 −17 src/core/qgscoordinatetransform_p.cpp
@@ -84,7 +84,8 @@ QgsCoordinateTransformPrivate::QgsCoordinateTransformPrivate( const QgsCoordinat
: mSourceCRS( source )
, mDestCRS( destination )
{
calculateTransforms( context );
if ( mSourceCRS != mDestCRS )
calculateTransforms( context );
}
Q_NOWARN_DEPRECATED_POP

@@ -169,6 +170,14 @@ bool QgsCoordinateTransformPrivate::initialize()

mIsValid = true;

if ( mSourceCRS == mDestCRS )
{
// If the source and destination projection are the same, set the short
// circuit flag (no transform takes place)
mShortCircuit = true;
return true;
}

// init the projections (destination and source)
freeProj();

@@ -245,22 +254,9 @@ bool QgsCoordinateTransformPrivate::initialize()
}
#endif

//XXX todo overload == operator for QgsCoordinateReferenceSystem
//at the moment srs.parameters contains the whole proj def...soon it won't...
//if (mSourceCRS->toProj() == mDestCRS->toProj())
if ( mSourceCRS == mDestCRS )
{
// If the source and destination projection are the same, set the short
// circuit flag (no transform takes place)
mShortCircuit = true;
QgsDebugMsgLevel( QStringLiteral( "Source/Dest CRS equal, shortcircuit is set." ), 3 );
}
else
{
// Transform must take place
mShortCircuit = false;
QgsDebugMsgLevel( QStringLiteral( "Source/Dest CRS not equal, shortcircuit is not set." ), 3 );
}
// Transform must take place
mShortCircuit = false;

return mIsValid;
}

0 comments on commit abcb9b9

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