QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
Go to the documentation of this file.
23 #include <QTextStream>
31 , mIsEmpty( p.isEmpty() )
56 QTextStream ot( &rep );
57 ot.setRealNumberPrecision( 12 );
58 ot << mX <<
", " << mY;
63 QString
x = std::isfinite( mX ) ? QString::number( mX,
'f',
precision ) : QObject::tr(
"infinite" );
64 QString
y = std::isfinite( mY ) ? QString::number( mY,
'f',
precision ) : QObject::tr(
"infinite" );
65 return QStringLiteral(
"%1,%2" ).arg(
x,
y );
71 QString wkt = QStringLiteral(
"POINT" );
73 wkt += QLatin1String(
" EMPTY" );
82 double dx = other.
x() - mX;
83 double dy = other.
y() - mY;
84 return ( std::atan2( dx, dy ) * 180.0 / M_PI );
89 double rads = bearing * M_PI / 180.0;
90 double dx =
distance * std::sin( rads );
91 double dy =
distance * std::cos( rads );
103 t = ( mX * ny - mY * nx - x1 * ny + y1 * nx ) / ( ( x2 - x1 ) * ny - ( y2 - y1 ) * nx );
107 minDistPoint.
setX( x1 );
108 minDistPoint.
setY( y1 );
112 minDistPoint.
setX( x2 );
113 minDistPoint.
setY( y2 );
117 minDistPoint.
setX( x1 + t * ( x2 - x1 ) );
118 minDistPoint.
setY( y1 + t * ( y2 - y1 ) );
121 double dist =
sqrDist( minDistPoint );
125 minDistPoint.
setX( mX );
126 minDistPoint.
setY( mY );
double distance(double x, double y) const SIP_HOLDGIL
Returns the distance between this point and a specified x, y coordinate.
Point geometry type, with support for z-dimension and m-values.
void setY(double y) SIP_HOLDGIL
Sets the y value of the point.
QString asWkt() const
Returns the well known text representation for the point (e.g.
bool isEmpty() const SIP_HOLDGIL
Returns true if the geometry is empty.
QgsPointXY project(double distance, double bearing) const SIP_HOLDGIL
Returns a new point which corresponds to this point projected by a specified distance in a specified ...
void setX(double x) SIP_HOLDGIL
Sets the x value of the point.
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
double sqrDist(double x, double y) const SIP_HOLDGIL
Returns the squared distance between this point a specified x, y coordinate.
QString toString(int precision=-1) const
Returns a string representation of the point (x, y) with a preset precision.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
QgsPointXY()=default
Default constructor.
A class to represent a 2D point.
double azimuth(const QgsPointXY &other) const SIP_HOLDGIL
Calculates azimuth between this point and other one (clockwise in degree, starting from north)
bool isEmpty() const override SIP_HOLDGIL
Returns true if the geometry is empty.
double sqrDistToSegment(double x1, double y1, double x2, double y2, QgsPointXY &minDistPoint, double epsilon=DEFAULT_SEGMENT_EPSILON) const SIP_HOLDGIL
Returns the minimum distance between this point and a segment.