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 Nov 5, 2017
1 parent 24cd144 commit a88dcdf57806ca4c34ddc0b4e7724e583af2623d
@@ -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();
}
@@ -65,6 +65,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 )
{
@@ -102,6 +105,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 );
@@ -97,6 +97,10 @@ class QgsCoordinateTransformPrivate : public QSharedData
//! Transform context
QgsCoordinateTransformContext mContext;

#ifdef QGISDEBUG
bool mHasContext = false;
#endif

QString mSourceProjString;
QString mDestProjString;

0 comments on commit a88dcdf

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