QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
QgsPoint Class Reference

A class to represent a point. More...

`#include <qgspoint.h>`

## Public Member Functions

QgsPoint ()
Default constructor. More...

QgsPoint (const QgsPoint &p)
Create a point from another point. More...

QgsPoint (double x, double y)
Create a point from x,y coordinates. More...

QgsPoint (QPointF point)
Create a point from a QPointF. More...

QgsPoint (QPoint point)
Create a point from a QPoint. More...

~QgsPoint ()

double azimuth (const QgsPoint &other) const
Calculates azimuth between this point and other one (clockwise in degree, starting from north) More...

bool compare (const QgsPoint &other, double epsilon=4 *DBL_EPSILON) const
Compares this point with another point with a fuzzy tolerance. More...

double distance (double x, double y) const
Returns the distance between this point and a specified x, y coordinate. More...

double distance (const QgsPoint &other) const
Returns the distance between this point and another point. More...

void multiply (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...

bool operator!= (const QgsPoint &other) const
Inequality operator. More...

QgsPoint operator* (double scalar) const
Multiplies the coordinates in this point by a scalar quantity. More...

QgsPointoperator*= (double scalar)
Multiplies the coordinates in this point by a scalar quantity in place. More...

QgsPoint operator+ (QgsVector v) const
Adds a vector to this point. More...

QgsPointoperator+= (QgsVector v)
Adds a vector to this point in place. More...

QgsVector operator- (const QgsPoint &p) const
Calculates the vector obtained by subtracting a point from this point. More...

QgsPoint operator- (QgsVector v) const
Subtracts a vector from this point. More...

QgsPointoperator-= (QgsVector v)
Subtracts a vector from this point in place. More...

QgsPoint operator/ (double scalar) const
Divides the coordinates in this point by a scalar quantity. More...

QgsPointoperator/= (double scalar)
Divides the coordinates in this point by a scalar quantity in place. More...

QgsPointoperator= (const QgsPoint &other)
Assignment. More...

bool operator== (const QgsPoint &other)
equality operator More...

QgsPoint project (double distance, double bearing) const
Returns a new point which correponds to this point projected by a specified distance in a specified bearing. More...

void set (double x, double y)
Sets the x and y value of the point. More...

void setX (double x)
Sets the x value of the point. More...

void setY (double y)
Sets the y value of the point. More...

double sqrDist (double x, double y) const
Returns the squared distance between this point a specified x, y coordinate. More...

double sqrDist (const QgsPoint &other) const
Returns the squared distance between this point another 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...

QString toDegreesMinutes (int thePrecision, const bool useSuffix=true, const bool padded=false) const
Return a string representation as degrees minutes. More...

QString toDegreesMinutesSeconds (int thePrecision, const bool useSuffix=true, const bool padded=false) const
Return a string representation as degrees minutes seconds. More...

QPointF toQPointF () const
Converts a point to a QPointF. More...

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 wellKnownText () const
Return the well known text representation for the point. More...

double x () const
Get the x value of the point. More...

double y () const
Get the y value of the point. More...

## Friends

uint qHash (const QgsPoint &pnt)

## Detailed Description

A class to represent a point.

Currently no Z axis / 2.5D support is implemented.

Definition at line 117 of file qgspoint.h.

## ◆ QgsPoint() [1/5]

 QgsPoint::QgsPoint ( )
inline

Default constructor.

Definition at line 121 of file qgspoint.h.

## ◆ QgsPoint() [2/5]

 QgsPoint::QgsPoint ( const QgsPoint & p )

Create a point from another point.

Definition at line 123 of file qgspoint.cpp.

## ◆ QgsPoint() [3/5]

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

Create a point from x,y coordinates.

Parameters
 x x coordinate y y coordinate

Definition at line 133 of file qgspoint.h.

## ◆ QgsPoint() [4/5]

 QgsPoint::QgsPoint ( QPointF point )
inline

Create a point from a QPointF.

Parameters
 point QPointF source
Note

Definition at line 142 of file qgspoint.h.

## ◆ QgsPoint() [5/5]

 QgsPoint::QgsPoint ( QPoint point )
inline

Create a point from a QPoint.

Parameters
 point QPoint source
Note

Definition at line 151 of file qgspoint.h.

## ◆ ~QgsPoint()

 QgsPoint::~QgsPoint ( )
inline

Definition at line 156 of file qgspoint.h.

## ◆ azimuth()

 double QgsPoint::azimuth ( const QgsPoint & other ) const

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

Definition at line 373 of file qgspoint.cpp.

## ◆ compare()

 bool QgsPoint::compare ( const QgsPoint & other, double epsilon = `4 * DBL_EPSILON` ) const

Compares this point with another point with a fuzzy tolerance.

Parameters
 other point to compare with epsilon maximum difference for coordinates between the points
Returns
true if points are equal within specified tolerance
Note

Definition at line 388 of file qgspoint.cpp.

## ◆ distance() [1/2]

 double QgsPoint::distance ( double x, double y ) const

Returns the distance between this point and a specified x, y coordinate.

Parameters
 x x-coordniate y y-coordinate
sqrDist()
Note

Definition at line 363 of file qgspoint.cpp.

## ◆ distance() [2/2]

 double QgsPoint::distance ( const QgsPoint & other ) const

Returns the distance between this point and another point.

Parameters
 other other point
sqrDist()
Note

Definition at line 368 of file qgspoint.cpp.

## ◆ multiply()

 void QgsPoint::multiply ( double scalar )

Multiply x and y by the given value.

Definition at line 421 of file qgspoint.cpp.

## ◆ onSegment()

 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.

Definition at line 427 of file qgspoint.cpp.

## ◆ operator!=()

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

Inequality operator.

Definition at line 402 of file qgspoint.cpp.

## ◆ operator*()

 QgsPoint QgsPoint::operator* ( double scalar ) const
inline

Multiplies the coordinates in this point by a scalar quantity.

Definition at line 320 of file qgspoint.h.

## ◆ operator*=()

 QgsPoint& QgsPoint::operator*= ( double scalar )
inline

Multiplies the coordinates in this point by a scalar quantity in place.

Definition at line 326 of file qgspoint.h.

## ◆ operator+()

 QgsPoint QgsPoint::operator+ ( QgsVector v ) const
inline

Adds a vector to this point.

Definition at line 314 of file qgspoint.h.

## ◆ operator+=()

 QgsPoint& QgsPoint::operator+= ( QgsVector v )
inline

Adds a vector to this point in place.

Definition at line 308 of file qgspoint.h.

## ◆ operator-() [1/2]

 QgsVector QgsPoint::operator- ( const QgsPoint & p ) const
inline

Calculates the vector obtained by subtracting a point from this point.

Definition at line 305 of file qgspoint.h.

## ◆ operator-() [2/2]

 QgsPoint QgsPoint::operator- ( QgsVector v ) const
inline

Subtracts a vector from this point.

Definition at line 317 of file qgspoint.h.

## ◆ operator-=()

 QgsPoint& QgsPoint::operator-= ( QgsVector v )
inline

Subtracts a vector from this point in place.

Definition at line 311 of file qgspoint.h.

## ◆ operator/()

 QgsPoint QgsPoint::operator/ ( double scalar ) const
inline

Divides the coordinates in this point by a scalar quantity.

Definition at line 323 of file qgspoint.h.

## ◆ operator/=()

 QgsPoint& QgsPoint::operator/= ( double scalar )
inline

Divides the coordinates in this point by a scalar quantity in place.

Definition at line 329 of file qgspoint.h.

## ◆ operator=()

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

Assignment.

Definition at line 410 of file qgspoint.cpp.

## ◆ operator==()

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

equality operator

Definition at line 394 of file qgspoint.cpp.

## ◆ project()

 QgsPoint QgsPoint::project ( double distance, double bearing ) const

Returns a new point which correponds to this point projected by a specified distance in a specified bearing.

Parameters
 distance distance to project bearing angle to project in, clockwise in degrees starting from north
Note

Definition at line 380 of file qgspoint.cpp.

## ◆ set()

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

Sets the x and y value of the point.

Definition at line 176 of file qgspoint.h.

## ◆ setX()

 void QgsPoint::setX ( double x )
inline

Sets the x value of the point.

Parameters
 x x coordinate

Definition at line 162 of file qgspoint.h.

## ◆ setY()

 void QgsPoint::setY ( double y )
inline

Sets the y value of the point.

Parameters
 y y coordinate

Definition at line 170 of file qgspoint.h.

## ◆ sqrDist() [1/2]

 double QgsPoint::sqrDist ( double x, double y ) const

Returns the squared distance between this point a specified x, y coordinate.

distance()

Definition at line 353 of file qgspoint.cpp.

## ◆ sqrDist() [2/2]

 double QgsPoint::sqrDist ( const QgsPoint & other ) const

Returns the squared distance between this point another point.

distance()

Definition at line 358 of file qgspoint.cpp.

## ◆ sqrDistToSegment()

 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.

Definition at line 457 of file qgspoint.cpp.

## ◆ toDegreesMinutes()

 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
 thePrecision number of decimal points to use for minutes useSuffix set to true to include a direction suffix (eg 'N'), set to false to use a "-" prefix for west and south coordinates padded set to true to force minutes to use two decimals, eg, '05' instead of '5'.

Definition at line 264 of file qgspoint.cpp.

## ◆ toDegreesMinutesSeconds()

 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
 thePrecision number of decimal points to use for seconds useSuffix set to true to include a direction suffix (eg 'N'), set to false to use a "-" prefix for west and south coordinates padded set to true to force minutes and seconds to use two decimals, eg, '05' instead of '5'.

Definition at line 150 of file qgspoint.cpp.

## ◆ toQPointF()

 QPointF QgsPoint::toQPointF ( ) const

Converts a point to a QPointF.

Returns
QPointF with same x and y values
Note

Definition at line 129 of file qgspoint.cpp.

## ◆ toString() [1/2]

 QString QgsPoint::toString ( ) const

String representation of the point (x,y)

Definition at line 134 of file qgspoint.cpp.

## ◆ toString() [2/2]

 QString QgsPoint::toString ( int thePrecision ) const

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

Definition at line 143 of file qgspoint.cpp.

## ◆ wellKnownText()

 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)

Definition at line 348 of file qgspoint.cpp.

## ◆ x()

 double QgsPoint::x ( ) const
inline

Get the x value of the point.

Returns
x coordinate

Definition at line 185 of file qgspoint.h.

## ◆ y()

 double QgsPoint::y ( ) const
inline

Get the y value of the point.

Returns
y coordinate

Definition at line 193 of file qgspoint.h.

## ◆ qHash

 uint qHash ( const QgsPoint & pnt )
friend

Definition at line 359 of file qgspoint.h.

The documentation for this class was generated from the following files:
• /tmp/buildd/qgis-2.18.21+99unstable/src/core/qgspoint.h
• /tmp/buildd/qgis-2.18.21+99unstable/src/core/qgspoint.cpp