Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Add a context getter to QgsCoordinateTransform
- Loading branch information
|
@@ -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): |
|
|
""" |
|
|