QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
Go to the documentation of this file.
21 #include "qgis_core.h"
47 Q_PROPERTY(
double x READ x WRITE setX )
48 Q_PROPERTY(
double y READ y WRITE setY )
124 void set(
double x,
double y )
156 return QPointF( mX, mY );
163 QString toString(
int precision = -1 )
const;
169 QString asWkt()
const;
177 return ( mX - x ) * ( mX - x ) + ( mY - y ) * ( mY - y );
186 return sqrDist( other.
x(), other.
y() );
198 return std::sqrt( sqrDist( x, y ) );
209 return std::sqrt( sqrDist( other ) );
216 double azimuth(
const QgsPointXY &other )
const;
225 QgsPointXY project(
double distance,
double bearing )
const;
243 bool compare(
const QgsPointXY &other,
double epsilon = 4 * std::numeric_limits<double>::epsilon() )
const
251 if ( isEmpty() && other.
isEmpty() )
253 if ( isEmpty() && !other.
isEmpty() )
255 if ( ! isEmpty() && other.
isEmpty() )
268 if ( isEmpty() && other.
isEmpty() )
270 if ( isEmpty() && !other.
isEmpty() )
272 if ( ! isEmpty() && other.
isEmpty() )
292 if ( &other !=
this )
330 operator QVariant()
const
332 return QVariant::fromValue( *
this );
336 SIP_PYOBJECT __repr__();
338 QString str = QStringLiteral(
"<QgsPointXY: %1>" ).arg( sipCpp->asWkt() );
339 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
348 SIP_PYOBJECT __getitem__(
int );
352 sipRes = Py_BuildValue(
"d", sipCpp->x() );
356 sipRes = Py_BuildValue(
"d", sipCpp->y() );
360 QString msg = QString(
"Bad index: %1" ).arg( a0 );
361 PyErr_SetString( PyExc_IndexError, msg.toLatin1().constData() );
365 long __hash__()
const;
367 sipRes =
qHash( *sipCpp );
380 bool mIsEmpty =
true;
390 const bool nan1X = std::isnan( p1.x() );
391 const bool nan2X = std::isnan( p2.x() );
392 if ( nan1X != nan2X )
397 const bool nan1Y = std::isnan( p1.y() );
398 const bool nan2Y = std::isnan( p2.y() );
399 if ( nan1Y != nan2Y )
411 os << p.toString().toLocal8Bit().data();
418 uint h1 =
qHash(
static_cast< quint64
>( p.mX ) );
419 uint h2 =
qHash(
static_cast< quint64
>( p.mY ) );
420 hash = h1 ^ ( h2 << 1 );
425 #endif //QGSPOINTXY_H
QgsPointXY & operator=(const QgsPointXY &other)
Assignment.
QgsPointXY operator+(QgsVector v) const
Adds a vector to this point.
Point geometry type, with support for z-dimension and m-values.
double sqrDist(double x, double y) const
Returns the squared distance between this point a specified x, y coordinate.
QgsPointXY & operator+=(QgsVector v)
Adds a vector to this point in place.
QgsPointXY & operator/=(double scalar)
Divides the coordinates in this point by a scalar quantity in place.
QgsVector operator-(const QgsPointXY &p) const
Calculates the vector obtained by subtracting a point from this point.
QPointF toQPointF() const
Converts a point to a QPointF.
const double DEFAULT_SEGMENT_EPSILON
Default snapping tolerance for segments.
bool operator==(const QgsPointXY &other)
equality operator
bool operator!=(const QgsPointXY &other) const
Inequality operator.
Q_DECLARE_METATYPE(QgsMeshTimeSettings)
double x() const
Returns the vector's x-component.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
QgsPointXY & operator-=(QgsVector v)
Subtracts a vector from this point in place.
double distance(double x, double y) const
Returns the distance between this point and a specified x, y coordinate.
double distance(const QgsPointXY &other) const
Returns the distance between this point and another point.
bool compare(const QgsPointXY &other, double epsilon=4 *std::numeric_limits< double >::epsilon()) const
Compares this point with another point with a fuzzy tolerance.
void setY(double y)
Sets the y value of the point.
double x() const
Gets the x value of the point.
void multiply(double scalar)
Multiply x and y by the given value.
QgsPointXY operator/(double scalar) const
Divides 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*(double scalar) const
Multiplies the coordinates in this point by a scalar quantity.
double y() const
Returns the vector's y-component.
bool isEmpty() const
Returns true if the geometry is empty.
double sqrDist(const QgsPointXY &other) const
Returns the squared distance between this point another point.
std::ostream & operator<<(std::ostream &os, const QgsPointXY &p)
void setX(double x)
Sets the x value of the point.
QgsPointXY(QPoint point)
Create a point from a QPoint.
QgsPointXY(QPointF point)
Create a point from a QPointF.
uint qHash(const QgsPointXY &p)
double y() const
Gets the y value of the point.
QgsPointXY operator-(QgsVector v) const
Subtracts a vector from this point.
void set(double x, double y)
Sets the x and y value of the point.