1/************************************************************************ 2 * This file has been generated automatically from * 3 * * 4 * src/core/qgsdistancearea.h * 5 * * 6 * Do not edit manually ! Edit header and run scripts/sipify.pl again * 7 ************************************************************************/ 8 9 10 11 12class QgsDistanceArea 13{ 14%Docstring(signature="appended") 15A general purpose distance and area calculator, capable of performing ellipsoid based calculations. 16 17Measurements can either be performed on existing :py:class:`QgsGeometry` objects, or using 18lists of points. 19 20If a valid :py:func:`~ellipsoid` has been set for the :py:class:`QgsDistanceArea`, all calculations will be 21performed using ellipsoidal algorithms (e.g. using Vincenty's formulas). If no 22ellipsoid has been set, all calculations will be performed using Cartesian 23formulas only. The behavior can be determined by calling :py:func:`~willUseEllipsoid`. 24 25In order to perform accurate calculations, the source coordinate reference system 26of all measured geometries must first be specified using :py:func:`~setSourceCrs`. 27 28Usually, the measurements returned by :py:class:`QgsDistanceArea` are in meters. If no valid 29ellipsoid is set, then the units may not be meters. The units can be retrieved 30by calling :py:func:`~lengthUnits` and :py:func:`~areaUnits`. 31 32Internally, the GeographicLib library is used to calculate all ellipsoid based measurements. 33%End 34 35%TypeHeaderCode 36#include "qgsdistancearea.h" 37%End 38 public: 39 40 QgsDistanceArea(); 41%Docstring 42Constructor 43%End 44 ~QgsDistanceArea(); 45 46 QgsDistanceArea( const QgsDistanceArea &other ); 47%Docstring 48Copy constructor 49%End 50 51 bool willUseEllipsoid() const; 52%Docstring 53Returns whether calculations will use the ellipsoid. Calculations will only use the 54ellipsoid if a valid :py:func:`~QgsDistanceArea.ellipsoid` has been set. 55 56.. seealso:: :py:func:`ellipsoid` 57 58.. versionadded:: 2.14 59%End 60 61 void setSourceCrs( const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context ); 62%Docstring 63Sets source spatial reference system ``crs``. 64 65.. seealso:: :py:func:`sourceCrs` 66 67.. versionadded:: 2.2 68%End 69 70 QgsCoordinateReferenceSystem sourceCrs() const; 71%Docstring 72Returns the source spatial reference system. 73 74.. seealso:: :py:func:`setSourceCrs` 75 76.. seealso:: :py:func:`ellipsoidCrs` 77%End 78 79 QgsCoordinateReferenceSystem ellipsoidCrs() const; 80%Docstring 81Returns the ellipsoid (destination) spatial reference system. 82 83.. seealso:: :py:func:`sourceCrs` 84 85.. seealso:: :py:func:`ellipsoid` 86 87.. versionadded:: 3.6 88%End 89 90 bool setEllipsoid( const QString &ellipsoid ); 91%Docstring 92Sets the ``ellipsoid`` by its acronym. Known ellipsoid acronyms can be 93retrieved using :py:func:`QgsEllipsoidUtils.acronyms()`. 94Calculations will only use the ellipsoid if a valid ellipsoid has been set. 95 96:return: ``True`` if ellipsoid was successfully set 97 98.. seealso:: :py:func:`ellipsoid` 99 100.. seealso:: :py:func:`willUseEllipsoid` 101%End 102 103 bool setEllipsoid( double semiMajor, double semiMinor ); 104%Docstring 105Sets ellipsoid by supplied radii. Calculations will only use the ellipsoid if 106a valid ellipsoid been set. 107 108:return: ``True`` if ellipsoid was successfully set 109 110.. seealso:: :py:func:`ellipsoid` 111 112.. seealso:: :py:func:`willUseEllipsoid` 113%End 114 115 QString ellipsoid() const; 116%Docstring 117Returns ellipsoid's acronym. Calculations will only use the 118ellipsoid if a valid ellipsoid has been set. 119 120.. seealso:: :py:func:`setEllipsoid` 121 122.. seealso:: :py:func:`willUseEllipsoid` 123 124.. seealso:: :py:func:`ellipsoidCrs` 125%End 126 127 double ellipsoidSemiMajor() const; 128%Docstring 129Returns the ellipsoid's semi major axis. 130 131.. seealso:: :py:func:`ellipsoid` 132 133.. seealso:: :py:func:`ellipsoidSemiMinor` 134 135.. seealso:: :py:func:`ellipsoidInverseFlattening` 136%End 137 138 double ellipsoidSemiMinor() const; 139%Docstring 140Returns ellipsoid's semi minor axis. 141 142.. seealso:: :py:func:`ellipsoid` 143 144.. seealso:: :py:func:`ellipsoidSemiMajor` 145 146.. seealso:: :py:func:`ellipsoidInverseFlattening` 147%End 148 149 double ellipsoidInverseFlattening() const; 150%Docstring 151Returns ellipsoid's inverse flattening. 152The inverse flattening is calculated with invf = a/(a-b). 153 154.. seealso:: :py:func:`ellipsoid` 155 156.. seealso:: :py:func:`ellipsoidSemiMajor` 157 158.. seealso:: :py:func:`ellipsoidSemiMinor` 159%End 160 161 double measureArea( const QgsGeometry &geometry ) const; 162%Docstring 163Measures the area of a geometry. 164 165:param geometry: geometry to measure 166 167:return: area of geometry. For geometry collections, non surface geometries will be ignored. The units for the 168 returned area can be retrieved by calling :py:func:`~QgsDistanceArea.areaUnits`. 169 170.. seealso:: :py:func:`measureLength` 171 172.. seealso:: :py:func:`measurePerimeter` 173 174.. seealso:: :py:func:`areaUnits` 175 176.. versionadded:: 2.12 177%End 178 179 double measureLength( const QgsGeometry &geometry ) const; 180%Docstring 181Measures the length of a geometry. 182 183:param geometry: geometry to measure 184 185:return: length of geometry. For geometry collections, non curve geometries will be ignored. The units for the 186 returned distance can be retrieved by calling :py:func:`~QgsDistanceArea.lengthUnits`. 187 188.. seealso:: :py:func:`lengthUnits` 189 190.. seealso:: :py:func:`measureArea` 191 192.. seealso:: :py:func:`measurePerimeter` 193 194.. versionadded:: 2.12 195%End 196 197 double measurePerimeter( const QgsGeometry &geometry ) const; 198%Docstring 199Measures the perimeter of a polygon geometry. 200 201:param geometry: geometry to measure 202 203:return: perimeter of geometry. For geometry collections, any non-polygon geometries will be ignored. The units for the 204 returned perimeter can be retrieved by calling :py:func:`~QgsDistanceArea.lengthUnits`. 205 206.. seealso:: :py:func:`lengthUnits` 207 208.. seealso:: :py:func:`measureArea` 209 210.. seealso:: :py:func:`measurePerimeter` 211 212.. versionadded:: 2.12 213%End 214 215 double measureLine( const QVector<QgsPointXY> &points ) const; 216%Docstring 217Measures the length of a line with multiple segments. 218 219:param points: list of points in line 220 221:return: length of line. The units for the returned length can be retrieved by calling :py:func:`~QgsDistanceArea.lengthUnits`. 222 223.. seealso:: :py:func:`lengthUnits` 224%End 225 226 double measureLine( const QgsPointXY &p1, const QgsPointXY &p2 ) const; 227%Docstring 228Measures the distance between two points. 229 230:param p1: start of line 231:param p2: end of line 232 233:return: distance between points. The units for the returned distance can be retrieved by calling :py:func:`~QgsDistanceArea.lengthUnits`. 234 235.. seealso:: :py:func:`lengthUnits` 236%End 237 238 double measureLineProjected( const QgsPointXY &p1, double distance = 1, double azimuth = M_PI_2, QgsPointXY *projectedPoint /Out/ = 0 ) const; 239%Docstring 240Calculates the distance from one point with distance in meters and azimuth (direction) 241When the :py:func:`~QgsDistanceArea.sourceCrs` is geographic, :py:func:`~QgsDistanceArea.computeSpheroidProject` will be called 242otherwise :py:func:`QgsPoint.project()` will be called after :py:func:`QgsUnitTypes.fromUnitToUnitFactor()` has been applied to the distance 243 244:param p1: start point [can be Cartesian or Geographic] 245:param distance: must be in meters 246:param azimuth: - azimuth in radians, clockwise from North 247 248:return: - distance in mapUnits 249 - projectedPoint: calculated projected point 250 251.. seealso:: :py:func:`sourceCrs` 252 253.. seealso:: :py:func:`computeSpheroidProject` 254 255.. note:: 256 257 The input Point must be in the coordinate reference system being used 258 259.. versionadded:: 3.0 260%End 261 262 QgsUnitTypes::DistanceUnit lengthUnits() const; 263%Docstring 264Returns the units of distance for length calculations made by this object. 265 266.. seealso:: :py:func:`areaUnits` 267 268.. versionadded:: 2.14 269%End 270 271 QgsUnitTypes::AreaUnit areaUnits() const; 272%Docstring 273Returns the units of area for areal calculations made by this object. 274 275.. seealso:: :py:func:`lengthUnits` 276 277.. versionadded:: 2.14 278%End 279 280 double measurePolygon( const QVector<QgsPointXY> &points ) const; 281%Docstring 282Measures the area of the polygon described by a set of points. 283%End 284 285 double bearing( const QgsPointXY &p1, const QgsPointXY &p2 ) const; 286%Docstring 287Computes the bearing (in radians) between two points. 288%End 289 290 static QString formatDistance( double distance, int decimals, QgsUnitTypes::DistanceUnit unit, bool keepBaseUnit = false ); 291%Docstring 292Returns an distance formatted as a friendly string. 293 294:param distance: distance to format 295:param decimals: number of decimal places to show 296:param unit: unit of distance 297:param keepBaseUnit: set to ``False`` to allow conversion of large distances to more suitable units, e.g., meters to 298 kilometers 299 300:return: formatted distance string 301 302.. seealso:: :py:func:`formatArea` 303 304.. versionadded:: 2.16 305%End 306 307 static QString formatArea( double area, int decimals, QgsUnitTypes::AreaUnit unit, bool keepBaseUnit = false ); 308%Docstring 309Returns an area formatted as a friendly string. 310 311:param area: area to format 312:param decimals: number of decimal places to show 313:param unit: unit of area 314:param keepBaseUnit: set to ``False`` to allow conversion of large areas to more suitable units, e.g., square meters to 315 square kilometers 316 317:return: formatted area string 318 319.. seealso:: :py:func:`formatDistance` 320 321.. versionadded:: 2.14 322%End 323 324 double convertLengthMeasurement( double length, QgsUnitTypes::DistanceUnit toUnits ) const; 325%Docstring 326Takes a length measurement calculated by this QgsDistanceArea object and converts it to a 327different distance unit. 328 329:param length: length value calculated by this class to convert. It is assumed that the length 330 was calculated by this class, ie that its unit of length is equal to :py:func:`~QgsDistanceArea.lengthUnits`. 331:param toUnits: distance unit to convert measurement to 332 333:return: converted distance 334 335.. seealso:: :py:func:`convertAreaMeasurement` 336 337.. versionadded:: 2.14 338%End 339 340 double convertAreaMeasurement( double area, QgsUnitTypes::AreaUnit toUnits ) const; 341%Docstring 342Takes an area measurement calculated by this QgsDistanceArea object and converts it to a 343different areal unit. 344 345:param area: area value calculated by this class to convert. It is assumed that the area 346 was calculated by this class, ie that its unit of area is equal to :py:func:`~QgsDistanceArea.areaUnits`. 347:param toUnits: area unit to convert measurement to 348 349:return: converted area 350 351.. seealso:: :py:func:`convertLengthMeasurement` 352 353.. versionadded:: 2.14 354%End 355 356 QgsPointXY computeSpheroidProject( const QgsPointXY &p1, double distance = 1, double azimuth = M_PI_2 ) const; 357%Docstring 358Given a location, an azimuth and a distance, computes the 359location of the projected point. 360 361:param p1: - location of first geographic (latitude/longitude) point as degrees. 362:param distance: - distance in meters. 363:param azimuth: - azimuth in radians, clockwise from North 364 365:return: p2 - location of projected point as longitude/latitude. 366 367.. versionadded:: 3.0 368%End 369 370 QVector<QVector<QgsPointXY> > geodesicLine( const QgsPointXY &p1, const QgsPointXY &p2, double interval, bool breakLine = false ) const; 371%Docstring 372Calculates the geodesic line between ``p1`` and ``p2``, which represents the shortest path on the 373ellipsoid between these two points. 374 375The ellipsoid settings defined on this QgsDistanceArea object will be used during the calculations. 376 377``p1`` and ``p2`` must be in the :py:func:`~QgsDistanceArea.sourceCrs` of this QgsDistanceArea object. The returned line 378will also be in this same CRS. 379 380The ``interval`` parameter gives the maximum distance between points on the computed line. 381This argument is always specified in meters. A shorter distance results in a denser line, 382at the cost of extra computing time. 383 384If the geodesic line crosses the antimeridian (+/- 180 degrees longitude) and ``breakLine`` is ``True``, then 385the line will be split into two parts, broken at the antimeridian. In this case the function 386will return two lines, corresponding to the portions at either side of the antimeridian. 387 388.. versionadded:: 3.6 389%End 390 391 double latitudeGeodesicCrossesAntimeridian( const QgsPointXY &p1, const QgsPointXY &p2, double &fractionAlongLine /Out/ ) const; 392%Docstring 393Calculates the latitude at which the geodesic line joining ``p1`` and ``p2`` crosses 394the antimeridian (longitude +/- 180 degrees). 395 396The ellipsoid settings defined on this QgsDistanceArea object will be used during the calculations. 397 398``p1`` and ``p2`` must be in the :py:func:`~QgsDistanceArea.ellipsoidCrs` of this QgsDistanceArea object. The returned latitude 399will also be in this same CRS. 400 401:param p1: Starting point, in :py:func:`~QgsDistanceArea.ellipsoidCrs` 402:param p2: Ending point, in :py:func:`~QgsDistanceArea.ellipsoidCrs` 403 404:return: - the latitude at which the geodesic crosses the antimeridian 405 - fractionAlongLine: will be set to the fraction along the geodesic line joining ``p1`` to ``p2`` at which the antimeridian crossing occurs. 406 407.. seealso:: :py:func:`splitGeometryAtAntimeridian` 408 409 410.. versionadded:: 3.6 411%End 412 413 QgsGeometry splitGeometryAtAntimeridian( const QgsGeometry &geometry ) const; 414%Docstring 415Splits a (Multi)LineString ``geometry`` at the antimeridian (longitude +/- 180 degrees). 416The returned geometry will always be a multi-part geometry. 417 418Whenever line segments in the input geometry cross the antimeridian, they will be 419split into two segments, with the latitude of the breakpoint being determined using a geodesic 420line connecting the points either side of this segment. 421 422The ellipsoid settings defined on this QgsDistanceArea object will be used during the calculations. 423 424``geometry`` must be in the :py:func:`~QgsDistanceArea.sourceCrs` of this QgsDistanceArea object. The returned geometry 425will also be in this same CRS. 426 427If ``geometry`` contains M or Z values, these will be linearly interpolated for the new vertices 428created at the antimeridian. 429 430.. note:: 431 432 Non-(Multi)LineString geometries will be returned unchanged. 433 434.. seealso:: :py:func:`latitudeGeodesicCrossesAntimeridian` 435 436.. versionadded:: 3.6 437%End 438 439}; 440 441 442/************************************************************************ 443 * This file has been generated automatically from * 444 * * 445 * src/core/qgsdistancearea.h * 446 * * 447 * Do not edit manually ! Edit header and run scripts/sipify.pl again * 448 ************************************************************************/ 449