QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | Friends | List of all members
QgsPoint Class Reference

A class to represent a point geometry. More...

#include <qgspoint.h>

Public Member Functions

 QgsPoint ()
 Default constructor. More...
 
 QgsPoint (const QgsPoint &p)
 
 QgsPoint (double x, double y)
 
 ~QgsPoint ()
 
void setX (double x)
 
void setY (double y)
 
void set (double x, double y)
 
double x () const
 
double y () const
 
QString toString () const
 String representation of the point (x,y) More...
 
QString toString (int thePrecision) const
 As above but with precision for string representation of a point. More...
 
QString toDegreesMinutesSeconds (int thePrecision, const bool useSuffix=true, const bool padded=false) const
 Return a string representation as degrees minutes seconds. More...
 
QString toDegreesMinutes (int thePrecision, const bool useSuffix=true, const bool padded=false) const
 Return a string representation as degrees minutes. More...
 
QString wellKnownText () const
 
double sqrDist (double x, double y) const
 Returns the squared distance between this point and x,y. More...
 
double sqrDist (const QgsPoint &other) const
 Returns the squared distance between this and other point. More...
 
double sqrDistToSegment (double x1, double y1, double x2, double y2, QgsPoint &minDistPoint, double epsilon=DEFAULT_SEGMENT_EPSILON) const
 Returns the minimum distance between this point and a segment. More...
 
double azimuth (const QgsPoint &other)
 Calculates azimut between this point and other one (clockwise in degree, starting from north) More...
 
bool operator== (const QgsPoint &other)
 equality operator More...
 
bool operator!= (const QgsPoint &other) const
 Inequality operator. More...
 
void multiply (const double &scalar)
 Multiply x and y by the given value. More...
 
int onSegment (const QgsPoint &a, const QgsPoint &b) const
 Test if this point is on the segment defined by points a, b. More...
 
QgsPointoperator= (const QgsPoint &other)
 Assignment. More...
 
QgsVector operator- (QgsPoint p) const
 
QgsPointoperator+= (const QgsVector &v)
 
QgsPointoperator-= (const QgsVector &v)
 
QgsPoint operator+ (const QgsVector &v) const
 
QgsPoint operator- (const QgsVector &v) const
 

Friends

uint qHash (const QgsPoint &pnt)
 

Detailed Description

A class to represent a point geometry.

Currently no Z axis / 2.5D support is implemented.

Constructor & Destructor Documentation

QgsPoint::QgsPoint ( )
inline

Default constructor.

QgsPoint::QgsPoint ( const QgsPoint p)

Create a point from another point

QgsPoint::QgsPoint ( double  x,
double  y 
)
inline

Create a point from x,y coordinates

Parameters
xx coordinate
yy coordinate
QgsPoint::~QgsPoint ( )
inline

Member Function Documentation

double QgsPoint::azimuth ( const QgsPoint other)

Calculates azimut between this point and other one (clockwise in degree, starting from north)

void QgsPoint::multiply ( const double &  scalar)

Multiply x and y by the given value.

int QgsPoint::onSegment ( const QgsPoint a,
const QgsPoint b 
) const

Test if this point is on the segment defined by points a, b.

Returns
0 if this point is not on the open ray through a and b, 1 if point is on open ray a, 2 if point is within line segment, 3 if point is on open ray b.
bool QgsPoint::operator!= ( const QgsPoint other) const

Inequality operator.

QgsPoint QgsPoint::operator+ ( const QgsVector v) const
inline
QgsPoint& QgsPoint::operator+= ( const QgsVector v)
inline
QgsVector QgsPoint::operator- ( QgsPoint  p) const
inline
QgsPoint QgsPoint::operator- ( const QgsVector v) const
inline
QgsPoint& QgsPoint::operator-= ( const QgsVector v)
inline
QgsPoint & QgsPoint::operator= ( const QgsPoint other)

Assignment.

bool QgsPoint::operator== ( const QgsPoint other)

equality operator

void QgsPoint::set ( double  x,
double  y 
)
inline

Sets the x and y value of the point

void QgsPoint::setX ( double  x)
inline

Sets the x value of the point

Parameters
xx coordinate
void QgsPoint::setY ( double  y)
inline

Sets the y value of the point

Parameters
yy coordinate
double QgsPoint::sqrDist ( double  x,
double  y 
) const

Returns the squared distance between this point and x,y.

double QgsPoint::sqrDist ( const QgsPoint other) const

Returns the squared distance between this and other point.

double QgsPoint::sqrDistToSegment ( double  x1,
double  y1,
double  x2,
double  y2,
QgsPoint minDistPoint,
double  epsilon = DEFAULT_SEGMENT_EPSILON 
) const

Returns the minimum distance between this point and a segment.

QString QgsPoint::toDegreesMinutes ( int  thePrecision,
const bool  useSuffix = true,
const bool  padded = false 
) const

Return a string representation as degrees minutes.

Its up to the calling function to ensure that this point can be meaningfully represented in this form.

Parameters
thePrecisionnumber of decimal points to use for minutes
useSuffixset to true to include a direction suffix (eg 'N'), set to false to use a "-" prefix for west and south coordinates
paddedset to true to force minutes to use two decimals, eg, '05' instead of '5'.
QString QgsPoint::toDegreesMinutesSeconds ( int  thePrecision,
const bool  useSuffix = true,
const bool  padded = false 
) const

Return a string representation as degrees minutes seconds.

Its up to the calling function to ensure that this point can be meaningfully represented in this form.

Parameters
thePrecisionnumber of decimal points to use for seconds
useSuffixset to true to include a direction suffix (eg 'N'), set to false to use a "-" prefix for west and south coordinates
paddedset to true to force minutes and seconds to use two decimals, eg, '05' instead of '5'.
QString QgsPoint::toString ( ) const

String representation of the point (x,y)

QString QgsPoint::toString ( int  thePrecision) const

As above but with precision for string representation of a point.

QString QgsPoint::wellKnownText ( ) const

Return the well known text representation for the point. The wkt is created without an SRID.

Returns
Well known text in the form POINT(x y)
double QgsPoint::x ( ) const
inline

Get the x value of the point

Returns
x coordinate
double QgsPoint::y ( ) const
inline

Get the y value of the point

Returns
y coordinate

Friends And Related Function Documentation

uint qHash ( const QgsPoint pnt)
friend

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