QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
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:
88#ifndef SIP_RUN
90 double x = std::numeric_limits<double>::quiet_NaN(),
91 double y = std::numeric_limits<double>::quiet_NaN(),
92 double z = std::numeric_limits<double>::quiet_NaN(),
93 double m = std::numeric_limits<double>::quiet_NaN(),
95 );
96#else
97 // clang-format off
98 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 )];
99 % MethodCode
100 if ( sipCanConvertToType( a0, sipType_QgsPointXY, SIP_NOT_NONE ) && a1 == Py_None && a2 == Py_None && a3 == Py_None && a4 == Py_None )
101 {
102 int state;
103 sipIsErr = 0;
104
105 QgsPointXY *p = reinterpret_cast<QgsPointXY *>( sipConvertToType( a0, sipType_QgsPointXY, 0, SIP_NOT_NONE, &state, &sipIsErr ) );
106 if ( !sipIsErr )
107 {
108 sipCpp = new sipQgsPoint( QgsPoint( *p ) );
109 }
110 sipReleaseType( p, sipType_QgsPointXY, state );
111 }
112 else if ( sipCanConvertToType( a0, sipType_QPointF, SIP_NOT_NONE ) && a1 == Py_None && a2 == Py_None && a3 == Py_None && a4 == Py_None )
113 {
114 int state;
115 sipIsErr = 0;
116
117 QPointF *p = reinterpret_cast<QPointF *>( sipConvertToType( a0, sipType_QPointF, 0, SIP_NOT_NONE, &state, &sipIsErr ) );
118 if ( !sipIsErr )
119 {
120 sipCpp = new sipQgsPoint( QgsPoint( *p ) );
121 }
122 sipReleaseType( p, sipType_QPointF, state );
123 }
124 else if (
125 ( a0 == Py_None || PyFloat_AsDouble( a0 ) != -1.0 || !PyErr_Occurred() ) &&
126 ( a1 == Py_None || PyFloat_AsDouble( a1 ) != -1.0 || !PyErr_Occurred() ) &&
127 ( a2 == Py_None || PyFloat_AsDouble( a2 ) != -1.0 || !PyErr_Occurred() ) &&
128 ( a3 == Py_None || PyFloat_AsDouble( a3 ) != -1.0 || !PyErr_Occurred() ) )
129 {
130 double x = a0 == Py_None ? std::numeric_limits<double>::quiet_NaN() : PyFloat_AsDouble( a0 );
131 double y = a1 == Py_None ? std::numeric_limits<double>::quiet_NaN() : PyFloat_AsDouble( a1 );
132 double z = a2 == Py_None ? std::numeric_limits<double>::quiet_NaN() : PyFloat_AsDouble( a2 );
133 double m = a3 == Py_None ? std::numeric_limits<double>::quiet_NaN() : PyFloat_AsDouble( a3 );
134 Qgis::WkbType wkbType = a4 == Py_None ? Qgis::WkbType::Unknown : static_cast<Qgis::WkbType>( sipConvertToEnum( a4, sipType_Qgis_WkbType ) );
135 sipCpp = new sipQgsPoint( QgsPoint( x, y, z, m, wkbType ) );
136 }
137 else // Invalid ctor arguments
138 {
139 PyErr_SetString( PyExc_TypeError, u"Invalid type in constructor arguments."_s.toUtf8().constData() );
140 sipIsErr = 1;
141 }
142 % End
143// clang-format on
144#endif
145
149 explicit QgsPoint( const QgsPointXY &p ) SIP_SKIP;
150
154 explicit QgsPoint( QPointF p ) SIP_SKIP;
155
161 explicit QgsPoint(
162 Qgis::WkbType wkbType,
163 double x = std::numeric_limits<double>::quiet_NaN(),
164 double y = std::numeric_limits<double>::quiet_NaN(),
165 double z = std::numeric_limits<double>::quiet_NaN(),
166 double m = std::numeric_limits<double>::quiet_NaN()
167 ) SIP_SKIP;
168
177 explicit QgsPoint( const QVector3D &vect, double m = std::numeric_limits<double>::quiet_NaN() ) SIP_SKIP;
178
186 explicit QgsPoint( const QVector4D &vect ) SIP_SKIP;
187
196 explicit QgsPoint( const QgsVector3D &vect, double m = std::numeric_limits<double>::quiet_NaN() ) SIP_SKIP;
197
198#ifndef SIP_RUN
199 private:
200 bool fuzzyHelper(
201 double epsilon,
202 const QgsAbstractGeometry &other,
203 bool is3DFlag,
204 bool isMeasureFlag,
205 std::function<bool( double, double, double, double, double, double, double, double, double )> comparator3DMeasure,
206 std::function<bool( double, double, double, double, double, double, double )> comparator3D,
207 std::function<bool( double, double, double, double, double, double, double )> comparatorMeasure,
208 std::function<bool( double, double, double, double, double )> comparator2D
209 ) const
210 {
211 const QgsPoint *pt = qgsgeometry_cast< const QgsPoint * >( &other );
212 if ( !pt )
213 return false;
214
215 const Qgis::WkbType type = wkbType();
216
217 if ( pt->wkbType() != type )
218 return false;
219
220 if ( is3DFlag && isMeasureFlag )
221 {
222 return comparator3DMeasure( epsilon, mX, mY, mZ, mM, pt->x(), pt->y(), pt->z(), pt->m() );
223 }
224 else if ( is3DFlag )
225 {
226 return comparator3D( epsilon, mX, mY, mZ, pt->x(), pt->y(), pt->z() );
227 }
228 else if ( isMeasureFlag )
229 {
230 return comparatorMeasure( epsilon, mX, mY, mM, pt->x(), pt->y(), pt->m() );
231 }
232 return comparator2D( epsilon, mX, mY, pt->x(), pt->y() );
233 }
234#endif // !SIP_RUN
235
236 public:
237 // clang-format off
238 bool fuzzyEqual( const QgsAbstractGeometry &other, double epsilon = 1e-8 ) const override SIP_HOLDGIL
239 // clang-format on
240 {
241 return fuzzyHelper(
242 epsilon,
243 other,
244 is3D(),
245 isMeasure(),
246 []( double epsilon, double x1, double y1, double z1, double m1,
247 double x2, double y2, double z2, double m2 )
248 {
249 return QgsGeometryUtilsBase::fuzzyEqual( epsilon, x1, y1, z1, m1, x2, y2, z2, m2 );
250 },
251 []( double epsilon, double x1, double y1, double z1,
252 double x2, double y2, double z2 )
253 {
254 return QgsGeometryUtilsBase::fuzzyEqual( epsilon, x1, y1, z1, x2, y2, z2 );
255 },
256 []( double epsilon, double x1, double y1, double m1,
257 double x2, double y2, double m2 )
258 {
259 return QgsGeometryUtilsBase::fuzzyEqual( epsilon, x1, y1, m1, x2, y2, m2 );
260 },
261 []( double epsilon, double x1, double y1,
262 double x2, double y2 )
263 {
264 return QgsGeometryUtilsBase::fuzzyEqual( epsilon, x1, y1, x2, y2 );
265 } );
266 }
267
268 bool fuzzyDistanceEqual( const QgsAbstractGeometry &other, double epsilon = 1e-8 ) const override SIP_HOLDGIL
269 {
270 return fuzzyHelper(
271 epsilon,
272 other,
273 is3D(),
274 isMeasure(),
275 []( double epsilon, double x1, double y1, double z1, double m1,
276 double x2, double y2, double z2, double m2 )
277 {
278 return QgsGeometryUtilsBase::fuzzyDistanceEqual( epsilon, x1, y1, z1, m1, x2, y2, z2, m2 );
279 },
280 []( double epsilon, double x1, double y1, double z1,
281 double x2, double y2, double z2 )
282 {
283 return QgsGeometryUtilsBase::fuzzyDistanceEqual( epsilon, x1, y1, z1, x2, y2, z2 );
284 },
285 []( double epsilon, double x1, double y1, double m1,
286 double x2, double y2, double m2 )
287 {
288 return QgsGeometryUtilsBase::fuzzyDistanceEqual( epsilon, x1, y1, m1, x2, y2, m2 );
289 },
290 []( double epsilon, double x1, double y1,
291 double x2, double y2 )
292 {
293 return QgsGeometryUtilsBase::fuzzyDistanceEqual( epsilon, x1, y1, x2, y2 );
294 } );
295 }
296
297 bool operator==( const QgsAbstractGeometry &other ) const override SIP_HOLDGIL
298 {
299 return fuzzyEqual( other, 1e-8 );
300 }
301
302 bool operator!=( const QgsAbstractGeometry &other ) const override SIP_HOLDGIL
303 {
304 return !fuzzyEqual( other, 1e-8 );
305 }
306
312 double x() const SIP_HOLDGIL { return mX; }
313
319 double y() const SIP_HOLDGIL { return mY; }
320
326 double z() const SIP_HOLDGIL { return mZ; }
327
333 double m() const SIP_HOLDGIL { return mM; }
334
342 double &rx() SIP_SKIP { clearCache(); return mX; }
343
351 double &ry() SIP_SKIP { clearCache(); return mY; }
352
360 double &rz() SIP_SKIP { clearCache(); return mZ; }
361
369 double &rm() SIP_SKIP { clearCache(); return mM; }
370
376 void setX( double x ) SIP_HOLDGIL
377 {
378 clearCache();
379 mX = x;
380 }
381
387 void setY( double y ) SIP_HOLDGIL
388 {
389 clearCache();
390 mY = y;
391 }
392
400 void setZ( double z ) SIP_HOLDGIL
401 {
402 if ( !is3D() )
403 return;
404 clearCache();
405 mZ = z;
406 }
407
415 void setM( double m ) SIP_HOLDGIL
416 {
417 if ( !isMeasure() )
418 return;
419 clearCache();
420 mM = m;
421 }
422
426 QPointF toQPointF() const SIP_HOLDGIL
427 {
428 return QPointF( mX, mY );
429 }
430
436 QVector3D toVector3D() const SIP_HOLDGIL
437 {
438 return QVector3D( static_cast<float>( mX ), static_cast<float>( mY ), static_cast<float>( mZ ) ); //
439 }
440
446 QVector4D toVector4D() const SIP_HOLDGIL
447 {
448 return QVector4D( static_cast<float>( mX ), static_cast<float>( mY ), static_cast<float>( mZ ), static_cast<float>( mM ) );
449 }
450
456 {
457 return QgsVector3D( mX, mY, mZ );
458 }
459
466 double distance( double x, double y ) const SIP_HOLDGIL
467 {
468 return QgsGeometryUtilsBase::distance2D( mX, mY, x, y );
469 }
470
477 double distance( const QgsPoint &other ) const SIP_HOLDGIL
478 {
479 return QgsGeometryUtilsBase::distance2D( mX, mY, other.x(), other.y() );
480 }
481
488 double distanceSquared( double x, double y ) const SIP_HOLDGIL
489 {
490 return QgsGeometryUtilsBase::sqrDistance2D( mX, mY, x, y );
491 }
492
499 double distanceSquared( const QgsPoint &other ) const SIP_HOLDGIL
500 {
501 return QgsGeometryUtilsBase::sqrDistance2D( mX, mY, other.x(), other.y() );
502 }
503
510 double distance3D( double x, double y, double z ) const SIP_HOLDGIL
511 {
512 if ( is3D() || !std::isnan( z ) )
513 {
514 return QgsGeometryUtilsBase::distance3D( mX, mY, mZ, x, y, z );
515 }
516 return QgsGeometryUtilsBase::distance2D( mX, mY, x, y );
517 }
518
525 double distance3D( const QgsPoint &other ) const SIP_HOLDGIL
526 {
527 if ( is3D() || other.is3D() )
528 {
529 return QgsGeometryUtilsBase::distance3D( mX, mY, mZ, other.x(), other.y(), other.z() );
530 }
531 return QgsGeometryUtilsBase::distance2D( mX, mY, other.x(), other.y() );
532 }
533
540 double distanceSquared3D( double x, double y, double z ) const SIP_HOLDGIL
541 {
542 if ( is3D() || !std::isnan( z ) )
543 {
544 return QgsGeometryUtilsBase::sqrDistance3D( mX, mY, mZ, x, y, z );
545 }
546 return QgsGeometryUtilsBase::sqrDistance2D( mX, mY, x, y );
547 }
548
555 double distanceSquared3D( const QgsPoint &other ) const SIP_HOLDGIL
556 {
557 if ( is3D() || other.is3D() )
558 {
559 return QgsGeometryUtilsBase::sqrDistance3D( mX, mY, mZ, other.x(), other.y(), other.z() );
560 }
561 return QgsGeometryUtilsBase::sqrDistance2D( mX, mY, other.x(), other.y() );
562 }
563
567 double azimuth( const QgsPoint &other ) const SIP_HOLDGIL;
568
573 double inclination( const QgsPoint &other ) const SIP_HOLDGIL;
574
604 QgsPoint project( double distance, double azimuth, double inclination = 90.0 ) const SIP_HOLDGIL;
605
609 QgsVector operator-( const QgsPoint &p ) const SIP_HOLDGIL { return QgsVector( mX - p.mX, mY - p.mY ); }
610
614 QgsPoint &operator+=( QgsVector v ) SIP_HOLDGIL { mX += v.x(); mY += v.y(); return *this; }
615
619 QgsPoint &operator-=( QgsVector v ) SIP_HOLDGIL { mX -= v.x(); mY -= v.y(); return *this; }
620
624 QgsPoint operator+( QgsVector v ) const SIP_HOLDGIL { QgsPoint r = *this; r.rx() += v.x(); r.ry() += v.y(); return r; }
625
629 QgsPoint operator-( QgsVector v ) const SIP_HOLDGIL { QgsPoint r = *this; r.rx() -= v.x(); r.ry() -= v.y(); return r; }
630
631 //implementation of inherited methods
632 void normalize() final SIP_HOLDGIL;
633 bool isEmpty() const override SIP_HOLDGIL;
634 QgsBox3D boundingBox3D() const override SIP_HOLDGIL;
635 QString geometryType() const override SIP_HOLDGIL;
636 int dimension() const override SIP_HOLDGIL;
637 QgsPoint *clone() const override SIP_FACTORY;
638 QgsPoint *snappedToGrid( double hSpacing, double vSpacing, double dSpacing = 0, double mSpacing = 0, bool removeRedundantPoints = false ) const override SIP_FACTORY;
639 QgsPoint *simplifyByDistance( double tolerance ) const override SIP_FACTORY;
640 bool removeDuplicateNodes( double epsilon = 4 * std::numeric_limits<double>::epsilon(), bool useZValues = false ) override;
641 void clear() override;
642 bool fromWkb( QgsConstWkbPtr &wkb ) override;
643 bool fromWkt( const QString &wkt ) override;
644 int wkbSize( QgsAbstractGeometry::WkbFlags flags = QgsAbstractGeometry::WkbFlags() ) const override;
645 QByteArray asWkb( QgsAbstractGeometry::WkbFlags = QgsAbstractGeometry::WkbFlags() ) const override;
646 QString asWkt( int precision = 17 ) const override;
647 QDomElement asGml2( QDomDocument &doc, int precision = 17, const QString &ns = "gml", QgsAbstractGeometry::AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY ) const override;
648 QDomElement asGml3( QDomDocument &doc, int precision = 17, const QString &ns = "gml", QgsAbstractGeometry::AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY ) const override;
649 json asJsonObject( int precision = 17 ) const override SIP_SKIP;
650 QString asKml( int precision = 17 ) const override;
651 void draw( QPainter &p ) const override;
652 QPainterPath asQPainterPath() const override;
653 void transform( const QgsCoordinateTransform &ct, Qgis::TransformDirection d = Qgis::TransformDirection::Forward, bool transformZ = false ) override SIP_THROW( QgsCsException );
654 void transform( const QTransform &t, double zTranslate = 0.0, double zScale = 1.0, double mTranslate = 0.0, double mScale = 1.0 ) override;
655 QgsCoordinateSequence coordinateSequence() const override;
656 int nCoordinates() const override SIP_HOLDGIL;
657 int vertexNumberFromVertexId( QgsVertexId id ) const override;
658 QgsAbstractGeometry *boundary() const override SIP_FACTORY;
659 bool isValid( QString &error SIP_OUT, Qgis::GeometryValidityFlags flags = Qgis::GeometryValidityFlags() ) const override SIP_HOLDGIL;
660
661 //low-level editing
662 bool insertVertex( QgsVertexId position, const QgsPoint &vertex ) override;
663 bool moveVertex( QgsVertexId position, const QgsPoint &newPos ) override;
664 bool deleteVertex( QgsVertexId position ) override;
665
666 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;
667 bool nextVertex( QgsVertexId &id, QgsPoint &vertex SIP_OUT ) const override;
668 void adjacentVertices( QgsVertexId vertex, QgsVertexId &previousVertex SIP_OUT, QgsVertexId &nextVertex SIP_OUT ) const override;
669
675 double vertexAngle( QgsVertexId vertex ) const override;
676
677 int vertexCount( int /*part*/ = 0, int /*ring*/ = 0 ) const override;
678 int ringCount( int /*part*/ = 0 ) const override;
679 int partCount() const override;
680 QgsPoint vertexAt( QgsVertexId /*id*/ ) const override;
681 QgsPoint *toCurveType() const override SIP_FACTORY;
682 double segmentLength( QgsVertexId startVertex ) const override;
683 bool boundingBoxIntersects( const QgsRectangle &rectangle ) const override SIP_HOLDGIL;
684 bool boundingBoxIntersects( const QgsBox3D &box3d ) const override SIP_HOLDGIL;
685
686 bool addZValue( double zValue = 0 ) override;
687 bool addMValue( double mValue = 0 ) override;
688 bool dropZValue() override;
689 bool dropMValue() override;
690 void swapXy() override;
691 bool convertTo( Qgis::WkbType type ) override;
692
693 bool transform( QgsAbstractGeometryTransformer *transformer, QgsFeedback *feedback = nullptr ) override;
694
695#ifndef SIP_RUN
696
697 void filterVertices( const std::function< bool( const QgsPoint & ) > &filter ) override;
698 void transformVertices( const std::function< QgsPoint( const QgsPoint & ) > &transform ) override;
699
708 inline static const QgsPoint *cast( const QgsAbstractGeometry *geom )
709 {
710 if ( geom && QgsWkbTypes::flatType( geom->wkbType() ) == Qgis::WkbType::Point )
711 return static_cast<const QgsPoint *>( geom );
712 return nullptr;
713 }
714
723 inline static QgsPoint *cast( QgsAbstractGeometry *geom )
724 {
725 if ( geom && QgsWkbTypes::flatType( geom->wkbType() ) == Qgis::WkbType::Point )
726 return static_cast<QgsPoint *>( geom );
727 return nullptr;
728 }
729#endif
730
732
733#ifdef SIP_RUN
734// clang-format off
735 SIP_PYOBJECT __repr__();
736 % MethodCode
737 QString str = u"<QgsPoint: %1>"_s.arg( sipCpp->asWkt() );
738 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
739 % End
740// clang-format on
741#endif
742
743 protected:
744
745 int compareToSameClass( const QgsAbstractGeometry *other ) const final;
746 int childCount() const override;
747 QgsPoint childPoint( int index ) const override;
748
749 private:
750 double mX;
751 double mY;
752 double mZ;
753 double mM;
754};
755
756// clazy:excludeall=qstring-allocations
757
758#endif // QGSPOINT_H
Provides global constants and enumerations for use throughout the application.
Definition qgis.h:62
WkbType
The WKB type describes the number of dimensions a geometry has.
Definition qgis.h:294
@ Point
Point.
Definition qgis.h:296
@ Unknown
Unknown.
Definition qgis.h:295
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:211
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:326
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:268
void setY(double y)
Sets the point's y-coordinate.
Definition qgspoint.h:387
bool operator==(const QgsAbstractGeometry &other) const override
Definition qgspoint.h:297
double distance3D(const QgsPoint &other) const
Returns the Cartesian 3D distance between this point and another point.
Definition qgspoint.h:525
QgsPoint operator-(QgsVector v) const
Subtracts a vector from this point.
Definition qgspoint.h:629
double & rx()
Returns a reference to the x-coordinate of this point.
Definition qgspoint.h:342
QgsVector3D toQgsVector3D() const
Returns the point as a QgsVector3D.
Definition qgspoint.h:455
QVector3D toVector3D() const
Returns the point as a QVector3D.
Definition qgspoint.h:436
QgsPoint operator+(QgsVector v) const
Adds a vector to this point.
Definition qgspoint.h:624
double distanceSquared3D(const QgsPoint &other) const
Returns the Cartesian 3D squared distance between this point and another point.
Definition qgspoint.h:555
void setX(double x)
Sets the point's x-coordinate.
Definition qgspoint.h:376
QgsPoint & operator+=(QgsVector v)
Adds a vector to this point in place.
Definition qgspoint.h:614
static QgsPoint * cast(QgsAbstractGeometry *geom)
Cast the geom to a QgsPoint.
Definition qgspoint.h:723
static const QgsPoint * cast(const QgsAbstractGeometry *geom)
Cast the geom to a QgsPoint.
Definition qgspoint.h:708
QPointF toQPointF() const
Returns the point as a QPointF.
Definition qgspoint.h:426
double distance(const QgsPoint &other) const
Returns the Cartesian 2D distance between this point and another point.
Definition qgspoint.h:477
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:510
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:540
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:415
double y() const
Returns the point's y-coordinate.
Definition qgspoint.h:319
QgsPoint & operator-=(QgsVector v)
Subtracts a vector from this point in place.
Definition qgspoint.h:619
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:238
double distanceSquared(const QgsPoint &other) const
Returns the Cartesian 2D squared distance between this point another point.
Definition qgspoint.h:499
QVector4D toVector4D() const
Returns the point as a QVector4D.
Definition qgspoint.h:446
double distance(double x, double y) const
Returns the Cartesian 2D distance between this point and a specified x, y coordinate.
Definition qgspoint.h:466
double m() const
Returns the point's m value.
Definition qgspoint.h:333
double & ry()
Returns a reference to the y-coordinate of this point.
Definition qgspoint.h:351
void setZ(double z)
Sets the point's z-coordinate.
Definition qgspoint.h:400
double distanceSquared(double x, double y) const
Returns the Cartesian 2D squared distance between this point a specified x, y coordinate.
Definition qgspoint.h:488
double m
Definition qgspoint.h:59
double y
Definition qgspoint.h:57
bool operator!=(const QgsAbstractGeometry &other) const override
Definition qgspoint.h:302
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:360
double & rm()
Returns a reference to the m value of this point.
Definition qgspoint.h:369
double x() const
Returns the point's x-coordinate.
Definition qgspoint.h:312
A rectangle specified with double values.
A 3D vector (similar to QVector3D) with the difference that it uses double precision instead of singl...
Definition qgsvector3d.h:33
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:239
#define SIP_SKIP
Definition qgis_sip.h:133
#define SIP_OUT
Definition qgis_sip.h:57
#define SIP_HOLDGIL
Definition qgis_sip.h:178
#define SIP_FACTORY
Definition qgis_sip.h:83
#define SIP_THROW(name,...)
Definition qgis_sip.h:210
T qgsgeometry_cast(QgsAbstractGeometry *geom)
QVector< QgsRingSequence > QgsCoordinateSequence
double closestSegment(const QgsPolylineXY &pl, const QgsPointXY &pt, int &vertexAfter, double epsilon)
Definition qgstracer.cpp:72
Utility class for identifying a unique vertex within a geometry.
Definition qgsvertexid.h:34