Skip to content
Permalink
Browse files

Add a context getter to QgsCoordinateTransform

  • Loading branch information
nyalldawson committed Jul 4, 2018
1 parent a04d228 commit 2695e000422b48b3772a39c7a4040f29d43d0d61
@@ -156,7 +156,19 @@ Sets the destination coordinate reference system.
Sets the ``context`` in which the coordinate transform should be
calculated.

.. seealso:: :py:func:`context`

.. versionadded:: 3.0
%End

QgsCoordinateTransformContext context() const;
%Docstring
Returns the context in which the coordinate transform will be
calculated.

.. seealso:: :py:func:`setContext`

.. versionadded:: 3.4
%End

QgsCoordinateReferenceSystem sourceCrs() const;
@@ -185,6 +185,11 @@ void QgsCoordinateTransform::setContext( const QgsCoordinateTransformContext &co
}
}

QgsCoordinateTransformContext QgsCoordinateTransform::context() const
{
return mContext;
}

QgsCoordinateReferenceSystem QgsCoordinateTransform::sourceCrs() const
{
return d->mSourceCRS;
@@ -175,10 +175,19 @@ class CORE_EXPORT QgsCoordinateTransform
/**
* Sets the \a context in which the coordinate transform should be
* calculated.
* \see context()
* \since QGIS 3.0
*/
void setContext( const QgsCoordinateTransformContext &context );

/**
* Returns the context in which the coordinate transform will be
* calculated.
* \see setContext()
* \since QGIS 3.4
*/
QgsCoordinateTransformContext context() const;

/**
* Returns the source coordinate reference system, which the transform will
* transform coordinates from.
@@ -76,14 +76,13 @@ void QgsQuickCoordinateTransformer::setSourceCrs( const QgsCoordinateReferenceSy

void QgsQuickCoordinateTransformer::setTransformContext( const QgsCoordinateTransformContext &context )
{
mTransformContext = context;
mCoordinateTransform.setContext( mTransformContext );
mCoordinateTransform.setContext( context );
emit transformContextChanged();
}

QgsCoordinateTransformContext QgsQuickCoordinateTransformer::transformContext() const
{
return mTransformContext;
return mCoordinateTransform.context();
}

void QgsQuickCoordinateTransformer::updatePosition()
@@ -108,7 +108,6 @@ class QUICK_EXPORT QgsQuickCoordinateTransformer : public QObject
QgsPoint mProjectedPosition;
QgsPoint mSourcePosition;
QgsCoordinateTransform mCoordinateTransform;
QgsCoordinateTransformContext mTransformContext;
};

#endif // QGSQUICKCOORDINATETRANSFORMER_H
@@ -145,6 +145,7 @@ def testContext(self):
3, 4)

transform = QgsCoordinateTransform(QgsCoordinateReferenceSystem('EPSG:28354'), QgsCoordinateReferenceSystem('EPSG:28353'), context)
self.assertEqual(list(transform.context().sourceDestinationDatumTransforms().keys()), [('EPSG:28356', 'EPSG:4283')])
# should be no datum transforms
self.assertEqual(transform.sourceDatumTransformId(), -1)
self.assertEqual(transform.destinationDatumTransformId(), -1)
@@ -193,6 +194,7 @@ def testContext(self):
transform.setContext(context)
self.assertEqual(transform.sourceDatumTransformId(), 3)
self.assertEqual(transform.destinationDatumTransformId(), 4)
self.assertEqual(list(transform.context().sourceDestinationDatumTransforms().keys()), [('EPSG:28356', 'EPSG:4283')])

def testProjectContext(self):
"""

0 comments on commit 2695e00

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