QGIS API Documentation  2.6.0-Brighton
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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.
 ~QgsDistanceArea ()
 Destructor.
 QgsDistanceArea (const QgsDistanceArea &origDA)
 Copy constructor.
QgsDistanceAreaoperator= (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 computeDistanceFlat (const QgsPoint &p1, const QgsPoint &p2)
 uses flat / planimetric / Euclidean distance
double computeDistance (const QList< QgsPoint > &points)
 calculate distance with given coordinates (does not do a transform anymore)
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)

Detailed Description

General purpose distance and area calculator.

Constructor & Destructor Documentation

QgsDistanceArea::QgsDistanceArea ( )

Constructor.

QgsDistanceArea::~QgsDistanceArea ( )

Destructor.

QgsDistanceArea::QgsDistanceArea ( const QgsDistanceArea origDA)

Copy constructor.

Member Function Documentation

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

compute bearing - in radians

void QgsDistanceArea::computeAreaInit ( )
protected

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

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

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

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
double QgsDistanceArea::computeDistanceFlat ( const QgsPoint p1,
const QgsPoint p2 
)
protected

uses flat / planimetric / Euclidean distance

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

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

double QgsDistanceArea::computePolygonFlatArea ( const QList< QgsPoint > &  points)
protected
void QgsDistanceArea::convertMeasurement ( double &  measure,
QGis::UnitType measureUnits,
QGis::UnitType  displayUnits,
bool  isArea 
)

Helper for conversion between physical units.

const QString& QgsDistanceArea::ellipsoid ( ) const
inline

returns ellipsoid's acronym

bool QgsDistanceArea::ellipsoidalEnabled ( ) const
inline

returns projections enabled flag

double QgsDistanceArea::ellipsoidInverseFlattening ( ) const
inline

returns ellipsoid's inverse flattening

double QgsDistanceArea::ellipsoidSemiMajor ( ) const
inline

returns ellipsoid's semi major axis

double QgsDistanceArea::ellipsoidSemiMinor ( ) const
inline

returns ellipsoid's semi minor axis

bool QgsDistanceArea::geographic ( ) const
inline

What sort of coordinate system is being used?

double QgsDistanceArea::measure ( QgsGeometry geometry)

general measurement (line distance or polygon area)

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

measures line

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

measures line with one segment

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

measures line distance, line points are extracted from WKB

double QgsDistanceArea::measurePerimeter ( QgsGeometry geometry)

measures perimeter of polygon

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

measures polygon area

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

measures polygon area and perimeter, vertices are extracted from WKB

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

Assignment operator.

bool QgsDistanceArea::setEllipsoid ( const QString &  ellipsoid)

sets ellipsoid by its acronym

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

Sets ellipsoid by supplied radii.

void QgsDistanceArea::setEllipsoidalMode ( bool  flag)

sets whether coordinates must be projected to ellipsoid before measuring

void QgsDistanceArea::setSourceAuthId ( QString  authid)

sets source spatial reference system by authid

void QgsDistanceArea::setSourceCrs ( long  srsid)

sets source spatial reference system (by QGIS CRS)

void QgsDistanceArea::setSourceCrs ( const QgsCoordinateReferenceSystem srcCRS)

Sets source spatial reference system (by QGIS CRS)

Note
: missing in Python bindings in QGIS < 2.2
long QgsDistanceArea::sourceCrs ( ) const
inline

returns source spatial reference system

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

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