QGIS API Documentation
2.18.21-Las Palmas (9fba24a)
|
General purpose distance and area calculator. More...
#include <qgsdistancearea.h>
Public Member Functions | |
QgsDistanceArea () | |
Constructor. More... | |
QgsDistanceArea (const QgsDistanceArea &origDA) | |
Copy constructor. More... | |
~QgsDistanceArea () | |
Destructor. More... | |
QgsUnitTypes::AreaUnit | areaUnits () const |
Returns the units of area for areal calculations made by this object. More... | |
double | bearing (const QgsPoint &p1, const QgsPoint &p2) const |
compute bearing - in radians More... | |
double | convertAreaMeasurement (double area, QgsUnitTypes::AreaUnit toUnits) const |
Takes an area measurement calculated by this QgsDistanceArea object and converts it to a different areal unit. More... | |
double | convertLengthMeasurement (double length, QGis::UnitType toUnits) const |
Takes a length measurement calculated by this QgsDistanceArea object and converts it to a different distance unit. More... | |
void | convertMeasurement (double &measure, QGis::UnitType &measureUnits, QGis::UnitType displayUnits, bool isArea) const |
Helper for conversion between physical units. More... | |
QString | ellipsoid () const |
Returns ellipsoid's acronym. More... | |
bool | ellipsoidalEnabled () const |
Returns whether ellipsoidal calculations are enabled. More... | |
double | ellipsoidInverseFlattening () const |
returns ellipsoid's inverse flattening More... | |
double | ellipsoidSemiMajor () const |
returns ellipsoid's semi major axis More... | |
double | ellipsoidSemiMinor () const |
returns ellipsoid's semi minor axis More... | |
bool | geographic () const |
What sort of coordinate system is being used? More... | |
QGis::UnitType | lengthUnits () const |
Returns the units of distance for length calculations made by this object. More... | |
Q_DECL_DEPRECATED double | measure (const QgsGeometry *geometry) const |
General measurement (line distance or polygon area) More... | |
double | measureArea (const QgsGeometry *geometry) const |
Measures the area of a geometry. More... | |
double | measureLength (const QgsGeometry *geometry) const |
Measures the length of a geometry. More... | |
double | measureLine (const QList< QgsPoint > &points) const |
Measures the length of a line with multiple segments. More... | |
double | measureLine (const QgsPoint &p1, const QgsPoint &p2) const |
Measures length of a line with one segment. More... | |
double | measureLine (const QgsPoint &p1, const QgsPoint &p2, QGis::UnitType &units) const |
Measures length of line with one segment and returns units of distance. More... | |
double | measurePerimeter (const QgsGeometry *geometry) const |
Measures the perimeter of a polygon geometry. More... | |
double | measurePolygon (const QList< QgsPoint > &points) const |
measures polygon area More... | |
QgsDistanceArea & | operator= (const QgsDistanceArea &origDA) |
Assignment operator. More... | |
bool | setEllipsoid (const QString &ellipsoid) |
Sets ellipsoid by its acronym. More... | |
bool | setEllipsoid (double semiMajor, double semiMinor) |
Sets ellipsoid by supplied radii. More... | |
void | setEllipsoidalMode (bool flag) |
Sets whether coordinates must be projected to ellipsoid before measuring. More... | |
void | setSourceAuthId (const QString &authid) |
sets source spatial reference system by authid More... | |
void | setSourceCrs (long srsid) |
sets source spatial reference system (by QGIS CRS) More... | |
void | setSourceCrs (const QgsCoordinateReferenceSystem &srcCRS) |
Sets source spatial reference system (by QGIS CRS) More... | |
Q_DECL_DEPRECATED long | sourceCrs () const |
returns source spatial reference system More... | |
long | sourceCrsId () const |
Returns the QgsCoordinateReferenceSystem::srsid() for the CRS used during calculations. More... | |
bool | willUseEllipsoid () const |
Returns whether calculations will use the ellipsoid. More... | |
Static Public Member Functions | |
static QString | formatArea (double area, int decimals, QgsUnitTypes::AreaUnit unit, bool keepBaseUnit=false) |
Returns an area formatted as a friendly string. More... | |
static QString | formatDistance (double distance, int decimals, QGis::UnitType unit, bool keepBaseUnit=false) |
Returns an distance formatted as a friendly string. More... | |
static Q_DECL_DEPRECATED QString | textUnit (double value, int decimals, QGis::UnitType u, bool isArea, bool keepBaseUnit=false) |
Returns a measurement formatted as a friendly string. More... | |
Protected Member Functions | |
void | computeAreaInit () |
precalculates some values (must be called always when changing ellipsoid) More... | |
double | computeDistance (const QList< QgsPoint > &points) const |
calculate distance with given coordinates (does not do a transform anymore) More... | |
double | computeDistanceBearing (const QgsPoint &p1, const QgsPoint &p2, double *course1=nullptr, double *course2=nullptr) const |
calculates distance from two points on ellipsoid based on inverse Vincenty's formulae More... | |
double | computeDistanceFlat (const QgsPoint &p1, const QgsPoint &p2) const |
uses flat / planimetric / Euclidean distance More... | |
double | computePolygonArea (const QList< QgsPoint > &points) const |
calculates area of polygon on ellipsoid algorithm has been taken from GRASS: gis/area_poly1.c More... | |
double | computePolygonFlatArea (const QList< QgsPoint > &points) const |
QgsConstWkbPtr | measurePolygon (QgsConstWkbPtr feature, double *area, double *perimeter, bool hasZptr=false) const |
measures polygon area and perimeter, vertices are extracted from WKB More... | |
General purpose distance and area calculator.
Definition at line 38 of file qgsdistancearea.h.
QgsDistanceArea::QgsDistanceArea | ( | ) |
Constructor.
Definition at line 48 of file qgsdistancearea.cpp.
QgsDistanceArea::~QgsDistanceArea | ( | ) |
Destructor.
Definition at line 65 of file qgsdistancearea.cpp.
QgsDistanceArea::QgsDistanceArea | ( | const QgsDistanceArea & | origDA | ) |
Copy constructor.
Definition at line 59 of file qgsdistancearea.cpp.
QgsUnitTypes::AreaUnit QgsDistanceArea::areaUnits | ( | ) | const |
Returns the units of area for areal calculations made by this object.
Definition at line 539 of file qgsdistancearea.cpp.
compute bearing - in radians
Definition at line 681 of file qgsdistancearea.cpp.
|
protected |
precalculates some values (must be called always when changing ellipsoid)
Definition at line 854 of file qgsdistancearea.cpp.
calculate distance with given coordinates (does not do a transform anymore)
Definition at line 788 of file qgsdistancearea.cpp.
|
protected |
calculates distance from two points on ellipsoid based on inverse Vincenty's formulae
Points p1 and p2 are expected to be in degrees and in currently used ellipsoid
Definition at line 706 of file qgsdistancearea.cpp.
|
protected |
uses flat / planimetric / Euclidean distance
Definition at line 783 of file qgsdistancearea.cpp.
calculates area of polygon on ellipsoid algorithm has been taken from GRASS: gis/area_poly1.c
Definition at line 889 of file qgsdistancearea.cpp.
Definition at line 978 of file qgsdistancearea.cpp.
double QgsDistanceArea::convertAreaMeasurement | ( | double | area, |
QgsUnitTypes::AreaUnit | toUnits | ||
) | const |
Takes an area measurement calculated by this QgsDistanceArea object and converts it to a different areal unit.
area | area value calculated by this class to convert. It is assumed that the area was calculated by this class, ie that its unit of area is equal to areaUnits(). |
toUnits | area unit to convert measurement to |
Definition at line 1412 of file qgsdistancearea.cpp.
double QgsDistanceArea::convertLengthMeasurement | ( | double | length, |
QGis::UnitType | toUnits | ||
) | const |
Takes a length measurement calculated by this QgsDistanceArea object and converts it to a different distance unit.
length | length value calculated by this class to convert. It is assumed that the length was calculated by this class, ie that its unit of length is equal to lengthUnits(). |
toUnits | distance unit to convert measurement to |
Definition at line 1398 of file qgsdistancearea.cpp.
void QgsDistanceArea::convertMeasurement | ( | double & | measure, |
QGis::UnitType & | measureUnits, | ||
QGis::UnitType | displayUnits, | ||
bool | isArea | ||
) | const |
Helper for conversion between physical units.
Definition at line 1367 of file qgsdistancearea.cpp.
|
inline |
Returns ellipsoid's acronym.
Calculations will only use the ellipsoid if ellipsoidalEnabled() is true and an ellipsoid has been set.
Definition at line 126 of file qgsdistancearea.h.
|
inline |
Returns whether ellipsoidal calculations are enabled.
Definition at line 65 of file qgsdistancearea.h.
|
inline |
returns ellipsoid's inverse flattening
Definition at line 133 of file qgsdistancearea.h.
|
inline |
returns ellipsoid's semi major axis
Definition at line 129 of file qgsdistancearea.h.
|
inline |
returns ellipsoid's semi minor axis
Definition at line 131 of file qgsdistancearea.h.
|
static |
Returns an area formatted as a friendly string.
area | area to format |
decimals | number of decimal places to show |
unit | unit of area |
keepBaseUnit | set to false to allow conversion of large areas to more suitable units, eg square meters to square kilometers |
Definition at line 1232 of file qgsdistancearea.cpp.
|
static |
Returns an distance formatted as a friendly string.
distance | distance to format |
decimals | number of decimal places to show |
unit | unit of distance |
keepBaseUnit | set to false to allow conversion of large distances to more suitable units, eg meters to kilometers |
Definition at line 1129 of file qgsdistancearea.cpp.
|
inline |
What sort of coordinate system is being used?
Definition at line 99 of file qgsdistancearea.h.
QGis::UnitType QgsDistanceArea::lengthUnits | ( | ) | const |
Returns the units of distance for length calculations made by this object.
Definition at line 534 of file qgsdistancearea.cpp.
double QgsDistanceArea::measure | ( | const QgsGeometry * | geometry | ) | const |
General measurement (line distance or polygon area)
Definition at line 350 of file qgsdistancearea.cpp.
double QgsDistanceArea::measureArea | ( | const QgsGeometry * | geometry | ) | const |
Measures the area of a geometry.
geometry | geometry to measure |
Definition at line 359 of file qgsdistancearea.cpp.
double QgsDistanceArea::measureLength | ( | const QgsGeometry * | geometry | ) | const |
Measures the length of a geometry.
geometry | geometry to measure |
Definition at line 368 of file qgsdistancearea.cpp.
Measures the length of a line with multiple segments.
points | list of points in line |
Definition at line 449 of file qgsdistancearea.cpp.
Measures length of a line with one segment.
p1 | start of line |
p2 | end of line |
Definition at line 491 of file qgsdistancearea.cpp.
double QgsDistanceArea::measureLine | ( | const QgsPoint & | p1, |
const QgsPoint & | p2, | ||
QGis::UnitType & | units | ||
) | const |
Measures length of line with one segment and returns units of distance.
p1 | start of line |
p2 | end of line |
units | will be set to units of measure |
Definition at line 497 of file qgsdistancearea.cpp.
double QgsDistanceArea::measurePerimeter | ( | const QgsGeometry * | geometry | ) | const |
Measures the perimeter of a polygon geometry.
geometry | geometry to measure |
Definition at line 377 of file qgsdistancearea.cpp.
measures polygon area
Definition at line 654 of file qgsdistancearea.cpp.
|
protected |
measures polygon area and perimeter, vertices are extracted from WKB
Definition at line 545 of file qgsdistancearea.cpp.
QgsDistanceArea & QgsDistanceArea::operator= | ( | const QgsDistanceArea & | origDA | ) |
Assignment operator.
Definition at line 71 of file qgsdistancearea.cpp.
bool QgsDistanceArea::setEllipsoid | ( | const QString & | ellipsoid | ) |
Sets ellipsoid by its acronym.
Calculations will only use the ellipsoid if both the ellipsoid has been set and ellipsoidalEnabled() is true.
Definition at line 124 of file qgsdistancearea.cpp.
bool QgsDistanceArea::setEllipsoid | ( | double | semiMajor, |
double | semiMinor | ||
) |
Sets ellipsoid by supplied radii.
Calculations will only use the ellipsoid if both the ellipsoid has been set and ellipsoidalEnabled() is true.
Definition at line 257 of file qgsdistancearea.cpp.
void QgsDistanceArea::setEllipsoidalMode | ( | bool | flag | ) |
Sets whether coordinates must be projected to ellipsoid before measuring.
Definition at line 97 of file qgsdistancearea.cpp.
void QgsDistanceArea::setSourceAuthId | ( | const QString & | authid | ) |
sets source spatial reference system by authid
Definition at line 118 of file qgsdistancearea.cpp.
void QgsDistanceArea::setSourceCrs | ( | long | srsid | ) |
sets source spatial reference system (by QGIS CRS)
Definition at line 107 of file qgsdistancearea.cpp.
void QgsDistanceArea::setSourceCrs | ( | const QgsCoordinateReferenceSystem & | srcCRS | ) |
Sets source spatial reference system (by QGIS CRS)
Definition at line 113 of file qgsdistancearea.cpp.
|
inline |
returns source spatial reference system
Definition at line 90 of file qgsdistancearea.h.
|
inline |
Returns the QgsCoordinateReferenceSystem::srsid() for the CRS used during calculations.
Definition at line 96 of file qgsdistancearea.h.
|
static |
Returns a measurement formatted as a friendly string.
value | value of measurement |
decimals | number of decimal places to show |
u | unit of measurement |
isArea | set to true if measurement is an area measurement |
keepBaseUnit | set to false to allow conversion of large distances to more suitable units, eg meters to kilometers |
Definition at line 999 of file qgsdistancearea.cpp.
bool QgsDistanceArea::willUseEllipsoid | ( | ) | const |
Returns whether calculations will use the ellipsoid.
Calculations will only use the ellipsoid if ellipsoidalEnabled() is true and an ellipsoid has been set.
Definition at line 102 of file qgsdistancearea.cpp.