Skip to content

Commit

Permalink
Use the GeographicLib routines exposed through PROJ for all ellipsoidal
Browse files Browse the repository at this point in the history
calculations

Since GRASS upstream is moving away from the previous calculations which
all of QGIS' ellipsoidal distance/areas formulas are based on, let's
follow suit and delegate all these calculations to the GeographicLib
routines exposed through the PROJ api.

Refs OSGeo/grass#1283
  • Loading branch information
nyalldawson committed Feb 25, 2021
1 parent 54e4597 commit cc9cbec
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 329 deletions.
22 changes: 9 additions & 13 deletions python/core/auto_generated/qgsdistancearea.sip.in
Expand Up @@ -28,6 +28,8 @@ of all measured geometries must first be specified using :py:func:`~setSourceCrs
Usually, the measurements returned by :py:class:`QgsDistanceArea` are in meters. If no valid
ellipsoid is set, then the units may not be meters. The units can be retrieved
by calling :py:func:`~lengthUnits` and :py:func:`~areaUnits`.

Internally, the GeographicLib library is used to calculate all ellipsoid based measurements.
%End

%TypeHeaderCode
Expand All @@ -38,6 +40,12 @@ by calling :py:func:`~lengthUnits` and :py:func:`~areaUnits`.
QgsDistanceArea();
%Docstring
Constructor
%End
~QgsDistanceArea();

QgsDistanceArea( const QgsDistanceArea &other );
%Docstring
Copy constructor
%End

bool willUseEllipsoid() const;
Expand Down Expand Up @@ -348,26 +356,14 @@ different areal unit.
QgsPointXY computeSpheroidProject( const QgsPointXY &p1, double distance = 1, double azimuth = M_PI_2 ) const;
%Docstring
Given a location, an azimuth and a distance, computes the
location of the projected point. Based on Vincenty's formula
for the geodetic direct problem as described in "Geocentric
Datum of Australia Technical Manual", Chapter 4.
location of the projected point.

:param p1: - location of first geographic (latitude/longitude) point as degrees.
:param distance: - distance in meters.
:param azimuth: - azimuth in radians, clockwise from North

:return: p2 - location of projected point as longitude/latitude.

.. note::

code (and documentation) taken from rttopo project
https://git.osgeo.org/gogs/rttopo/librttopo

- spheroid_project.spheroid_project(...)
- Valid bounds checking for degrees (latitude=+- 85.05115) is based values used for
-> 'WGS84 Web Mercator (Auxiliary Sphere)' calculations
--> latitudes outside these bounds cause the calculations to become unstable and can return invalid results

.. versionadded:: 3.0
%End

Expand Down

0 comments on commit cc9cbec

Please sign in to comment.