QGIS API Documentation 3.41.0-Master (3440c17df1d)
|
A class to represent a 2D point. More...
#include <qgspointxy.h>
Public Member Functions | |
QgsPointXY ()=default | |
QgsPointXY (const QgsPoint &point) | |
Create a new point. | |
QgsPointXY (const QgsPointXY &p) | |
QgsPointXY (double x, double y) | |
Create a point from x,y coordinates. | |
QgsPointXY (QPoint point) | |
Create a point from a QPoint. | |
QgsPointXY (QPointF point) | |
Create a point from a QPointF. | |
~QgsPointXY ()=default | |
QString | asWkt () const |
Returns the well known text representation for the point (e.g. | |
double | azimuth (const QgsPointXY &other) const |
Calculates azimuth between this point and other one (clockwise in degree, starting from north) | |
bool | compare (const QgsPointXY &other, double epsilon=4 *std::numeric_limits< double >::epsilon()) const |
Compares this point with another point with a fuzzy tolerance. | |
double | distance (const QgsPointXY &other) const |
Returns the distance between this point and another point. | |
double | distance (double x, double y) const |
Returns the distance between this point and a specified x, y coordinate. | |
bool | distanceCompare (const QgsPointXY &other, double epsilon=4 *std::numeric_limits< double >::epsilon()) const |
Compares this point with another point with a fuzzy tolerance using distance comparison. | |
bool | isEmpty () const |
Returns true if the geometry is empty. | |
void | multiply (double scalar) |
Multiply x and y by the given value. | |
operator QVariant () const | |
Allows direct construction of QVariants from points. | |
bool | operator!= (const QgsPointXY &other) const |
QgsPointXY | operator* (double scalar) const |
Multiplies the coordinates in this point by a scalar quantity. | |
QgsPointXY & | operator*= (double scalar) |
Multiplies the coordinates in this point by a scalar quantity in place. | |
QgsPointXY | operator+ (QgsVector v) const |
Adds a vector to this point. | |
QgsPointXY & | operator+= (QgsVector v) |
Adds a vector to this point in place. | |
QgsVector | operator- (const QgsPointXY &p) const |
Calculates the vector obtained by subtracting a point from this point. | |
QgsPointXY | operator- (QgsVector v) const |
Subtracts a vector from this point. | |
QgsPointXY & | operator-= (QgsVector v) |
Subtracts a vector from this point in place. | |
QgsPointXY | operator/ (double scalar) const |
Divides the coordinates in this point by a scalar quantity. | |
QgsPointXY & | operator/= (double scalar) |
Divides the coordinates in this point by a scalar quantity in place. | |
QgsPointXY & | operator= (const QgsPointXY &other) |
bool | operator== (const QgsPointXY &other) const |
QgsPointXY | project (double distance, double bearing) const |
Returns a new point which corresponds to this point projected by a specified distance in a specified bearing. | |
void | set (double x, double y) |
Sets the x and y value of the point. | |
void | setX (double x) |
Sets the x value of the point. | |
void | setY (double y) |
Sets the y value of the point. | |
double | sqrDist (const QgsPointXY &other) const |
Returns the squared distance between this point another point. | |
double | sqrDist (double x, double y) const |
Returns the squared distance between this point a specified x, y coordinate. | |
double | sqrDistToSegment (double x1, double y1, double x2, double y2, QgsPointXY &minDistPoint, double epsilon=DEFAULT_SEGMENT_EPSILON) const |
Returns the minimum distance between this point and a segment. | |
QPointF | toQPointF () const |
Converts a point to a QPointF. | |
QString | toString (int precision=-1) const |
Returns a string representation of the point (x, y) with a preset precision. | |
double | x () const |
Gets the x value of the point. | |
double | y () const |
Gets the y value of the point. | |
Properties | |
double | x |
double | y |
Friends | |
uint | qHash (const QgsPointXY &pnt) |
A class to represent a 2D point.
A QgsPointXY represents a strictly 2-dimensional position, with only X and Y coordinates. This is a very lightweight class, designed to minimize the memory requirements of storing millions of points.
In many scenarios it is preferable to use a QgsPoint instead which also supports optional Z and M values. QgsPointXY should only be used for situations where a point can only EVER be two dimensional.
Some valid use cases for QgsPointXY include:
Use cases for which QgsPointXY is NOT a valid choice include:
Definition at line 59 of file qgspointxy.h.
|
default |
QgsPointXY::QgsPointXY | ( | const QgsPointXY & | p | ) |
Definition at line 29 of file qgspointxy.cpp.
|
inline |
Create a point from x,y coordinates.
x | x coordinate |
y | y coordinate |
Definition at line 77 of file qgspointxy.h.
|
inline |
Create a point from a QPointF.
point | QPointF source |
Definition at line 87 of file qgspointxy.h.
|
inline |
Create a point from a QPoint.
point | QPoint source |
Definition at line 97 of file qgspointxy.h.
QgsPointXY::QgsPointXY | ( | const QgsPoint & | point | ) |
|
default |
QString QgsPointXY::asWkt | ( | ) | const |
Returns the well known text representation for the point (e.g.
"POINT(x y)"). The wkt is created without an SRID.
Definition at line 70 of file qgspointxy.cpp.
double QgsPointXY::azimuth | ( | const QgsPointXY & | other | ) | const |
Calculates azimuth between this point and other one (clockwise in degree, starting from north)
Definition at line 81 of file qgspointxy.cpp.
|
inline |
Compares this point with another point with a fuzzy tolerance.
other | point to compare with |
epsilon | maximum difference for coordinates between the points |
true
if points are equal within specified toleranceDefinition at line 253 of file qgspointxy.h.
|
inline |
Returns the distance between this point and another point.
other | other point |
Definition at line 216 of file qgspointxy.h.
|
inline |
Returns the distance between this point and a specified x, y coordinate.
x | x-coordniate |
y | y-coordinate |
Definition at line 206 of file qgspointxy.h.
|
inline |
Compares this point with another point with a fuzzy tolerance using distance comparison.
other | point to compare with |
epsilon | maximum difference for coordinates between the points |
true
if points are equal within specified toleranceDefinition at line 268 of file qgspointxy.h.
|
inline |
Returns true
if the geometry is empty.
Unlike QgsPoint, this class is also used to retrieve graphical coordinates like QPointF. It therefore has the default coordinates (0.0). A QgsPointXY is considered empty, when the coordinates have not been explicitly filled in.
Definition at line 242 of file qgspointxy.h.
|
inline |
Multiply x and y by the given value.
Definition at line 298 of file qgspointxy.h.
|
inline |
Allows direct construction of QVariants from points.
Definition at line 344 of file qgspointxy.h.
|
inline |
Definition at line 285 of file qgspointxy.h.
|
inline |
Multiplies the coordinates in this point by a scalar quantity.
Definition at line 332 of file qgspointxy.h.
|
inline |
Multiplies the coordinates in this point by a scalar quantity in place.
Definition at line 338 of file qgspointxy.h.
|
inline |
Adds a vector to this point.
Definition at line 326 of file qgspointxy.h.
|
inline |
Adds a vector to this point in place.
Definition at line 320 of file qgspointxy.h.
|
inline |
Calculates the vector obtained by subtracting a point from this point.
Definition at line 317 of file qgspointxy.h.
|
inline |
Subtracts a vector from this point.
Definition at line 329 of file qgspointxy.h.
|
inline |
Subtracts a vector from this point in place.
Definition at line 323 of file qgspointxy.h.
|
inline |
Divides the coordinates in this point by a scalar quantity.
Definition at line 335 of file qgspointxy.h.
|
inline |
Divides the coordinates in this point by a scalar quantity in place.
Definition at line 341 of file qgspointxy.h.
|
inline |
Definition at line 304 of file qgspointxy.h.
|
inline |
Definition at line 273 of file qgspointxy.h.
QgsPointXY QgsPointXY::project | ( | double | distance, |
double | bearing | ||
) | const |
Returns a new point which corresponds to this point projected by a specified distance in a specified bearing.
distance | distance to project |
bearing | angle to project in, clockwise in degrees starting from north |
Definition at line 88 of file qgspointxy.cpp.
|
inline |
Sets the x and y value of the point.
Definition at line 136 of file qgspointxy.h.
|
inline |
Sets the x value of the point.
x | x coordinate |
Definition at line 119 of file qgspointxy.h.
|
inline |
Sets the y value of the point.
y | y coordinate |
Definition at line 129 of file qgspointxy.h.
|
inline |
Returns the squared distance between this point another point.
Definition at line 195 of file qgspointxy.h.
|
inline |
Returns the squared distance between this point a specified x, y coordinate.
Definition at line 186 of file qgspointxy.h.
double QgsPointXY::sqrDistToSegment | ( | double | x1, |
double | y1, | ||
double | x2, | ||
double | y2, | ||
QgsPointXY & | minDistPoint, | ||
double | epsilon = DEFAULT_SEGMENT_EPSILON |
||
) | const |
Returns the minimum distance between this point and a segment.
Definition at line 96 of file qgspointxy.cpp.
|
inline |
Converts a point to a QPointF.
Definition at line 165 of file qgspointxy.h.
QString QgsPointXY::toString | ( | int | precision = -1 | ) | const |
Returns a string representation of the point (x, y) with a preset precision.
If precision is -1, then a default precision will be used.
Definition at line 52 of file qgspointxy.cpp.
|
inline |
|
inline |
|
friend |
Definition at line 409 of file qgspointxy.h.
|
readwrite |
Definition at line 63 of file qgspointxy.h.
|
readwrite |
Definition at line 64 of file qgspointxy.h.