21 #include "qgis_core.h" 47 Q_PROPERTY(
double x READ x WRITE setX )
48 Q_PROPERTY(
double y READ y WRITE setY )
119 void set(
double x,
double y )
150 return QPointF( mX, mY );
157 QString toString(
int precision = -1 )
const;
163 QString asWkt()
const;
171 return ( mX - x ) * ( mX - x ) + ( mY - y ) * ( mY - y );
180 return sqrDist( other.
x(), other.
y() );
192 return std::sqrt( sqrDist( x, y ) );
203 return std::sqrt( sqrDist( other ) );
210 double azimuth(
const QgsPointXY &other )
const;
219 QgsPointXY project(
double distance,
double bearing )
const;
228 bool compare(
const QgsPointXY &other,
double epsilon = 4 * std::numeric_limits<double>::epsilon() )
const 255 if ( &other !=
this )
292 operator QVariant()
const 294 return QVariant::fromValue( *
this );
298 SIP_PYOBJECT __repr__();
300 QString str = QStringLiteral(
"<QgsPointXY: %1>" ).arg( sipCpp->asWkt() );
301 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
310 SIP_PYOBJECT __getitem__(
int );
314 sipRes = Py_BuildValue(
"d", sipCpp->x() );
318 sipRes = Py_BuildValue(
"d", sipCpp->y() );
322 QString msg = QString(
"Bad index: %1" ).arg( a0 );
323 PyErr_SetString( PyExc_IndexError, msg.toAscii().constData() );
327 long __hash__()
const;
329 sipRes =
qHash( *sipCpp );
358 os << p.toString().toLocal8Bit().data();
365 uint h1 =
qHash( static_cast< quint64 >( p.mX ) );
366 uint h2 =
qHash( static_cast< quint64 >( p.mY ) );
367 hash = h1 ^ ( h2 << 1 );
372 #endif //QGSPOINTXY_H
QgsPointXY & operator*=(double scalar)
Multiplies the coordinates in this point by a scalar quantity in place.
uint qHash(const QgsPointXY &p)
A class to represent a 2D point.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
bool operator==(const QgsPointXY &other)
equality operator
QgsVector operator-(const QgsPointXY &p) const
Calculates the vector obtained by subtracting a point from this point.
Q_DECLARE_METATYPE(QModelIndex)
double sqrDist(double x, double y) const
Returns the squared distance between this point a specified x, y coordinate.
double distance(const QgsPointXY &other) const
Returns the distance between this point and another point.
bool operator!=(const QgsPointXY &other) const
Inequality operator.
QPointF toQPointF() const
Converts a point to a QPointF.
const double DEFAULT_SEGMENT_EPSILON
Default snapping tolerance for segments.
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.
double sqrDist(const QgsPointXY &other) const
Returns the squared distance between this point another point.
double distance(double x, double y) const
Returns the distance between this point and a specified x, y coordinate.
Point geometry type, with support for z-dimension and m-values.
void setX(double x)
Sets the x value of the point.
QgsPointXY(QPoint point)
Create a point from a QPoint.
A class to represent a vector.
QgsPointXY & operator+=(QgsVector v)
Adds a vector to this point in place.
std::ostream & operator<<(std::ostream &os, const QgsPointXY &p)
QgsPointXY & operator-=(QgsVector v)
Subtracts a vector from this point in place.
QgsPointXY operator+(QgsVector v) const
Adds a vector to this point.
QgsPointXY(QPointF point)
Create a point from a QPointF.
QgsPointXY operator-(QgsVector v) const
Subtracts a vector from this point.
double y() const
Gets the y value of the point.
QgsPointXY operator*(double scalar) const
Multiplies the coordinates in this point by a scalar quantity.
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.
double x() const
Returns the vector's x-component.
QgsPointXY & operator=(const QgsPointXY &other)
Assignment.
double y() const
Returns the vector's y-component.