QgsDistanceArea Class Reference
[QGIS core library]

General purpose distance and area calculator. More...

#include <qgsdistancearea.h>

Collaboration diagram for QgsDistanceArea:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 QgsDistanceArea ()
 Constructor.
 ~QgsDistanceArea ()
 Destructor.
void setProjectionsEnabled (bool flag)
 sets whether coordinates must be projected to ellipsoid before measuring
bool hasCrsTransformEnabled ()
 returns projections enabled flag
void setSourceCrs (long srsid)
 sets source spatial reference system (by QGIS CRS)
void setSourceEpsgCrsId (long epsgId)
 sets source spatial reference system (by EpsgCrsId)
long sourceCrs ()
 returns source spatial reference system
bool geographic ()
 What sort of coordinate system is being used?
bool setEllipsoid (const QString &ellipsoid)
 sets ellipsoid by its acronym
const QString & ellipsoid ()
 returns ellipsoid's acronym
double ellipsoidSemiMajor ()
 returns ellipsoid's semi major axis
double ellipsoidSemiMinor ()
 returns ellipsoid's semi minor axis
double ellipsoidInverseFlattening ()
 returns ellipsoid's inverse flattening
double measure (QgsGeometry *geometry)
 general measurement (line distance or polygon area)
double measureLine (const QList< QgsPoint > &points)
 measures line with more segments
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

Static Public Member Functions

static QString textUnit (double value, int decimals, QGis::UnitType u, bool isArea, bool keepBaseUnit=false)

Protected Member Functions

unsigned char * measureLine (unsigned char *feature, double *area, bool hasZptr=false)
 measures line distance, line points are extracted from WKB
unsigned char * measurePolygon (unsigned char *feature, double *area, bool hasZptr=false)
 measures polygon area, 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

double getQ (double x)
double getQbar (double x)

Private Attributes

QgsCoordinateTransformmCoordTransform
 used for transforming coordinates from source CRS to ellipsoid's coordinates
bool mProjectionsEnabled
 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


Detailed Description

General purpose distance and area calculator.

Definition at line 35 of file qgsdistancearea.h.


Constructor & Destructor Documentation

QgsDistanceArea::QgsDistanceArea (  ) 

Constructor.

Definition at line 41 of file qgsdistancearea.cpp.

References GEOCRS_ID, mCoordTransform, mProjectionsEnabled, setEllipsoid(), and setSourceCrs().

QgsDistanceArea::~QgsDistanceArea (  ) 

Destructor.

Definition at line 51 of file qgsdistancearea.cpp.

References mCoordTransform.


Member Function Documentation

void QgsDistanceArea::setProjectionsEnabled ( bool  flag  ) 

sets whether coordinates must be projected to ellipsoid before measuring

Definition at line 57 of file qgsdistancearea.cpp.

References mProjectionsEnabled.

Referenced by QgsSearchTreeNode::init(), and QgsMapRenderer::setProjectionsEnabled().

bool QgsDistanceArea::hasCrsTransformEnabled (  )  [inline]

returns projections enabled flag

Definition at line 48 of file qgsdistancearea.h.

void QgsDistanceArea::setSourceCrs ( long  srsid  ) 

sets source spatial reference system (by QGIS CRS)

Definition at line 62 of file qgsdistancearea.cpp.

References QgsCoordinateReferenceSystem::createFromSrsId(), mCoordTransform, and QgsCoordinateTransform::setSourceCrs().

Referenced by QgsDistanceArea(), and QgsMapRenderer::setDestinationSrs().

void QgsDistanceArea::setSourceEpsgCrsId ( long  epsgId  ) 

sets source spatial reference system (by EpsgCrsId)

Definition at line 69 of file qgsdistancearea.cpp.

References QgsCoordinateReferenceSystem::createFromEpsg(), mCoordTransform, and QgsCoordinateTransform::setSourceCrs().

long QgsDistanceArea::sourceCrs (  )  [inline]

returns source spatial reference system

Definition at line 57 of file qgsdistancearea.h.

bool QgsDistanceArea::geographic (  )  [inline]

What sort of coordinate system is being used?

Definition at line 59 of file qgsdistancearea.h.

bool QgsDistanceArea::setEllipsoid ( const QString &  ellipsoid  ) 

const QString& QgsDistanceArea::ellipsoid (  )  [inline]

returns ellipsoid's acronym

Definition at line 65 of file qgsdistancearea.h.

double QgsDistanceArea::ellipsoidSemiMajor (  )  [inline]

returns ellipsoid's semi major axis

Definition at line 68 of file qgsdistancearea.h.

double QgsDistanceArea::ellipsoidSemiMinor (  )  [inline]

returns ellipsoid's semi minor axis

Definition at line 70 of file qgsdistancearea.h.

double QgsDistanceArea::ellipsoidInverseFlattening (  )  [inline]

returns ellipsoid's inverse flattening

Definition at line 72 of file qgsdistancearea.h.

double QgsDistanceArea::measure ( QgsGeometry geometry  ) 

double QgsDistanceArea::measureLine ( const QList< QgsPoint > &  points  ) 

measures line with more segments

Definition at line 273 of file qgsdistancearea.cpp.

References computeDistanceBearing(), mCoordTransform, mEllipsoid, mProjectionsEnabled, QgsCoordinateTransform::transform(), and QgsLogger::warning().

Referenced by measure(), and measureLine().

double QgsDistanceArea::measureLine ( const QgsPoint p1,
const QgsPoint p2 
)

double QgsDistanceArea::measurePolygon ( const QList< QgsPoint > &  points  ) 

double QgsDistanceArea::bearing ( const QgsPoint p1,
const QgsPoint p2 
)

QString QgsDistanceArea::textUnit ( double  value,
int  decimals,
QGis::UnitType  u,
bool  isArea,
bool  keepBaseUnit = false 
) [static]

unsigned char * QgsDistanceArea::measureLine ( unsigned char *  feature,
double *  area,
bool  hasZptr = false 
) [protected]

measures line distance, line points are extracted from WKB

Definition at line 243 of file qgsdistancearea.cpp.

References measureLine(), and QgsDebugMsg.

unsigned char * QgsDistanceArea::measurePolygon ( unsigned char *  feature,
double *  area,
bool  hasZptr = false 
) [protected]

measures polygon area, vertices are extracted from WKB

Definition at line 340 of file qgsdistancearea.cpp.

References computePolygonArea(), mCoordTransform, mEllipsoid, mProjectionsEnabled, QgsCoordinateTransform::transform(), and QgsLogger::warning().

double QgsDistanceArea::computeDistanceBearing ( const QgsPoint p1,
const QgsPoint p2,
double *  course1 = NULL,
double *  course2 = NULL 
) [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

Note:
if course1 is not NULL, bearing (in radians) from first point is calculated (the same for course2)
Returns:
distance in meters

Definition at line 461 of file qgsdistancearea.cpp.

References DEG2RAD, M_PI, mInvFlattening, mSemiMajor, mSemiMinor, QgsPoint::x(), and QgsPoint::y().

Referenced by bearing(), and measureLine().

double QgsDistanceArea::computePolygonArea ( const QList< QgsPoint > &  points  )  [protected]

calculates area of polygon on ellipsoid algorithm has been taken from GRASS: gis/area_poly1.c

Definition at line 595 of file qgsdistancearea.cpp.

References computePolygonFlatArea(), DEG2RAD, getQ(), getQbar(), m_AE, m_E, M_PI, m_Qp, m_TwoPI, mEllipsoid, mProjectionsEnabled, and QgsDebugMsgLevel.

Referenced by measurePolygon().

double QgsDistanceArea::computePolygonFlatArea ( const QList< QgsPoint > &  points  )  [protected]

Definition at line 650 of file qgsdistancearea.cpp.

Referenced by computePolygonArea().

void QgsDistanceArea::computeAreaInit (  )  [protected]

precalculates some values (must be called always when changing ellipsoid)

Definition at line 567 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 setEllipsoid().

double QgsDistanceArea::getQ ( double  x  )  [private]

Definition at line 545 of file qgsdistancearea.cpp.

References m_QA, m_QB, and m_QC.

Referenced by computeAreaInit(), and computePolygonArea().

double QgsDistanceArea::getQbar ( double  x  )  [private]

Definition at line 556 of file qgsdistancearea.cpp.

References m_QbarA, m_QbarB, m_QbarC, and m_QbarD.

Referenced by computePolygonArea().


Member Data Documentation

used for transforming coordinates from source CRS to ellipsoid's coordinates

Definition at line 129 of file qgsdistancearea.h.

Referenced by bearing(), measureLine(), measurePolygon(), QgsDistanceArea(), setEllipsoid(), setSourceCrs(), setSourceEpsgCrsId(), and ~QgsDistanceArea().

indicates whether we will transform coordinates

Definition at line 132 of file qgsdistancearea.h.

Referenced by bearing(), computePolygonArea(), measureLine(), measurePolygon(), QgsDistanceArea(), and setProjectionsEnabled().

id of the source spatial reference system

Definition at line 135 of file qgsdistancearea.h.

QString QgsDistanceArea::mEllipsoid [private]

ellipsoid acronym (from table tbl_ellipsoids)

Definition at line 138 of file qgsdistancearea.h.

Referenced by bearing(), computePolygonArea(), measureLine(), measurePolygon(), and setEllipsoid().

double QgsDistanceArea::mSemiMajor [private]

ellipsoid parameters

Definition at line 141 of file qgsdistancearea.h.

Referenced by computeAreaInit(), computeDistanceBearing(), and setEllipsoid().

double QgsDistanceArea::mSemiMinor [private]

Definition at line 141 of file qgsdistancearea.h.

Referenced by computeAreaInit(), computeDistanceBearing(), and setEllipsoid().

Definition at line 141 of file qgsdistancearea.h.

Referenced by computeDistanceBearing(), and setEllipsoid().

double QgsDistanceArea::m_QA [private]

Definition at line 150 of file qgsdistancearea.h.

Referenced by computeAreaInit(), and getQ().

double QgsDistanceArea::m_QB [private]

Definition at line 150 of file qgsdistancearea.h.

Referenced by computeAreaInit(), and getQ().

double QgsDistanceArea::m_QC [private]

Definition at line 150 of file qgsdistancearea.h.

Referenced by computeAreaInit(), and getQ().

double QgsDistanceArea::m_QbarA [private]

Definition at line 151 of file qgsdistancearea.h.

Referenced by computeAreaInit(), and getQbar().

double QgsDistanceArea::m_QbarB [private]

Definition at line 151 of file qgsdistancearea.h.

Referenced by computeAreaInit(), and getQbar().

double QgsDistanceArea::m_QbarC [private]

Definition at line 151 of file qgsdistancearea.h.

Referenced by computeAreaInit(), and getQbar().

double QgsDistanceArea::m_QbarD [private]

Definition at line 151 of file qgsdistancearea.h.

Referenced by computeAreaInit(), and getQbar().

double QgsDistanceArea::m_AE [private]

Definition at line 152 of file qgsdistancearea.h.

Referenced by computeAreaInit(), and computePolygonArea().

double QgsDistanceArea::m_Qp [private]

Definition at line 153 of file qgsdistancearea.h.

Referenced by computeAreaInit(), and computePolygonArea().

double QgsDistanceArea::m_E [private]

Definition at line 154 of file qgsdistancearea.h.

Referenced by computeAreaInit(), and computePolygonArea().

double QgsDistanceArea::m_TwoPI [private]

Definition at line 155 of file qgsdistancearea.h.

Referenced by computeAreaInit(), and computePolygonArea().


The documentation for this class was generated from the following files:

Generated on Sat Feb 4 19:17:32 2012 for Quantum GIS API Documentation by  doxygen 1.5.6