62 Q_PROPERTY(
double x READ x WRITE setX )
63 Q_PROPERTY(
double y READ y WRITE setY )
171 return QPointF( mX, mY );
178 QString toString(
int precision = -1 )
const;
184 QString asWkt()
const;
192 return ( mX - x ) * ( mX - x ) + ( mY - y ) * ( mY - y );
201 return sqrDist( other.x(), other.y() );
213 return std::sqrt( sqrDist( x, y ) );
224 return std::sqrt( sqrDist( other ) );
266 if ( isEmpty() && other.
isEmpty() )
268 if ( isEmpty() && !other.
isEmpty() )
270 if ( ! isEmpty() && other.
isEmpty() )
283 if ( isEmpty() && other.
isEmpty() )
285 if ( isEmpty() && !other.
isEmpty() )
287 if ( ! isEmpty() && other.
isEmpty() )
307 if ( &other !=
this )
345 operator QVariant()
const
347 return QVariant::fromValue( *
this );
351 SIP_PYOBJECT __repr__();
353 QString
str = QStringLiteral(
"<QgsPointXY: %1>" ).arg( sipCpp->asWkt() );
354 sipRes = PyUnicode_FromString(
str.toUtf8().constData() );
363 SIP_PYOBJECT __getitem__(
int );
367 sipRes = Py_BuildValue(
"d", sipCpp->x() );
371 sipRes = Py_BuildValue(
"d", sipCpp->y() );
375 QString msg = QString(
"Bad index: %1" ).arg( a0 );
376 PyErr_SetString( PyExc_IndexError, msg.toLatin1().constData() );
380 long __hash__()
const;
382 sipRes =
qHash( *sipCpp );
395 bool mIsEmpty =
true;
405 const bool nan1X = std::isnan( p1.x() );
406 const bool nan2X = std::isnan( p2.x() );
407 if ( nan1X != nan2X )
412 const bool nan1Y = std::isnan( p1.y() );
413 const bool nan2Y = std::isnan( p2.y() );
414 if ( nan1Y != nan2Y )
426 os << p.toString().toLocal8Bit().data();
433 const uint h1 =
qHash(
static_cast< quint64
>( p.mX ) );
434 const uint h2 =
qHash(
static_cast< quint64
>( p.mY ) );
435 hash = h1 ^ ( h2 << 1 );
A class to represent a 2D point.
double x() const
Gets the x value of the point.
QgsPointXY(QPoint point)
Create a point from a QPoint.
QgsPointXY operator*(double scalar) const
Multiplies the coordinates in this point by a scalar quantity.
QgsPointXY & operator-=(QgsVector v)
Subtracts a vector from this point in place.
QgsPointXY(QPointF point)
Create a point from a QPointF.
double sqrDist(double x, double y) const
Returns the squared distance between this point a specified x, y coordinate.
double distance(double x, double y) const
Returns the distance between this point and a specified x, y coordinate.
QgsPointXY operator-(QgsVector v) const
Subtracts a vector from this point.
void setY(double y)
Sets the y value of the point.
double distance(const QgsPointXY &other) const
Returns the distance between this point and another point.
void multiply(double scalar)
Multiply x and y by the given value.
QgsPointXY & operator*=(double scalar)
Multiplies the coordinates in this point by a scalar quantity 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.
bool compare(const QgsPointXY &other, double epsilon=4 *std::numeric_limits< double >::epsilon()) const
Compares this point with another point with a fuzzy tolerance.
bool operator!=(const QgsPointXY &other) const
Inequality operator.
void set(double x, double y)
Sets the x and y value of the point.
QgsPointXY & operator+=(QgsVector v)
Adds a vector to this point in place.
QgsPointXY & operator=(const QgsPointXY &other)
Assignment.
QgsVector operator-(const QgsPointXY &p) const
Calculates the vector obtained by subtracting a point from this point.
double y() const
Gets the y value of the point.
double sqrDist(const QgsPointXY &other) const
Returns the squared distance between this point another point.
void setX(double x)
Sets the x value of the point.
bool isEmpty() const
Returns true if the geometry is empty.
QPointF toQPointF() const
Converts a point to a QPointF.
QgsPointXY operator+(QgsVector v) const
Adds a vector to this point.
bool operator==(const QgsPointXY &other)
equality operator
Point geometry type, with support for z-dimension and m-values.
A class to represent a vector.
double y() const
Returns the vector's y-component.
double x() const
Returns the vector's x-component.
uint qHash(const QVariant &variant)
Hash for QVariant.
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(QgsDatabaseQueryLogEntry)
uint qHash(const QgsPointXY &p)
std::ostream & operator<<(std::ostream &os, const QgsPointXY &p)