Skip to content
Permalink
Browse files

Add method to retrieve destination CRS from QgsDistanceArea

  • Loading branch information
nyalldawson committed Jan 4, 2019
1 parent dbf8fe6 commit ebd104466e8307a69596f241e0710862062b3050
@@ -64,6 +64,19 @@ Sets source spatial reference system ``crs``.
Returns the source spatial reference system.

.. seealso:: :py:func:`setSourceCrs`

.. seealso:: :py:func:`ellipsoidCrs`
%End

QgsCoordinateReferenceSystem ellipsoidCrs() const;
%Docstring
Returns the ellipsoid (destination) spatial reference system.

.. seealso:: :py:func:`sourceCrs`

.. seealso:: :py:func:`ellipsoid`

.. versionadded:: 3.6
%End

bool setEllipsoid( const QString &ellipsoid );
@@ -99,6 +112,8 @@ ellipsoid if a valid ellipsoid has been set.
.. seealso:: :py:func:`setEllipsoid`

.. seealso:: :py:func:`willUseEllipsoid`

.. seealso:: :py:func:`ellipsoidCrs`
%End

double ellipsoidSemiMajor() const;
@@ -71,9 +71,18 @@ class CORE_EXPORT QgsDistanceArea
/**
* Returns the source spatial reference system.
* \see setSourceCrs()
* \see ellipsoidCrs()
*/
QgsCoordinateReferenceSystem sourceCrs() const { return mCoordTransform.sourceCrs(); }

/**
* Returns the ellipsoid (destination) spatial reference system.
* \see sourceCrs()
* \see ellipsoid()
* \since QGIS 3.6
*/
QgsCoordinateReferenceSystem ellipsoidCrs() const { return mCoordTransform.destinationCrs(); }

/**
* Sets the \a ellipsoid by its acronym. Known ellipsoid acronyms can be
* retrieved using QgsEllipsoidUtils::acronyms().
@@ -98,6 +107,7 @@ class CORE_EXPORT QgsDistanceArea
* ellipsoid if a valid ellipsoid has been set.
* \see setEllipsoid()
* \see willUseEllipsoid()
* \see ellipsoidCrs()
*/
QString ellipsoid() const { return mEllipsoid; }

@@ -43,6 +43,12 @@ def testCrs(self):
da.setSourceCrs(crs, QgsProject.instance().transformContext())
self.assertEqual(da.sourceCrs().srsid(), crs.srsid())

self.assertFalse(da.ellipsoidCrs().isValid())
da.setEllipsoid("GRS80")
self.assertEqual(da.ellipsoidCrs().authid(), 'EPSG:4019')
da.setEllipsoid("WGS84")
self.assertEqual(da.ellipsoidCrs().authid(), 'EPSG:4030')

def testMeasureLine(self):
# +-+
# | |

0 comments on commit ebd1044

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