QGIS API Documentation 3.99.0-Master (d270888f95f)
Loading...
Searching...
No Matches
qgspoint.h
Go to the documentation of this file.
1/***************************************************************************
2 qgspointv2.h
3 --------------
4 begin : September 2014
5 copyright : (C) 2014 by Marco Hugentobler
6 email : marco at sourcepole dot ch
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSPOINT_H
19#define QGSPOINT_H
20
21#include "qgis_core.h"
22#include "qgis_sip.h"
23#include "qgsabstractgeometry.h"
25#include "qgsrectangle.h"
26
27#include <QString>
28
29using namespace Qt::StringLiterals;
30
31/***************************************************************************
32 * This class is considered CRITICAL and any change MUST be accompanied with
33 * full unit tests in testqgsgeometry.cpp.
34 * See details in QEP #17
35 ****************************************************************************/
36
52class CORE_EXPORT QgsPoint: public QgsAbstractGeometry
53{
54 Q_GADGET
55
56 Q_PROPERTY( double x READ x WRITE setX )
57 Q_PROPERTY( double y READ y WRITE setY )
58 Q_PROPERTY( double z READ z WRITE setZ )
59 Q_PROPERTY( double m READ m WRITE setM )
60
61 public:
62
89#ifndef SIP_RUN
90 QgsPoint( double x = std::numeric_limits<double>::quiet_NaN(), double y = std::numeric_limits<double>::quiet_NaN(), double z = std::numeric_limits<double>::quiet_NaN(), double m = std::numeric_limits<double>::quiet_NaN(), Qgis::WkbType wkbType = Qgis::WkbType::Unknown );
91#else
92 QgsPoint( SIP_PYOBJECT x SIP_TYPEHINT( Optional[Union[QgsPoint, QPointF, float]] ) = Py_None, SIP_PYOBJECT y SIP_TYPEHINT( Optional[float] ) = Py_None, SIP_PYOBJECT z SIP_TYPEHINT( Optional[float] ) = Py_None, SIP_PYOBJECT m SIP_TYPEHINT( Optional[float] ) = Py_None, SIP_PYOBJECT wkbType SIP_TYPEHINT( Optional[int] ) = Py_None ) [( double x = 0.0, double y = 0.0, double z = 0.0, double m = 0.0, Qgis::WkbType wkbType = Qgis::WkbType::Unknown )];
93 % MethodCode
94 if ( sipCanConvertToType( a0, sipType_QgsPointXY, SIP_NOT_NONE ) && a1 == Py_None && a2 == Py_None && a3 == Py_None && a4 == Py_None )
95 {
96 int state;
97 sipIsErr = 0;
98
99 QgsPointXY *p = reinterpret_cast<QgsPointXY *>( sipConvertToType( a0, sipType_QgsPointXY, 0, SIP_NOT_NONE, &state, &sipIsErr ) );
100 if ( !sipIsErr )
101 {
102 sipCpp = new sipQgsPoint( QgsPoint( *p ) );
103 }
104 sipReleaseType( p, sipType_QgsPointXY, state );
105 }
106 else if ( sipCanConvertToType( a0, sipType_QPointF, SIP_NOT_NONE ) && a1 == Py_None && a2 == Py_None && a3 == Py_None && a4 == Py_None )
107 {
108 int state;
109 sipIsErr = 0;
110
111 QPointF *p = reinterpret_cast<QPointF *>( sipConvertToType( a0, sipType_QPointF, 0, SIP_NOT_NONE, &state, &sipIsErr ) );
112 if ( !sipIsErr )
113 {
114 sipCpp = new sipQgsPoint( QgsPoint( *p ) );
115 }
116 sipReleaseType( p, sipType_QPointF, state );
117 }
118 else if (
119 ( a0 == Py_None || PyFloat_AsDouble( a0 ) != -1.0 || !PyErr_Occurred() ) &&
120 ( a1 == Py_None || PyFloat_AsDouble( a1 ) != -1.0 || !PyErr_Occurred() ) &&
121 ( a2 == Py_None || PyFloat_AsDouble( a2 ) != -1.0 || !PyErr_Occurred() ) &&
122 ( a3 == Py_None || PyFloat_AsDouble( a3 ) != -1.0 || !PyErr_Occurred() ) )
123 {
124 double x = a0 == Py_None ? std::numeric_limits<double>::quiet_NaN() : PyFloat_AsDouble( a0 );
125 double y = a1 == Py_None ? std::numeric_limits<double>::quiet_NaN() : PyFloat_AsDouble( a1 );
126 double z = a2 == Py_None ? std::numeric_limits<double>::quiet_NaN() : PyFloat_AsDouble( a2 );
127 double m = a3 == Py_None ? std::numeric_limits<double>::quiet_NaN() : PyFloat_AsDouble( a3 );
128 Qgis::WkbType wkbType = a4 == Py_None ? Qgis::WkbType::Unknown : static_cast<Qgis::WkbType>( sipConvertToEnum( a4, sipType_Qgis_WkbType ) );
129 sipCpp = new sipQgsPoint( QgsPoint( x, y, z, m, wkbType ) );
130 }
131 else // Invalid ctor arguments
132 {
133 PyErr_SetString( PyExc_TypeError, u"Invalid type in constructor arguments."_s.toUtf8().constData() );
134 sipIsErr = 1;
135 }
136 % End
137#endif
138
142 explicit QgsPoint( const QgsPointXY &p ) SIP_SKIP;
143
147 explicit QgsPoint( QPointF p ) SIP_SKIP;
148
154 explicit QgsPoint( Qgis::WkbType wkbType, double x = std::numeric_limits<double>::quiet_NaN(), double y = std::numeric_limits<double>::quiet_NaN(), double z = std::numeric_limits<double>::quiet_NaN(), double m = std::numeric_limits<double>::quiet_NaN() ) SIP_SKIP;
155
156#ifndef SIP_RUN
157 private:
158 bool fuzzyHelper( double epsilon,
159 const QgsAbstractGeometry &other,
160 bool is3DFlag,
161 bool isMeasureFlag,
162 std::function<bool( double, double, double, double, double, double, double, double, double )> comparator3DMeasure,
163 std::function<bool( double, double, double, double, double, double, double )> comparator3D,
164 std::function<bool( double, double, double, double, double, double, double )> comparatorMeasure,
165 std::function<bool( double, double, double, double, double )> comparator2D ) const
166 {
167 const QgsPoint *pt = qgsgeometry_cast< const QgsPoint * >( &other );
168 if ( !pt )
169 return false;
170
171 const Qgis::WkbType type = wkbType();
172
173 if ( pt->wkbType() != type )
174 return false;
175
176 if ( is3DFlag && isMeasureFlag )
177 {
178 return comparator3DMeasure( epsilon, mX, mY, mZ, mM, pt->x(), pt->y(), pt->z(), pt->m() );
179 }
180 else if ( is3DFlag )
181 {
182 return comparator3D( epsilon, mX, mY, mZ, pt->x(), pt->y(), pt->z() );
183 }
184 else if ( isMeasureFlag )
185 {
186 return comparatorMeasure( epsilon, mX, mY, mM, pt->x(), pt->y(), pt->m() );
187 }
188 return comparator2D( epsilon, mX, mY, pt->x(), pt->y() );
189 }
190#endif // !SIP_RUN
191
192 public:
193 bool fuzzyEqual( const QgsAbstractGeometry &other, double epsilon = 1e-8 ) const override SIP_HOLDGIL
194 {
195 return fuzzyHelper(
196 epsilon,
197 other,
198 is3D(),
199 isMeasure(),
200 []( double epsilon, double x1, double y1, double z1, double m1,
201 double x2, double y2, double z2, double m2 )
202 {
203 return QgsGeometryUtilsBase::fuzzyEqual( epsilon, x1, y1, z1, m1, x2, y2, z2, m2 );
204 },
205 []( double epsilon, double x1, double y1, double z1,
206 double x2, double y2, double z2 )
207 {
208 return QgsGeometryUtilsBase::fuzzyEqual( epsilon, x1, y1, z1, x2, y2, z2 );
209 },
210 []( double epsilon, double x1, double y1, double m1,
211 double x2, double y2, double m2 )
212 {
213 return QgsGeometryUtilsBase::fuzzyEqual( epsilon, x1, y1, m1, x2, y2, m2 );
214 },
215 []( double epsilon, double x1, double y1,
216 double x2, double y2 )
217 {
218 return QgsGeometryUtilsBase::fuzzyEqual( epsilon, x1, y1, x2, y2 );
219 } );
220 }
221
222 bool fuzzyDistanceEqual( const QgsAbstractGeometry &other, double epsilon = 1e-8 ) const override SIP_HOLDGIL
223 {
224 return fuzzyHelper(
225 epsilon,
226 other,
227 is3D(),
228 isMeasure(),
229 []( double epsilon, double x1, double y1, double z1, double m1,
230 double x2, double y2, double z2, double m2 )
231 {
232 return QgsGeometryUtilsBase::fuzzyDistanceEqual( epsilon, x1, y1, z1, m1, x2, y2, z2, m2 );
233 },
234 []( double epsilon, double x1, double y1, double z1,
235 double x2, double y2, double z2 )
236 {
237 return QgsGeometryUtilsBase::fuzzyDistanceEqual( epsilon, x1, y1, z1, x2, y2, z2 );
238 },
239 []( double epsilon, double x1, double y1, double m1,
240 double x2, double y2, double m2 )
241 {
242 return QgsGeometryUtilsBase::fuzzyDistanceEqual( epsilon, x1, y1, m1, x2, y2, m2 );
243 },
244 []( double epsilon, double x1, double y1,
245 double x2, double y2 )
246 {
247 return QgsGeometryUtilsBase::fuzzyDistanceEqual( epsilon, x1, y1, x2, y2 );
248 } );
249 }
250
251 bool operator==( const QgsAbstractGeometry &other ) const override SIP_HOLDGIL
252 {
253 return fuzzyEqual( other, 1e-8 );
254 }
255
256 bool operator!=( const QgsAbstractGeometry &other ) const override SIP_HOLDGIL
257 {
258 return !fuzzyEqual( other, 1e-8 );
259 }
260
266 double x() const SIP_HOLDGIL { return mX; }
267
273 double y() const SIP_HOLDGIL { return mY; }
274
280 double z() const SIP_HOLDGIL { return mZ; }
281
287 double m() const SIP_HOLDGIL { return mM; }
288
296 double &rx() SIP_SKIP { clearCache(); return mX; }
297
305 double &ry() SIP_SKIP { clearCache(); return mY; }
306
314 double &rz() SIP_SKIP { clearCache(); return mZ; }
315
323 double &rm() SIP_SKIP { clearCache(); return mM; }
324
330 void setX( double x ) SIP_HOLDGIL
331 {
332 clearCache();
333 mX = x;
334 }
335
341 void setY( double y ) SIP_HOLDGIL
342 {
343 clearCache();
344 mY = y;
345 }
346
354 void setZ( double z ) SIP_HOLDGIL
355 {
356 if ( !is3D() )
357 return;
358 clearCache();
359 mZ = z;
360 }
361
369 void setM( double m ) SIP_HOLDGIL
370 {
371 if ( !isMeasure() )
372 return;
373 clearCache();
374 mM = m;
375 }
376
380 QPointF toQPointF() const SIP_HOLDGIL
381 {
382 return QPointF( mX, mY );
383 }
384
391 double distance( double x, double y ) const SIP_HOLDGIL
392 {
393 return QgsGeometryUtilsBase::distance2D( mX, mY, x, y );
394 }
395
402 double distance( const QgsPoint &other ) const SIP_HOLDGIL
403 {
404 return QgsGeometryUtilsBase::distance2D( mX, mY, other.x(), other.y() );
405 }
406
413 double distanceSquared( double x, double y ) const SIP_HOLDGIL
414 {
415 return QgsGeometryUtilsBase::sqrDistance2D( mX, mY, x, y );
416 }
417
424 double distanceSquared( const QgsPoint &other ) const SIP_HOLDGIL
425 {
426 return QgsGeometryUtilsBase::sqrDistance2D( mX, mY, other.x(), other.y() );
427 }
428
435 double distance3D( double x, double y, double z ) const SIP_HOLDGIL
436 {
437 if ( is3D() || !std::isnan( z ) )
438 {
439 return QgsGeometryUtilsBase::distance3D( mX, mY, mZ, x, y, z );
440 }
441 return QgsGeometryUtilsBase::distance2D( mX, mY, x, y );
442 }
443
450 double distance3D( const QgsPoint &other ) const SIP_HOLDGIL
451 {
452 if ( is3D() || other.is3D() )
453 {
454 return QgsGeometryUtilsBase::distance3D( mX, mY, mZ, other.x(), other.y(), other.z() );
455 }
456 return QgsGeometryUtilsBase::distance2D( mX, mY, other.x(), other.y() );
457 }
458
465 double distanceSquared3D( double x, double y, double z ) const SIP_HOLDGIL
466 {
467 if ( is3D() || !std::isnan( z ) )
468 {
469 return QgsGeometryUtilsBase::sqrDistance3D( mX, mY, mZ, x, y, z );
470 }
471 return QgsGeometryUtilsBase::sqrDistance2D( mX, mY, x, y );
472 }
473
480 double distanceSquared3D( const QgsPoint &other ) const SIP_HOLDGIL
481 {
482 if ( is3D() || other.is3D() )
483 {
484 return QgsGeometryUtilsBase::sqrDistance3D( mX, mY, mZ, other.x(), other.y(), other.z() );
485 }
486 return QgsGeometryUtilsBase::sqrDistance2D( mX, mY, other.x(), other.y() );
487 }
488
492 double azimuth( const QgsPoint &other ) const SIP_HOLDGIL;
493
498 double inclination( const QgsPoint &other ) const SIP_HOLDGIL;
499
529 QgsPoint project( double distance, double azimuth, double inclination = 90.0 ) const SIP_HOLDGIL;
530
534 QgsVector operator-( const QgsPoint &p ) const SIP_HOLDGIL { return QgsVector( mX - p.mX, mY - p.mY ); }
535
539 QgsPoint &operator+=( QgsVector v ) SIP_HOLDGIL { mX += v.x(); mY += v.y(); return *this; }
540
544 QgsPoint &operator-=( QgsVector v ) SIP_HOLDGIL { mX -= v.x(); mY -= v.y(); return *this; }
545
549 QgsPoint operator+( QgsVector v ) const SIP_HOLDGIL { QgsPoint r = *this; r.rx() += v.x(); r.ry() += v.y(); return r; }
550
554 QgsPoint operator-( QgsVector v ) const SIP_HOLDGIL { QgsPoint r = *this; r.rx() -= v.x(); r.ry() -= v.y(); return r; }
555
556 //implementation of inherited methods
557 void normalize() final SIP_HOLDGIL;
558 bool isEmpty() const override SIP_HOLDGIL;
559 QgsBox3D boundingBox3D() const override SIP_HOLDGIL;
560 QString geometryType() const override SIP_HOLDGIL;
561 int dimension() const override SIP_HOLDGIL;
562 QgsPoint *clone() const override SIP_FACTORY;
563 QgsPoint *snappedToGrid( double hSpacing, double vSpacing, double dSpacing = 0, double mSpacing = 0, bool removeRedundantPoints = false ) const override SIP_FACTORY;
564 QgsPoint *simplifyByDistance( double tolerance ) const override SIP_FACTORY;
565 bool removeDuplicateNodes( double epsilon = 4 * std::numeric_limits<double>::epsilon(), bool useZValues = false ) override;
566 void clear() override;
567 bool fromWkb( QgsConstWkbPtr &wkb ) override;
568 bool fromWkt( const QString &wkt ) override;
569 int wkbSize( QgsAbstractGeometry::WkbFlags flags = QgsAbstractGeometry::WkbFlags() ) const override;
570 QByteArray asWkb( QgsAbstractGeometry::WkbFlags = QgsAbstractGeometry::WkbFlags() ) const override;
571 QString asWkt( int precision = 17 ) const override;
572 QDomElement asGml2( QDomDocument &doc, int precision = 17, const QString &ns = "gml", QgsAbstractGeometry::AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY ) const override;
573 QDomElement asGml3( QDomDocument &doc, int precision = 17, const QString &ns = "gml", QgsAbstractGeometry::AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY ) const override;
574 json asJsonObject( int precision = 17 ) const override SIP_SKIP;
575 QString asKml( int precision = 17 ) const override;
576 void draw( QPainter &p ) const override;
577 QPainterPath asQPainterPath() const override;
578 void transform( const QgsCoordinateTransform &ct, Qgis::TransformDirection d = Qgis::TransformDirection::Forward, bool transformZ = false ) override SIP_THROW( QgsCsException );
579 void transform( const QTransform &t, double zTranslate = 0.0, double zScale = 1.0, double mTranslate = 0.0, double mScale = 1.0 ) override;
580 QgsCoordinateSequence coordinateSequence() const override;
581 int nCoordinates() const override SIP_HOLDGIL;
582 int vertexNumberFromVertexId( QgsVertexId id ) const override;
583 QgsAbstractGeometry *boundary() const override SIP_FACTORY;
584 bool isValid( QString &error SIP_OUT, Qgis::GeometryValidityFlags flags = Qgis::GeometryValidityFlags() ) const override SIP_HOLDGIL;
585
586 //low-level editing
587 bool insertVertex( QgsVertexId position, const QgsPoint &vertex ) override;
588 bool moveVertex( QgsVertexId position, const QgsPoint &newPos ) override;
589 bool deleteVertex( QgsVertexId position ) override;
590
591 double closestSegment( const QgsPoint &pt, QgsPoint &segmentPt SIP_OUT, QgsVertexId &vertexAfter SIP_OUT, int *leftOf SIP_OUT = nullptr, double epsilon = 4 * std::numeric_limits<double>::epsilon() ) const override;
592 bool nextVertex( QgsVertexId &id, QgsPoint &vertex SIP_OUT ) const override;
593 void adjacentVertices( QgsVertexId vertex, QgsVertexId &previousVertex SIP_OUT, QgsVertexId &nextVertex SIP_OUT ) const override;
594
600 double vertexAngle( QgsVertexId vertex ) const override;
601
602 int vertexCount( int /*part*/ = 0, int /*ring*/ = 0 ) const override;
603 int ringCount( int /*part*/ = 0 ) const override;
604 int partCount() const override;
605 QgsPoint vertexAt( QgsVertexId /*id*/ ) const override;
606 QgsPoint *toCurveType() const override SIP_FACTORY;
607 double segmentLength( QgsVertexId startVertex ) const override;
608 bool boundingBoxIntersects( const QgsRectangle &rectangle ) const override SIP_HOLDGIL;
609 bool boundingBoxIntersects( const QgsBox3D &box3d ) const override SIP_HOLDGIL;
610
611 bool addZValue( double zValue = 0 ) override;
612 bool addMValue( double mValue = 0 ) override;
613 bool dropZValue() override;
614 bool dropMValue() override;
615 void swapXy() override;
616 bool convertTo( Qgis::WkbType type ) override;
617
618 bool transform( QgsAbstractGeometryTransformer *transformer, QgsFeedback *feedback = nullptr ) override;
619
620#ifndef SIP_RUN
621
622 void filterVertices( const std::function< bool( const QgsPoint & ) > &filter ) override;
623 void transformVertices( const std::function< QgsPoint( const QgsPoint & ) > &transform ) override;
624
633 inline static const QgsPoint *cast( const QgsAbstractGeometry *geom )
634 {
635 if ( geom && QgsWkbTypes::flatType( geom->wkbType() ) == Qgis::WkbType::Point )
636 return static_cast<const QgsPoint *>( geom );
637 return nullptr;
638 }
639
648 inline static QgsPoint *cast( QgsAbstractGeometry *geom )
649 {
650 if ( geom && QgsWkbTypes::flatType( geom->wkbType() ) == Qgis::WkbType::Point )
651 return static_cast<QgsPoint *>( geom );
652 return nullptr;
653 }
654#endif
655
657
658#ifdef SIP_RUN
659 SIP_PYOBJECT __repr__();
660 % MethodCode
661 QString str = u"<QgsPoint: %1>"_s.arg( sipCpp->asWkt() );
662 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
663 % End
664#endif
665
666 protected:
667
668 int compareToSameClass( const QgsAbstractGeometry *other ) const final;
669 int childCount() const override;
670 QgsPoint childPoint( int index ) const override;
671
672 private:
673 double mX;
674 double mY;
675 double mZ;
676 double mM;
677};
678
679// clazy:excludeall=qstring-allocations
680
681#endif // QGSPOINT_H
Provides global constants and enumerations for use throughout the application.
Definition qgis.h:59
WkbType
The WKB type describes the number of dimensions a geometry has.
Definition qgis.h:280
@ Point
Point.
Definition qgis.h:282
@ Unknown
Unknown.
Definition qgis.h:281
An abstract base class for classes which transform geometries by transforming input points to output ...
Abstract base class for all geometries.
virtual QgsPoint childPoint(int index) const
Returns point at index (for geometries without child geometries - i.e.
bool isMeasure() const
Returns true if the geometry contains m values.
virtual int childCount() const
Returns number of child geometries (for geometries with child geometries) or child points (for geomet...
virtual void transformVertices(const std::function< QgsPoint(const QgsPoint &) > &transform)
Transforms the vertices from the geometry in place, applying the transform function to every vertex.
bool is3D() const
Returns true if the geometry is 3D and contains a z-value.
virtual QgsAbstractGeometry * createEmptyWithSameType() const =0
Creates a new geometry with the same class and same WKB type as the original and transfers ownership.
virtual void clearCache() const
Clears any cached parameters associated with the geometry, e.g., bounding boxes.
Qgis::WkbType wkbType() const
Returns the WKB type of the geometry.
virtual bool fuzzyEqual(const QgsAbstractGeometry &other, double epsilon=1e-8) const =0
Performs fuzzy comparison between this geometry and other using an epsilon.
virtual void normalize()=0
Reorganizes the geometry into a normalized form (or "canonical" form).
virtual void filterVertices(const std::function< bool(const QgsPoint &) > &filter)
Filters the vertices from the geometry in place, removing any which do not return true for the filter...
QgsAbstractGeometry()=default
virtual int compareToSameClass(const QgsAbstractGeometry *other) const =0
Compares to an other geometry of the same class, and returns a integer for sorting of the two geometr...
A 3-dimensional box composed of x, y, z coordinates.
Definition qgsbox3d.h:45
A const WKB pointer.
Definition qgswkbptr.h:139
Handles coordinate transforms between two coordinate systems.
Custom exception class for Coordinate Reference System related exceptions.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition qgsfeedback.h:44
static double sqrDistance2D(double x1, double y1, double x2, double y2)
Returns the squared 2D distance between (x1, y1) and (x2, y2).
static double distance2D(double x1, double y1, double x2, double y2)
Returns the 2D distance between (x1, y1) and (x2, y2).
static bool fuzzyEqual(T epsilon, const Args &... args) noexcept
Performs fuzzy comparison between pairs of values within a specified epsilon.
static double distance3D(double x1, double y1, double z1, double x2, double y2, double z2)
Returns the 3D distance between (x1, y1, z1) and (x2, y2, z2).
static double sqrDistance3D(double x1, double y1, double z1, double x2, double y2, double z2)
Returns the squared 3D distance between (x1, y1, z1) and (x2, y2, z2).
static bool fuzzyDistanceEqual(T epsilon, const Args &... args) noexcept
Compare equality between multiple pairs of values with a specified epsilon.
Represents a 2D point.
Definition qgspointxy.h:62
Point geometry type, with support for z-dimension and m-values.
Definition qgspoint.h:53
double z() const
Returns the point's z-coordinate.
Definition qgspoint.h:280
bool fuzzyDistanceEqual(const QgsAbstractGeometry &other, double epsilon=1e-8) const override
Performs fuzzy distance comparison between this geometry and other using an epsilon.
Definition qgspoint.h:222
void setY(double y)
Sets the point's y-coordinate.
Definition qgspoint.h:341
bool operator==(const QgsAbstractGeometry &other) const override
Definition qgspoint.h:251
double distance3D(const QgsPoint &other) const
Returns the Cartesian 3D distance between this point and another point.
Definition qgspoint.h:450
QgsPoint operator-(QgsVector v) const
Subtracts a vector from this point.
Definition qgspoint.h:554
double & rx()
Returns a reference to the x-coordinate of this point.
Definition qgspoint.h:296
QgsPoint operator+(QgsVector v) const
Adds a vector to this point.
Definition qgspoint.h:549
double distanceSquared3D(const QgsPoint &other) const
Returns the Cartesian 3D squared distance between this point and another point.
Definition qgspoint.h:480
void setX(double x)
Sets the point's x-coordinate.
Definition qgspoint.h:330
QgsPoint & operator+=(QgsVector v)
Adds a vector to this point in place.
Definition qgspoint.h:539
static QgsPoint * cast(QgsAbstractGeometry *geom)
Cast the geom to a QgsPoint.
Definition qgspoint.h:648
static const QgsPoint * cast(const QgsAbstractGeometry *geom)
Cast the geom to a QgsPoint.
Definition qgspoint.h:633
QPointF toQPointF() const
Returns the point as a QPointF.
Definition qgspoint.h:380
double distance(const QgsPoint &other) const
Returns the Cartesian 2D distance between this point and another point.
Definition qgspoint.h:402
double distance3D(double x, double y, double z) const
Returns the Cartesian 3D distance between this point and a specified x, y, z coordinate.
Definition qgspoint.h:435
double distanceSquared3D(double x, double y, double z) const
Returns the Cartesian 3D squared distance between this point and a specified x, y,...
Definition qgspoint.h:465
double z
Definition qgspoint.h:58
double x
Definition qgspoint.h:56
void setM(double m)
Sets the point's m-value.
Definition qgspoint.h:369
double y() const
Returns the point's y-coordinate.
Definition qgspoint.h:273
QgsPoint & operator-=(QgsVector v)
Subtracts a vector from this point in place.
Definition qgspoint.h:544
bool fuzzyEqual(const QgsAbstractGeometry &other, double epsilon=1e-8) const override
Performs fuzzy comparison between this geometry and other using an epsilon.
Definition qgspoint.h:193
double distanceSquared(const QgsPoint &other) const
Returns the Cartesian 2D squared distance between this point another point.
Definition qgspoint.h:424
double distance(double x, double y) const
Returns the Cartesian 2D distance between this point and a specified x, y coordinate.
Definition qgspoint.h:391
double m() const
Returns the point's m value.
Definition qgspoint.h:287
double & ry()
Returns a reference to the y-coordinate of this point.
Definition qgspoint.h:305
void setZ(double z)
Sets the point's z-coordinate.
Definition qgspoint.h:354
double distanceSquared(double x, double y) const
Returns the Cartesian 2D squared distance between this point a specified x, y coordinate.
Definition qgspoint.h:413
double m
Definition qgspoint.h:59
double y
Definition qgspoint.h:57
bool operator!=(const QgsAbstractGeometry &other) const override
Definition qgspoint.h:256
QgsPoint(double x=std::numeric_limits< double >::quiet_NaN(), double y=std::numeric_limits< double >::quiet_NaN(), double z=std::numeric_limits< double >::quiet_NaN(), double m=std::numeric_limits< double >::quiet_NaN(), Qgis::WkbType wkbType=Qgis::WkbType::Unknown)
Construct a point with the provided initial coordinate values.
Definition qgspoint.cpp:48
double & rz()
Returns a reference to the z-coordinate of this point.
Definition qgspoint.h:314
double & rm()
Returns a reference to the m value of this point.
Definition qgspoint.h:323
double x() const
Returns the point's x-coordinate.
Definition qgspoint.h:266
A rectangle specified with double values.
Represent a 2-dimensional vector.
Definition qgsvector.h:34
static Qgis::WkbType flatType(Qgis::WkbType type)
Returns the flat type for a WKB type.
#define SIP_TYPEHINT(type)
Definition qgis_sip.h:240
#define SIP_SKIP
Definition qgis_sip.h:134
#define SIP_OUT
Definition qgis_sip.h:58
#define SIP_HOLDGIL
Definition qgis_sip.h:179
#define SIP_FACTORY
Definition qgis_sip.h:84
#define SIP_THROW(name,...)
Definition qgis_sip.h:211
T qgsgeometry_cast(QgsAbstractGeometry *geom)
QVector< QgsRingSequence > QgsCoordinateSequence
double closestSegment(const QgsPolylineXY &pl, const QgsPointXY &pt, int &vertexAfter, double epsilon)
Definition qgstracer.cpp:75
Utility class for identifying a unique vertex within a geometry.
Definition qgsvertexid.h:34