21 #include "qgis_core.h"
47 Q_PROPERTY(
double x READ x WRITE setX )
48 Q_PROPERTY(
double y READ y WRITE setY )
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 ) );
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 );
A class to represent a 2D point.
double distance(const QgsPointXY &other) const SIP_HOLDGIL
Returns the distance between this point and another point.
bool isEmpty() const SIP_HOLDGIL
Returns true if the geometry is empty.
QgsPointXY operator*(double scalar) const
Multiplies the coordinates in this point by a scalar quantity.
bool operator==(const QgsPointXY &other) SIP_HOLDGIL
equality operator
void set(double x, double y) SIP_HOLDGIL
Sets the x and y value of the point.
double sqrDist(const QgsPointXY &other) const SIP_HOLDGIL
Returns the squared distance between this point another point.
QgsPointXY & operator=(const QgsPointXY &other) SIP_HOLDGIL
Assignment.
QgsPointXY(QPointF point) SIP_HOLDGIL
Create a point from a QPointF.
QgsPointXY operator-(QgsVector v) const
Subtracts a vector from this point.
double sqrDist(double x, double y) const SIP_HOLDGIL
Returns the squared distance between this point a specified x, y coordinate.
void setX(double x) SIP_HOLDGIL
Sets the x value of the point.
QgsPointXY(QPoint point) SIP_HOLDGIL
Create a point from a QPoint.
bool operator!=(const QgsPointXY &other) const SIP_HOLDGIL
Inequality operator.
QgsPointXY()=default
Default constructor.
QgsPointXY operator/(double scalar) const
Divides the coordinates in this point by a scalar quantity.
void multiply(double scalar) SIP_HOLDGIL
Multiply x and y by the given value.
QgsPointXY(double x, double y) SIP_HOLDGIL
Create a point from x,y coordinates.
QgsPointXY & operator/=(double scalar)
Divides the coordinates in this point by a scalar quantity in place.
QgsPointXY & operator*=(double scalar)
Multiplies the coordinates in this point by a scalar quantity in place.
bool compare(const QgsPointXY &other, double epsilon=4 *std::numeric_limits< double >::epsilon()) const SIP_HOLDGIL
Compares this point with another point with a fuzzy tolerance.
double x() const SIP_HOLDGIL
Gets the x value of the point.
QgsVector operator-(const QgsPointXY &p) const
Calculates the vector obtained by subtracting a point from this point.
double distance(double x, double y) const SIP_HOLDGIL
Returns the distance between this point and a specified x, y coordinate.
QgsPointXY & operator+=(QgsVector v)
Adds a vector to this point in place.
double y() const SIP_HOLDGIL
Gets the y value of the point.
QgsPointXY & operator-=(QgsVector v)
Subtracts a vector from this point in place.
void setY(double y) SIP_HOLDGIL
Sets the y value of the point.
QPointF toQPointF() const
Converts a point to a QPointF.
QgsPointXY operator+(QgsVector v) const
Adds a vector to this point.
Point geometry type, with support for z-dimension and m-values.
A class to represent a vector.
double y() const SIP_HOLDGIL
Returns the vector's y-component.
double x() const SIP_HOLDGIL
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)
const double DEFAULT_SEGMENT_EPSILON
Default snapping tolerance for segments.
Q_DECLARE_METATYPE(QgsMeshTimeSettings)
uint qHash(const QgsPointXY &p)
std::ostream & operator<<(std::ostream &os, const QgsPointXY &p)