QGIS API Documentation  2.11.0-Master
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
QgsDistanceArea Class Reference

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...
 
double bearing (const QgsPoint &p1, const QgsPoint &p2) const
 compute bearing - in radians More...
 
void convertMeasurement (double &measure, QGis::UnitType &measureUnits, QGis::UnitType displayUnits, bool isArea) const
 Helper for conversion between physical units. More...
 
const QStringellipsoid () const
 returns ellipsoid's acronym More...
 
bool ellipsoidalEnabled () const
 returns projections enabled flag 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...
 
double measure (const QgsGeometry *geometry) const
 general measurement (line distance or polygon area) More...
 
double measureLine (const QList< QgsPoint > &points) const
 measures line More...
 
double measureLine (const QgsPoint &p1, const QgsPoint &p2) const
 measures line with one segment More...
 
double measurePerimeter (const QgsGeometry *geometry) const
 measures perimeter of polygon More...
 
double measurePolygon (const QList< QgsPoint > &points) const
 measures polygon area More...
 
QgsDistanceAreaoperator= (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 (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...
 
long sourceCrs () const
 returns source spatial reference system More...
 

Static Public Member Functions

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

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

Detailed Description

General purpose distance and area calculator.

Definition at line 34 of file qgsdistancearea.h.

Constructor & Destructor Documentation

QgsDistanceArea::QgsDistanceArea ( )

Constructor.

Definition at line 42 of file qgsdistancearea.cpp.

QgsDistanceArea::~QgsDistanceArea ( )

Destructor.

Definition at line 58 of file qgsdistancearea.cpp.

QgsDistanceArea::QgsDistanceArea ( const QgsDistanceArea origDA)

Copy constructor.

Definition at line 53 of file qgsdistancearea.cpp.

Member Function Documentation

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

compute bearing - in radians

Definition at line 621 of file qgsdistancearea.cpp.

void QgsDistanceArea::computeAreaInit ( )
protected

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

Definition at line 794 of file qgsdistancearea.cpp.

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

calculate distance with given coordinates (does not do a transform anymore)

Definition at line 728 of file qgsdistancearea.cpp.

double QgsDistanceArea::computeDistanceBearing ( const QgsPoint p1,
const QgsPoint p2,
double *  course1 = NULL,
double *  course2 = NULL 
) const
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 646 of file qgsdistancearea.cpp.

double QgsDistanceArea::computeDistanceFlat ( const QgsPoint p1,
const QgsPoint p2 
) const
protected

uses flat / planimetric / Euclidean distance

Definition at line 723 of file qgsdistancearea.cpp.

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

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

Definition at line 829 of file qgsdistancearea.cpp.

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

Definition at line 886 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 1036 of file qgsdistancearea.cpp.

const QString& QgsDistanceArea::ellipsoid ( ) const
inline

returns ellipsoid's acronym

Definition at line 80 of file qgsdistancearea.h.

bool QgsDistanceArea::ellipsoidalEnabled ( ) const
inline

returns projections enabled flag

Definition at line 53 of file qgsdistancearea.h.

double QgsDistanceArea::ellipsoidInverseFlattening ( ) const
inline

returns ellipsoid's inverse flattening

Definition at line 87 of file qgsdistancearea.h.

double QgsDistanceArea::ellipsoidSemiMajor ( ) const
inline

returns ellipsoid's semi major axis

Definition at line 83 of file qgsdistancearea.h.

double QgsDistanceArea::ellipsoidSemiMinor ( ) const
inline

returns ellipsoid's semi minor axis

Definition at line 85 of file qgsdistancearea.h.

bool QgsDistanceArea::geographic ( ) const
inline

What sort of coordinate system is being used?

Definition at line 70 of file qgsdistancearea.h.

double QgsDistanceArea::measure ( const QgsGeometry geometry) const

general measurement (line distance or polygon area)

Definition at line 259 of file qgsdistancearea.cpp.

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

measures line

Definition at line 421 of file qgsdistancearea.cpp.

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

measures line with one segment

Definition at line 463 of file qgsdistancearea.cpp.

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

measures line distance, line points are extracted from WKB

Definition at line 394 of file qgsdistancearea.cpp.

double QgsDistanceArea::measurePerimeter ( const QgsGeometry geometry) const

measures perimeter of polygon

Definition at line 334 of file qgsdistancearea.cpp.

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

measures polygon area

Definition at line 594 of file qgsdistancearea.cpp.

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

measures polygon area and perimeter, vertices are extracted from WKB

Definition at line 499 of file qgsdistancearea.cpp.

QgsDistanceArea & QgsDistanceArea::operator= ( const QgsDistanceArea origDA)

Assignment operator.

Definition at line 64 of file qgsdistancearea.cpp.

bool QgsDistanceArea::setEllipsoid ( const QString ellipsoid)

sets ellipsoid by its acronym

Definition at line 113 of file qgsdistancearea.cpp.

bool QgsDistanceArea::setEllipsoid ( double  semiMajor,
double  semiMinor 
)

Sets ellipsoid by supplied radii.

Definition at line 247 of file qgsdistancearea.cpp.

void QgsDistanceArea::setEllipsoidalMode ( bool  flag)

sets whether coordinates must be projected to ellipsoid before measuring

Definition at line 89 of file qgsdistancearea.cpp.

void QgsDistanceArea::setSourceAuthId ( QString  authid)

sets source spatial reference system by authid

Definition at line 106 of file qgsdistancearea.cpp.

void QgsDistanceArea::setSourceCrs ( long  srsid)

sets source spatial reference system (by QGIS CRS)

Definition at line 94 of file qgsdistancearea.cpp.

void QgsDistanceArea::setSourceCrs ( const QgsCoordinateReferenceSystem srcCRS)

Sets source spatial reference system (by QGIS CRS)

Note
: missing in Python bindings in QGIS < 2.2

Definition at line 101 of file qgsdistancearea.cpp.

long QgsDistanceArea::sourceCrs ( ) const
inline

returns source spatial reference system

Definition at line 68 of file qgsdistancearea.h.

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

Definition at line 907 of file qgsdistancearea.cpp.


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