30#include "moc_qgspointxy.cpp"
32using namespace Qt::StringLiterals;
62 QTextStream ot( &rep );
63 ot.setRealNumberPrecision( 12 );
64 ot << mX <<
", " << mY;
69 const QString
x = std::isfinite( mX ) ? QString::number( mX,
'f', precision ) : QObject::tr(
"infinite" );
70 const QString
y = std::isfinite( mY ) ? QString::number( mY,
'f', precision ) : QObject::tr(
"infinite" );
71 return u
"%1,%2"_s.arg(
x,
y );
77 QString wkt = u
"POINT"_s;
88 const double dx = other.
x() - mX;
89 const double dy = other.
y() - mY;
90 return ( std::atan2( dx, dy ) * 180.0 / M_PI );
95 const double rads = bearing * M_PI / 180.0;
96 const double dx =
distance * std::sin( rads );
97 const double dy =
distance * std::cos( rads );
109 t = ( mX * ny - mY * nx - x1 * ny + y1 * nx ) / ( ( x2 - x1 ) * ny - ( y2 - y1 ) * nx );
113 minDistPoint.
setX( x1 );
114 minDistPoint.
setY( y1 );
118 minDistPoint.
setX( x2 );
119 minDistPoint.
setY( y2 );
123 minDistPoint.
setX( x1 + t * ( x2 - x1 ) );
124 minDistPoint.
setY( y1 + t * ( y2 - y1 ) );
127 const double dist =
sqrDist( minDistPoint );
131 minDistPoint.
setX( mX );
132 minDistPoint.
setY( mY );
QgsPointXY project(double distance, double bearing) const
Returns a new point which corresponds to this point projected by a specified distance in a specified ...
QString toString(int precision=-1) const
Returns a string representation of the point (x, y) with a preset precision.
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.
void setY(double y)
Sets the y value of the point.
QString asWkt() const
Returns the well known text representation for the point (e.g.
double azimuth(const QgsPointXY &other) const
Calculates azimuth between this point and other one (clockwise in degree, starting from north).
double sqrDistToSegment(double x1, double y1, double x2, double y2, QgsPointXY &minDistPoint, double epsilon=Qgis::DEFAULT_SEGMENT_EPSILON) const
Returns the minimum distance between this point and a segment.
void setX(double x)
Sets the x value of the point.
bool isEmpty() const
Returns true if the geometry is empty.
Point geometry type, with support for z-dimension and m-values.
bool isEmpty() const override
Returns true if the geometry is empty.
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference).