QgsPointXY class
A class to represent a 2D point.
Contents
A QgsPointXY represents a position with X and Y coordinates. In most scenarios it is preferable to use a QgsPoint instead which also supports Z and M values.
Derived classes
- class QgsReferencedPointXY
- A QgsPointXY with associated coordinate reference system.
Constructors, destructors, conversion operators
- QgsPointXY() defaulted
- Default constructor.
- QgsPointXY(const QgsPointXY& p)
- Create a point from another point.
- QgsPointXY(double x, double y)
- Create a point from x,y coordinates.
- QgsPointXY(QPointF point)
- Create a point from a QPointF.
- QgsPointXY(QPoint point)
- Create a point from a QPoint.
- QgsPointXY(const QgsPoint& point)
- Create a new point.
- operator QVariant() const
- Allows direct construction of QVariants from points.
Public functions
- auto asWkt() const -> QString
- Returns the well known text representation for the point (e.g.
- auto azimuth(const QgsPointXY& other) const -> double
- Calculates azimuth between this point and other one (clockwise in degree, starting from north)
- auto compare(const QgsPointXY& other, double epsilon = 4*std::numeric_limits<double>::epsilon()) const -> bool
- Compares this point with another point with a fuzzy tolerance.
- auto distance(double x, double y) const -> double
- Returns the distance between this point and a specified x, y coordinate.
- auto distance(const QgsPointXY& other) const -> double
- Returns the distance between this point and another point.
- void multiply(double scalar)
- Multiply x and y by the given value.
- auto operator!=(const QgsPointXY& other) const -> bool
- Inequality operator.
- auto operator*(double scalar) const -> QgsPointXY
- Multiplies the coordinates in this point by a scalar quantity.
- auto operator*=(double scalar) -> QgsPointXY&
- Multiplies the coordinates in this point by a scalar quantity in place.
- auto operator+(QgsVector v) const -> QgsPointXY
- Adds a vector to this point.
- auto operator+=(QgsVector v) -> QgsPointXY&
- Adds a vector to this point in place.
- auto operator-(const QgsPointXY& p) const -> QgsVector
- Calculates the vector obtained by subtracting a point from this point.
- auto operator-(QgsVector v) const -> QgsPointXY
- Subtracts a vector from this point.
- auto operator-=(QgsVector v) -> QgsPointXY&
- Subtracts a vector from this point in place.
- auto operator/(double scalar) const -> QgsPointXY
- Divides the coordinates in this point by a scalar quantity.
- auto operator/=(double scalar) -> QgsPointXY&
- Divides the coordinates in this point by a scalar quantity in place.
- auto operator=(const QgsPointXY& other) -> QgsPointXY&
- Assignment.
- auto operator==(const QgsPointXY& other) -> bool
- equality operator
- auto project(double distance, double bearing) const -> QgsPointXY
- 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.
- auto sqrDist(double x, double y) const -> double
- Returns the squared distance between this point a specified x, y coordinate.
- auto sqrDist(const QgsPointXY& other) const -> double
- Returns the squared distance between this point another point.
-
auto sqrDistToSegment(double x1,
double y1,
double x2,
double y2,
QgsPointXY& minDistPoint,
double epsilon = DEFAULT_
SEGMENT_ EPSILON) const -> double - Returns the minimum distance between this point and a segment.
- auto toQPointF() const -> QPointF
- Converts a point to a QPointF.
- auto toString(int precision = -1) const -> QString
- Returns a string representation of the point (x, y) with a preset precision.
- auto x() const -> double
- Gets the x value of the point.
- auto y() const -> double
- Gets the y value of the point.
Function documentation
QgsPointXY:: QgsPointXY(double x,
double y)
Create a point from x,y coordinates.
| Parameters | |
|---|---|
| x | x coordinate |
| y | y coordinate |
QgsPointXY:: QgsPointXY(QPointF point)
Create a point from a QPointF.
| Parameters | |
|---|---|
| point | QPointF source |
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.
bool QgsPointXY:: compare(const QgsPointXY& other,
double epsilon = 4*std::numeric_limits<double>::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 |
double QgsPointXY:: 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 |
double QgsPointXY:: distance(const QgsPointXY& other) const
Returns the distance between this point and another point.
| Parameters | |
|---|---|
| other | other point |
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.
| Parameters | |
|---|---|
| distance | distance to project |
| bearing | angle to project in, clockwise in degrees starting from north |
double QgsPointXY:: sqrDist(double x,
double y) const
Returns the squared distance between this point a specified x, y coordinate.
double QgsPointXY:: sqrDist(const QgsPointXY& other) const
Returns the squared distance between this point another point.
QPointF QgsPointXY:: toQPointF() const
Converts a point to a QPointF.
| Returns | QPointF with same x and y values |
|---|
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.