QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules 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. More...
 
 ~QgsDistanceArea ()
 Destructor. More...
 
 QgsDistanceArea (const QgsDistanceArea &origDA)
 Copy constructor. More...
 
QgsDistanceAreaoperator= (const QgsDistanceArea &origDA)
 Assignment operator. More...
 
void setEllipsoidalMode (bool flag)
 sets whether coordinates must be projected to ellipsoid before measuring More...
 
bool ellipsoidalEnabled () const
 returns projections enabled flag 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...
 
void setSourceAuthId (QString authid)
 sets source spatial reference system by authid More...
 
long sourceCrs () const
 returns source spatial reference system More...
 
bool geographic () const
 What sort of coordinate system is being used? More...
 
bool setEllipsoid (const QString &ellipsoid)
 sets ellipsoid by its acronym More...
 
bool setEllipsoid (double semiMajor, double semiMinor)
 Sets ellipsoid by supplied radii. More...
 
const QString & ellipsoid () const
 returns ellipsoid's acronym More...
 
double ellipsoidSemiMajor () const
 returns ellipsoid's semi major axis More...
 
double ellipsoidSemiMinor () const
 returns ellipsoid's semi minor axis More...
 
double ellipsoidInverseFlattening () const
 returns ellipsoid's inverse flattening More...
 
double measure (QgsGeometry *geometry)
 general measurement (line distance or polygon area) More...
 
double measurePerimeter (QgsGeometry *geometry)
 measures perimeter of polygon More...
 
double measureLine (const QList< QgsPoint > &points)
 measures line More...
 
double measureLine (const QgsPoint &p1, const QgsPoint &p2)
 measures line with one segment More...
 
double measurePolygon (const QList< QgsPoint > &points)
 measures polygon area More...
 
double bearing (const QgsPoint &p1, const QgsPoint &p2)
 compute bearing - in radians More...
 
void convertMeasurement (double &measure, QGis::UnitType &measureUnits, QGis::UnitType displayUnits, bool isArea)
 Helper for conversion between physical units. More...
 

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 More...
 
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 More...
 
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 More...
 
double computeDistanceFlat (const QgsPoint &p1, const QgsPoint &p2)
 uses flat / planimetric / Euclidean distance More...
 
double computeDistance (const QList< QgsPoint > &points)
 calculate distance with given coordinates (does not do a transform anymore) More...
 
double computePolygonArea (const QList< QgsPoint > &points)
 calculates area of polygon on ellipsoid algorithm has been taken from GRASS: gis/area_poly1.c More...
 
double computePolygonFlatArea (const QList< QgsPoint > &points)
 
void computeAreaInit ()
 precalculates some values (must be called always when changing ellipsoid) More...
 

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: