Skip to content
Permalink
Browse files

Fix failing test

  • Loading branch information
nyalldawson committed Dec 15, 2017
1 parent 1422d53 commit 40e551da17360fb46e49a9fcc93c1eec467d4f86
@@ -53,7 +53,7 @@ QgsCoordinateTransform::QgsCoordinateTransform( const QgsCoordinateReferenceSyst
{
d = new QgsCoordinateTransformPrivate( source, destination, QgsCoordinateTransformContext() );

if ( !d->mSourceCRS.isValid() || !d->mDestCRS.isValid() )
if ( !d->checkValidity() )
return;

if ( !setFromCache( d->mSourceCRS, d->mDestCRS, d->mSourceDatumTransform, d->mDestinationDatumTransform ) )
@@ -70,7 +70,7 @@ QgsCoordinateTransform::QgsCoordinateTransform( const QgsCoordinateReferenceSyst
d->mHasContext = true;
#endif

if ( !d->mSourceCRS.isValid() || !d->mDestCRS.isValid() )
if ( !d->checkValidity() )
return;

if ( !setFromCache( d->mSourceCRS, d->mDestCRS, d->mSourceDatumTransform, d->mDestinationDatumTransform ) )
@@ -87,7 +87,7 @@ QgsCoordinateTransform::QgsCoordinateTransform( const QgsCoordinateReferenceSyst
d->mHasContext = true;
#endif

if ( !d->mSourceCRS.isValid() || !d->mDestCRS.isValid() )
if ( !d->checkValidity() )
return;

if ( !setFromCache( d->mSourceCRS, d->mDestCRS, d->mSourceDatumTransform, d->mDestinationDatumTransform ) )
@@ -104,7 +104,7 @@ QgsCoordinateTransform::QgsCoordinateTransform( const QgsCoordinateReferenceSyst
d->mHasContext = true; // not strictly true, but we don't need to worry if datums have been explicitly set
#endif

if ( !d->mSourceCRS.isValid() || !d->mDestCRS.isValid() )
if ( !d->checkValidity() )
return;

if ( !setFromCache( d->mSourceCRS, d->mDestCRS, d->mSourceDatumTransform, d->mDestinationDatumTransform ) )
@@ -131,7 +131,7 @@ void QgsCoordinateTransform::setSourceCrs( const QgsCoordinateReferenceSystem &c
{
d.detach();
d->mSourceCRS = crs;
if ( !d->mSourceCRS.isValid() || !d->mDestCRS.isValid() )
if ( !d->checkValidity() )
return;

d->calculateTransforms();
@@ -145,7 +145,7 @@ void QgsCoordinateTransform::setDestinationCrs( const QgsCoordinateReferenceSyst
{
d.detach();
d->mDestCRS = crs;
if ( !d->mSourceCRS.isValid() || !d->mDestCRS.isValid() )
if ( !d->checkValidity() )
return;

d->calculateTransforms();
@@ -163,7 +163,7 @@ void QgsCoordinateTransform::setContext( const QgsCoordinateTransformContext &co
#ifdef QGISDEBUG
d->mHasContext = true;
#endif
if ( !d->mSourceCRS.isValid() || !d->mDestCRS.isValid() )
if ( !d->checkValidity() )
return;

d->calculateTransforms();
@@ -93,11 +93,25 @@ QgsCoordinateTransformPrivate::~QgsCoordinateTransformPrivate()
freeProj();
}

bool QgsCoordinateTransformPrivate::initialize()
bool QgsCoordinateTransformPrivate::checkValidity()
{
if ( !mSourceCRS.isValid() || !mDestCRS.isValid() )
{
invalidate();
return false;
}
return true;
}

void QgsCoordinateTransformPrivate::invalidate()
{
mShortCircuit = true;
mIsValid = false;
}

bool QgsCoordinateTransformPrivate::initialize()
{
invalidate();
if ( !mSourceCRS.isValid() )
{
// Pass through with no projection since we have no idea what the layer
@@ -81,6 +81,10 @@ class QgsCoordinateTransformPrivate : public QSharedData

~QgsCoordinateTransformPrivate();

bool checkValidity();

void invalidate();

bool initialize();

void calculateTransforms();

0 comments on commit 40e551d

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