QGIS API Documentation
2.2.0-Valmiera
|
General purpose distance and area calculator. More...
#include <qgsdistancearea.h>
Public Member Functions | |
QgsDistanceArea () | |
Constructor. | |
~QgsDistanceArea () | |
Destructor. | |
QgsDistanceArea (const QgsDistanceArea &origDA) | |
Copy constructor. | |
QgsDistanceArea & | operator= (const QgsDistanceArea &origDA) |
Assignment operator. | |
void | setEllipsoidalMode (bool flag) |
sets whether coordinates must be projected to ellipsoid before measuring | |
bool | ellipsoidalEnabled () const |
returns projections enabled flag | |
void | setSourceCrs (long srsid) |
sets source spatial reference system (by QGIS CRS) | |
void | setSourceCrs (const QgsCoordinateReferenceSystem &srcCRS) |
Sets source spatial reference system (by QGIS CRS) | |
void | setSourceAuthId (QString authid) |
sets source spatial reference system by authid | |
long | sourceCrs () const |
returns source spatial reference system | |
bool | geographic () const |
What sort of coordinate system is being used? | |
bool | setEllipsoid (const QString &ellipsoid) |
sets ellipsoid by its acronym | |
bool | setEllipsoid (double semiMajor, double semiMinor) |
Sets ellipsoid by supplied radii. | |
const QString & | ellipsoid () const |
returns ellipsoid's acronym | |
double | ellipsoidSemiMajor () const |
returns ellipsoid's semi major axis | |
double | ellipsoidSemiMinor () const |
returns ellipsoid's semi minor axis | |
double | ellipsoidInverseFlattening () const |
returns ellipsoid's inverse flattening | |
double | measure (QgsGeometry *geometry) |
general measurement (line distance or polygon area) | |
double | measurePerimeter (QgsGeometry *geometry) |
measures perimeter of polygon | |
double | measureLine (const QList< QgsPoint > &points) |
measures line | |
double | measureLine (const QgsPoint &p1, const QgsPoint &p2) |
measures line with one segment | |
double | measurePolygon (const QList< QgsPoint > &points) |
measures polygon area | |
double | bearing (const QgsPoint &p1, const QgsPoint &p2) |
compute bearing - in radians | |
void | convertMeasurement (double &measure, QGis::UnitType &measureUnits, QGis::UnitType displayUnits, bool isArea) |
Helper for conversion between physical units. |
Static Public Member Functions | |
static QString | textUnit (double value, int decimals, QGis::UnitType u, bool isArea, bool keepBaseUnit=false) |
Protected Member Functions | |
const unsigned char * | measureLine (const unsigned char *feature, double *area, bool hasZptr=false) |
measures line distance, line points are extracted from WKB | |
const unsigned char * | measurePolygon (const unsigned char *feature, double *area, double *perimeter, bool hasZptr=false) |
measures polygon area and perimeter, vertices are extracted from WKB | |
double | computeDistanceBearing (const QgsPoint &p1, const QgsPoint &p2, double *course1=NULL, double *course2=NULL) |
calculates distance from two points on ellipsoid based on inverse Vincenty's formulae | |
double | computePolygonArea (const QList< QgsPoint > &points) |
calculates area of polygon on ellipsoid algorithm has been taken from GRASS: gis/area_poly1.c | |
double | computePolygonFlatArea (const QList< QgsPoint > &points) |
void | computeAreaInit () |
precalculates some values (must be called always when changing ellipsoid) |
Private Member Functions | |
void | _copy (const QgsDistanceArea &origDA) |
Copy helper. | |
double | getQ (double x) |
double | getQbar (double x) |
Private Attributes | |
QgsCoordinateTransform * | mCoordTransform |
used for transforming coordinates from source CRS to ellipsoid's coordinates | |
bool | mEllipsoidalMode |
indicates whether we will transform coordinates | |
long | mSourceRefSys |
id of the source spatial reference system | |
QString | mEllipsoid |
ellipsoid acronym (from table tbl_ellipsoids) | |
double | mSemiMajor |
ellipsoid parameters | |
double | mSemiMinor |
double | mInvFlattening |
double | m_QA |
double | m_QB |
double | m_QC |
double | m_QbarA |
double | m_QbarB |
double | m_QbarC |
double | m_QbarD |
double | m_AE |
double | m_Qp |
double | m_E |
double | m_TwoPI |
General purpose distance and area calculator.
Definition at line 34 of file qgsdistancearea.h.
QgsDistanceArea::QgsDistanceArea | ( | ) |
Constructor.
Definition at line 41 of file qgsdistancearea.cpp.
References GEO_NONE, GEOCRS_ID, mCoordTransform, mEllipsoidalMode, setEllipsoid(), and setSourceCrs().
QgsDistanceArea::~QgsDistanceArea | ( | ) |
QgsDistanceArea::QgsDistanceArea | ( | const QgsDistanceArea & | origDA | ) |
|
private |
Copy helper.
Copy helper. Avoid Sqlite3 accesses.
Definition at line 75 of file qgsdistancearea.cpp.
References computeAreaInit(), QgsCoordinateTransform::destCRS(), mCoordTransform, mEllipsoid, mEllipsoidalMode, mInvFlattening, mSemiMajor, mSemiMinor, mSourceRefSys, and QgsCoordinateTransform::sourceCrs().
Referenced by operator=(), and QgsDistanceArea().
compute bearing - in radians
Definition at line 614 of file qgsdistancearea.cpp.
References computeDistanceBearing(), GEO_NONE, mCoordTransform, mEllipsoid, mEllipsoidalMode, QgsCoordinateTransform::transform(), QgsPoint::x(), and QgsPoint::y().
Referenced by QgsTransectSample::createSample().
|
protected |
precalculates some values (must be called always when changing ellipsoid)
Definition at line 745 of file qgsdistancearea.cpp.
References getQ(), m_AE, m_E, M_PI, m_QA, m_QB, m_QbarA, m_QbarB, m_QbarC, m_QbarD, m_QC, m_Qp, m_TwoPI, mSemiMajor, and mSemiMinor.
Referenced by _copy(), and setEllipsoid().
|
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 639 of file qgsdistancearea.cpp.
References DEG2RAD, M_PI, mInvFlattening, mSemiMajor, mSemiMinor, QgsPoint::x(), and QgsPoint::y().
Referenced by bearing(), and measureLine().
|
protected |
calculates area of polygon on ellipsoid algorithm has been taken from GRASS: gis/area_poly1.c
Definition at line 774 of file qgsdistancearea.cpp.
References computePolygonFlatArea(), DEG2RAD, GEO_NONE, getQ(), getQbar(), m_AE, m_E, M_PI, m_Qp, m_TwoPI, mEllipsoid, mEllipsoidalMode, and QgsDebugMsgLevel.
Referenced by measurePolygon().
|
protected |
Definition at line 831 of file qgsdistancearea.cpp.
References size.
Referenced by computePolygonArea().
void QgsDistanceArea::convertMeasurement | ( | double & | measure, |
QGis::UnitType & | measureUnits, | ||
QGis::UnitType | displayUnits, | ||
bool | isArea | ||
) |
Helper for conversion between physical units.
Definition at line 981 of file qgsdistancearea.cpp.
References QGis::Degrees, QGis::Feet, QGis::fromUnitToUnitFactor(), GEO_NONE, QgsCoordinateReferenceSystem::mapUnits(), mCoordTransform, mEllipsoid, mEllipsoidalMode, QGis::Meters, QGis::NauticalMiles, QgsDebugMsg, QgsCoordinateTransform::sourceCrs(), and QGis::toLiteral().
Referenced by QgsMapToolIdentify::convertMeasurement().
|
inline |
returns ellipsoid's acronym
Definition at line 80 of file qgsdistancearea.h.
Referenced by setEllipsoid().
|
inline |
returns projections enabled flag
Definition at line 53 of file qgsdistancearea.h.
|
inline |
returns ellipsoid's inverse flattening
Definition at line 87 of file qgsdistancearea.h.
|
inline |
returns ellipsoid's semi major axis
Definition at line 83 of file qgsdistancearea.h.
|
inline |
returns ellipsoid's semi minor axis
Definition at line 85 of file qgsdistancearea.h.
|
inline |
What sort of coordinate system is being used?
Definition at line 70 of file qgsdistancearea.h.
|
private |
Definition at line 723 of file qgsdistancearea.cpp.
References m_QA, m_QB, and m_QC.
Referenced by computeAreaInit(), and computePolygonArea().
|
private |
Definition at line 734 of file qgsdistancearea.cpp.
References m_QbarA, m_QbarB, m_QbarC, and m_QbarD.
Referenced by computePolygonArea().
double QgsDistanceArea::measure | ( | QgsGeometry * | geometry | ) |
general measurement (line distance or polygon area)
Definition at line 258 of file qgsdistancearea.cpp.
References QgsGeometry::asWkb(), measureLine(), measurePolygon(), QgsDebugMsg, QGis::WKBLineString, QGis::WKBLineString25D, QGis::WKBMultiLineString, QGis::WKBMultiLineString25D, QGis::WKBMultiPolygon, QGis::WKBMultiPolygon25D, QGis::WKBPolygon, and QGis::WKBPolygon25D.
Referenced by QgsTransectSample::createSample(), fcnGeomArea(), fcnGeomLength(), QgsMapToolIdentify::featureDerivedAttributes(), QgsGeometryAnalyzer::perimeterMeasure(), and QgsGeometryAnalyzer::simpleMeasure().
double QgsDistanceArea::measureLine | ( | const QList< QgsPoint > & | points | ) |
measures line
Definition at line 414 of file qgsdistancearea.cpp.
References computeDistanceBearing(), GEO_NONE, QgsMessageLog::logMessage(), mCoordTransform, mEllipsoid, mEllipsoidalMode, tr, and QgsCoordinateTransform::transform().
Referenced by QgsComposerScaleBar::mapWidth(), measure(), measureLine(), measurePolygon(), and QgsTransectSample::otherTransectWithinDistance().
measures line with one segment
Definition at line 456 of file qgsdistancearea.cpp.
References computeDistanceBearing(), QgsCoordinateTransform::destCRS(), GEO_NONE, QgsMessageLog::logMessage(), mCoordTransform, mEllipsoid, mEllipsoidalMode, QgsDebugMsgLevel, QgsCoordinateTransform::sourceCrs(), QgsCoordinateReferenceSystem::toProj4(), QgsPoint::toString(), tr, QgsCoordinateTransform::transform(), QgsPoint::x(), and QgsPoint::y().
|
protected |
measures line distance, line points are extracted from WKB
Definition at line 387 of file qgsdistancearea.cpp.
References measureLine(), and QgsDebugMsg.
double QgsDistanceArea::measurePerimeter | ( | QgsGeometry * | geometry | ) |
measures perimeter of polygon
Definition at line 329 of file qgsdistancearea.cpp.
References QgsGeometry::asWkb(), measurePolygon(), QgsDebugMsg, QGis::WKBLineString, QGis::WKBLineString25D, QGis::WKBMultiLineString, QGis::WKBMultiLineString25D, QGis::WKBMultiPolygon, QGis::WKBMultiPolygon25D, QGis::WKBPolygon, and QGis::WKBPolygon25D.
Referenced by fcnGeomPerimeter(), and QgsMapToolIdentify::featureDerivedAttributes().
double QgsDistanceArea::measurePolygon | ( | const QList< QgsPoint > & | points | ) |
measures polygon area
Definition at line 587 of file qgsdistancearea.cpp.
References computePolygonArea(), GEO_NONE, QgsMessageLog::logMessage(), mCoordTransform, mEllipsoid, mEllipsoidalMode, tr, and QgsCoordinateTransform::transform().
Referenced by measure(), and measurePerimeter().
|
protected |
measures polygon area and perimeter, vertices are extracted from WKB
Definition at line 492 of file qgsdistancearea.cpp.
References computePolygonArea(), GEO_NONE, QgsMessageLog::logMessage(), mCoordTransform, measureLine(), mEllipsoid, mEllipsoidalMode, QgsDebugMsg, tr, and QgsCoordinateTransform::transform().
QgsDistanceArea & QgsDistanceArea::operator= | ( | const QgsDistanceArea & | origDA | ) |
bool QgsDistanceArea::setEllipsoid | ( | const QString & | ellipsoid | ) |
sets ellipsoid by its acronym
Definition at line 113 of file qgsdistancearea.cpp.
References computeAreaInit(), QgsCoordinateReferenceSystem::createFromProj4(), ellipsoid(), GEO_NONE, QgsMessageLog::logMessage(), mCoordTransform, mEllipsoid, mInvFlattening, mSemiMajor, mSemiMinor, QgsDebugMsg, QgsCoordinateReferenceSystem::saveAsUserCRS(), QgsCoordinateTransform::setDestCRS(), QgsApplication::srsDbFilePath(), QgsCoordinateReferenceSystem::srsid(), QgsCoordinateReferenceSystem::toProj4(), and tr.
Referenced by QgsMapToolIdentify::featureDerivedAttributes(), QgsAttributeDialog::init(), QgsComposerScaleBar::mapWidth(), and QgsDistanceArea().
bool QgsDistanceArea::setEllipsoid | ( | double | semiMajor, |
double | semiMinor | ||
) |
Sets ellipsoid by supplied radii.
Definition at line 246 of file qgsdistancearea.cpp.
References computeAreaInit(), mEllipsoid, mInvFlattening, mSemiMajor, and mSemiMinor.
void QgsDistanceArea::setEllipsoidalMode | ( | bool | flag | ) |
sets whether coordinates must be projected to ellipsoid before measuring
Definition at line 89 of file qgsdistancearea.cpp.
References mEllipsoidalMode.
Referenced by QgsTransectSample::createSample(), QgsMapToolIdentify::featureDerivedAttributes(), QgsAttributeDialog::init(), QgsExpression::initGeomCalculator(), QgsComposerScaleBar::mapWidth(), and QgsMapRenderer::setProjectionsEnabled().
void QgsDistanceArea::setSourceAuthId | ( | QString | authid | ) |
sets source spatial reference system by authid
Definition at line 106 of file qgsdistancearea.cpp.
References QgsCoordinateReferenceSystem::createFromOgcWmsCrs(), mCoordTransform, and QgsCoordinateTransform::setSourceCrs().
void QgsDistanceArea::setSourceCrs | ( | long | srsid | ) |
sets source spatial reference system (by QGIS CRS)
Definition at line 94 of file qgsdistancearea.cpp.
References QgsCoordinateReferenceSystem::createFromSrsId(), mCoordTransform, and QgsCoordinateTransform::setSourceCrs().
Referenced by QgsAttributeEditorContext::adjustForLayer(), QgsTransectSample::createSample(), QgsMapToolIdentify::featureDerivedAttributes(), QgsAttributeDialog::init(), QgsComposerScaleBar::mapWidth(), QgsDistanceArea(), and QgsMapRenderer::setDestinationCrs().
void QgsDistanceArea::setSourceCrs | ( | const QgsCoordinateReferenceSystem & | srcCRS | ) |
Sets source spatial reference system (by QGIS CRS)
Definition at line 101 of file qgsdistancearea.cpp.
References mCoordTransform, and QgsCoordinateTransform::setSourceCrs().
|
inline |
returns source spatial reference system
Definition at line 68 of file qgsdistancearea.h.
|
static |
Definition at line 852 of file qgsdistancearea.cpp.
References QGis::Degrees, QGis::Feet, QGis::Meters, QGis::NauticalMiles, QgsDebugMsg, tr, and QGis::UnknownUnit.
Referenced by QgsMapToolIdentify::featureDerivedAttributes().
|
private |
Definition at line 175 of file qgsdistancearea.h.
Referenced by computeAreaInit(), and computePolygonArea().
|
private |
Definition at line 177 of file qgsdistancearea.h.
Referenced by computeAreaInit(), and computePolygonArea().
|
private |
Definition at line 173 of file qgsdistancearea.h.
Referenced by computeAreaInit(), and getQ().
|
private |
Definition at line 173 of file qgsdistancearea.h.
Referenced by computeAreaInit(), and getQ().
|
private |
Definition at line 174 of file qgsdistancearea.h.
Referenced by computeAreaInit(), and getQbar().
|
private |
Definition at line 174 of file qgsdistancearea.h.
Referenced by computeAreaInit(), and getQbar().
|
private |
Definition at line 174 of file qgsdistancearea.h.
Referenced by computeAreaInit(), and getQbar().
|
private |
Definition at line 174 of file qgsdistancearea.h.
Referenced by computeAreaInit(), and getQbar().
|
private |
Definition at line 173 of file qgsdistancearea.h.
Referenced by computeAreaInit(), and getQ().
|
private |
Definition at line 176 of file qgsdistancearea.h.
Referenced by computeAreaInit(), and computePolygonArea().
|
private |
Definition at line 178 of file qgsdistancearea.h.
Referenced by computeAreaInit(), and computePolygonArea().
|
private |
used for transforming coordinates from source CRS to ellipsoid's coordinates
Definition at line 152 of file qgsdistancearea.h.
Referenced by _copy(), bearing(), convertMeasurement(), measureLine(), measurePolygon(), QgsDistanceArea(), setEllipsoid(), setSourceAuthId(), setSourceCrs(), and ~QgsDistanceArea().
|
private |
ellipsoid acronym (from table tbl_ellipsoids)
Definition at line 161 of file qgsdistancearea.h.
Referenced by _copy(), bearing(), computePolygonArea(), convertMeasurement(), measureLine(), measurePolygon(), and setEllipsoid().
|
private |
indicates whether we will transform coordinates
Definition at line 155 of file qgsdistancearea.h.
Referenced by _copy(), bearing(), computePolygonArea(), convertMeasurement(), measureLine(), measurePolygon(), QgsDistanceArea(), and setEllipsoidalMode().
|
private |
Definition at line 164 of file qgsdistancearea.h.
Referenced by _copy(), computeDistanceBearing(), and setEllipsoid().
|
private |
ellipsoid parameters
Definition at line 164 of file qgsdistancearea.h.
Referenced by _copy(), computeAreaInit(), computeDistanceBearing(), and setEllipsoid().
|
private |
Definition at line 164 of file qgsdistancearea.h.
Referenced by _copy(), computeAreaInit(), computeDistanceBearing(), and setEllipsoid().
|
private |
id of the source spatial reference system
Definition at line 158 of file qgsdistancearea.h.
Referenced by _copy().