Skip to content
Permalink
Browse files

In debug builds, throw a warning when transforming coordinates

and no coordinate transform context has been set.
  • Loading branch information
nyalldawson committed Dec 15, 2017
1 parent 86d9492 commit 1a73fef4a7738b70a6ea2bdc067757de7b38e4e2
@@ -54,11 +54,17 @@ QgsCoordinateTransform::QgsCoordinateTransform( const QgsCoordinateReferenceSyst
QgsCoordinateTransform::QgsCoordinateTransform( const QgsCoordinateReferenceSystem &source, const QgsCoordinateReferenceSystem &destination, const QgsCoordinateTransformContext &context )
{
d = new QgsCoordinateTransformPrivate( source, destination, context );
#ifdef QGISDEBUG
d->mHasContext = true;
#endif
}

QgsCoordinateTransform::QgsCoordinateTransform( const QgsCoordinateReferenceSystem &source, const QgsCoordinateReferenceSystem &destination, const QgsProject *project )
{
d = new QgsCoordinateTransformPrivate( source, destination, project ? project->transformContext() : QgsCoordinateTransformContext() );
#ifdef QGISDEBUG
d->mHasContext = true;
#endif
}

QgsCoordinateTransform::QgsCoordinateTransform( const QgsCoordinateTransform &o )
@@ -93,6 +99,9 @@ void QgsCoordinateTransform::setContext( const QgsCoordinateTransformContext &co
{
d.detach();
d->mContext = context;
#ifdef QGISDEBUG
d->mHasContext = true;
#endif
d->calculateTransforms();
d->initialize();
}
@@ -69,6 +69,9 @@ QgsCoordinateTransformPrivate::QgsCoordinateTransformPrivate( const QgsCoordinat
, mSourceCRS( other.mSourceCRS )
, mDestCRS( other.mDestCRS )
, mContext( other.mContext )
#ifdef QGISDEBUG
, mHasContext( other.mHasContext )
#endif
, mSourceDatumTransform( other.mSourceDatumTransform )
, mDestinationDatumTransform( other.mDestinationDatumTransform )
{
@@ -106,6 +109,11 @@ bool QgsCoordinateTransformPrivate::initialize()

mIsValid = true;

#ifdef QGISDEBUG
if ( !mHasContext )
qWarning( "No QgsCoordinateTransformContext context set for transform" );
#endif

int sourceDatumTransform = mSourceDatumTransform;
int destDatumTransform = mDestinationDatumTransform;
bool useDefaultDatumTransform = ( sourceDatumTransform == - 1 && destDatumTransform == -1 );
@@ -103,6 +103,10 @@ class QgsCoordinateTransformPrivate : public QSharedData
//! Transform context
QgsCoordinateTransformContext mContext;

#ifdef QGISDEBUG
bool mHasContext = false;
#endif

QString mSourceProjString;
QString mDestProjString;

0 comments on commit 1a73fef

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