QGIS API Documentation 3.99.0-Master (b3fe4c4eded)
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
164 explicit QgsPoint( const QVector3D &vect, double m = std::numeric_limits<double>::quiet_NaN() ) SIP_SKIP;
165
173 explicit QgsPoint( const QVector4D &vect ) SIP_SKIP;
174
183 explicit QgsPoint( const QgsVector3D &vect, double m = std::numeric_limits<double>::quiet_NaN() ) SIP_SKIP;
184
185#ifndef SIP_RUN
186 private:
187 bool fuzzyHelper( double epsilon,
188 const QgsAbstractGeometry &other,
189 bool is3DFlag,
190 bool isMeasureFlag,
191 std::function<bool( double, double, double, double, double, double, double, double, double )> comparator3DMeasure,
192 std::function<bool( double, double, double, double, double, double, double )> comparator3D,
193 std::function<bool( double, double, double, double, double, double, double )> comparatorMeasure,
194 std::function<bool( double, double, double, double, double )> comparator2D ) const
195 {
196 const QgsPoint *pt = qgsgeometry_cast< const QgsPoint * >( &other );
197 if ( !pt )
198 return false;
199
200 const Qgis::WkbType type = wkbType();
201
202 if ( pt->wkbType() != type )
203 return false;
204
205 if ( is3DFlag && isMeasureFlag )
206 {
207 return comparator3DMeasure( epsilon, mX, mY, mZ, mM, pt->x(), pt->y(), pt->z(), pt->m() );
208 }
209 else if ( is3DFlag )
210 {
211 return comparator3D( epsilon, mX, mY, mZ, pt->x(), pt->y(), pt->z() );
212 }
213 else if ( isMeasureFlag )
214 {
215 return comparatorMeasure( epsilon, mX, mY, mM, pt->x(), pt->y(), pt->m() );
216 }
217 return comparator2D( epsilon, mX, mY, pt->x(), pt->y() );
218 }
219#endif // !SIP_RUN
220
221 public:
222 bool fuzzyEqual( 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::fuzzyEqual( 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::fuzzyEqual( 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::fuzzyEqual( epsilon, x1, y1, m1, x2, y2, m2 );
243 },
244 []( double epsilon, double x1, double y1,
245 double x2, double y2 )
246 {
247 return QgsGeometryUtilsBase::fuzzyEqual( epsilon, x1, y1, x2, y2 );
248 } );
249 }
250
251 bool fuzzyDistanceEqual( const QgsAbstractGeometry &other, double epsilon = 1e-8 ) const override SIP_HOLDGIL
252 {
253 return fuzzyHelper(
254 epsilon,
255 other,
256 is3D(),
257 isMeasure(),
258 []( double epsilon, double x1, double y1, double z1, double m1,
259 double x2, double y2, double z2, double m2 )
260 {
261 return QgsGeometryUtilsBase::fuzzyDistanceEqual( epsilon, x1, y1, z1, m1, x2, y2, z2, m2 );
262 },
263 []( double epsilon, double x1, double y1, double z1,
264 double x2, double y2, double z2 )
265 {
266 return QgsGeometryUtilsBase::fuzzyDistanceEqual( epsilon, x1, y1, z1, x2, y2, z2 );
267 },
268 []( double epsilon, double x1, double y1, double m1,
269 double x2, double y2, double m2 )
270 {
271 return QgsGeometryUtilsBase::fuzzyDistanceEqual( epsilon, x1, y1, m1, x2, y2, m2 );
272 },
273 []( double epsilon, double x1, double y1,
274 double x2, double y2 )
275 {
276 return QgsGeometryUtilsBase::fuzzyDistanceEqual( epsilon, x1, y1, x2, y2 );
277 } );
278 }
279
280 bool operator==( const QgsAbstractGeometry &other ) const override SIP_HOLDGIL
281 {
282 return fuzzyEqual( other, 1e-8 );
283 }
284
285 bool operator!=( const QgsAbstractGeometry &other ) const override SIP_HOLDGIL
286 {
287 return !fuzzyEqual( other, 1e-8 );
288 }
289
295 double x() const SIP_HOLDGIL { return mX; }
296
302 double y() const SIP_HOLDGIL { return mY; }
303
309 double z() const SIP_HOLDGIL { return mZ; }
310
316 double m() const SIP_HOLDGIL { return mM; }
317
325 double &rx() SIP_SKIP { clearCache(); return mX; }
326
334 double &ry() SIP_SKIP { clearCache(); return mY; }
335
343 double &rz() SIP_SKIP { clearCache(); return mZ; }
344
352 double &rm() SIP_SKIP { clearCache(); return mM; }
353
359 void setX( double x ) SIP_HOLDGIL
360 {
361 clearCache();
362 mX = x;
363 }
364
370 void setY( double y ) SIP_HOLDGIL
371 {
372 clearCache();
373 mY = y;
374 }
375
383 void setZ( double z ) SIP_HOLDGIL
384 {
385 if ( !is3D() )
386 return;
387 clearCache();
388 mZ = z;
389 }
390
398 void setM( double m ) SIP_HOLDGIL
399 {
400 if ( !isMeasure() )
401 return;
402 clearCache();
403 mM = m;
404 }
405
409 QPointF toQPointF() const SIP_HOLDGIL
410 {
411 return QPointF( mX, mY );
412 }
413
419 QVector3D toVector3D() const SIP_HOLDGIL
420 {
421 return QVector3D( static_cast<float>( mX ), static_cast<float>( mY ), static_cast<float>( mZ ) ); //
422 }
423
429 QVector4D toVector4D() const SIP_HOLDGIL
430 {
431 return QVector4D( static_cast<float>( mX ), static_cast<float>( mY ), static_cast<float>( mZ ), static_cast<float>( mM ) );
432 }
433
439 {
440 return QgsVector3D( mX, mY, mZ );
441 }
442
449 double distance( double x, double y ) const SIP_HOLDGIL
450 {
451 return QgsGeometryUtilsBase::distance2D( mX, mY, x, y );
452 }
453
460 double distance( const QgsPoint &other ) const SIP_HOLDGIL
461 {
462 return QgsGeometryUtilsBase::distance2D( mX, mY, other.x(), other.y() );
463 }
464
471 double distanceSquared( double x, double y ) const SIP_HOLDGIL
472 {
473 return QgsGeometryUtilsBase::sqrDistance2D( mX, mY, x, y );
474 }
475
482 double distanceSquared( const QgsPoint &other ) const SIP_HOLDGIL
483 {
484 return QgsGeometryUtilsBase::sqrDistance2D( mX, mY, other.x(), other.y() );
485 }
486
493 double distance3D( double x, double y, double z ) const SIP_HOLDGIL
494 {
495 if ( is3D() || !std::isnan( z ) )
496 {
497 return QgsGeometryUtilsBase::distance3D( mX, mY, mZ, x, y, z );
498 }
499 return QgsGeometryUtilsBase::distance2D( mX, mY, x, y );
500 }
501
508 double distance3D( const QgsPoint &other ) const SIP_HOLDGIL
509 {
510 if ( is3D() || other.is3D() )
511 {
512 return QgsGeometryUtilsBase::distance3D( mX, mY, mZ, other.x(), other.y(), other.z() );
513 }
514 return QgsGeometryUtilsBase::distance2D( mX, mY, other.x(), other.y() );
515 }
516
523 double distanceSquared3D( double x, double y, double z ) const SIP_HOLDGIL
524 {
525 if ( is3D() || !std::isnan( z ) )
526 {
527 return QgsGeometryUtilsBase::sqrDistance3D( mX, mY, mZ, x, y, z );
528 }
529 return QgsGeometryUtilsBase::sqrDistance2D( mX, mY, x, y );
530 }
531
538 double distanceSquared3D( const QgsPoint &other ) const SIP_HOLDGIL
539 {
540 if ( is3D() || other.is3D() )
541 {
542 return QgsGeometryUtilsBase::sqrDistance3D( mX, mY, mZ, other.x(), other.y(), other.z() );
543 }
544 return QgsGeometryUtilsBase::sqrDistance2D( mX, mY, other.x(), other.y() );
545 }
546
550 double azimuth( const QgsPoint &other ) const SIP_HOLDGIL;
551
556 double inclination( const QgsPoint &other ) const SIP_HOLDGIL;
557
587 QgsPoint project( double distance, double azimuth, double inclination = 90.0 ) const SIP_HOLDGIL;
588
592 QgsVector operator-( const QgsPoint &p ) const SIP_HOLDGIL { return QgsVector( mX - p.mX, mY - p.mY ); }
593
597 QgsPoint &operator+=( QgsVector v ) SIP_HOLDGIL { mX += v.x(); mY += v.y(); return *this; }
598
602 QgsPoint &operator-=( QgsVector v ) SIP_HOLDGIL { mX -= v.x(); mY -= v.y(); return *this; }
603
607 QgsPoint operator+( QgsVector v ) const SIP_HOLDGIL { QgsPoint r = *this; r.rx() += v.x(); r.ry() += v.y(); return r; }
608
612 QgsPoint operator-( QgsVector v ) const SIP_HOLDGIL { QgsPoint r = *this; r.rx() -= v.x(); r.ry() -= v.y(); return r; }
613
614 //implementation of inherited methods
615 void normalize() final SIP_HOLDGIL;
616 bool isEmpty() const override SIP_HOLDGIL;
617 QgsBox3D boundingBox3D() const override SIP_HOLDGIL;
618 QString geometryType() const override SIP_HOLDGIL;
619 int dimension() const override SIP_HOLDGIL;
620 QgsPoint *clone() const override SIP_FACTORY;
621 QgsPoint *snappedToGrid( double hSpacing, double vSpacing, double dSpacing = 0, double mSpacing = 0, bool removeRedundantPoints = false ) const override SIP_FACTORY;
622 QgsPoint *simplifyByDistance( double tolerance ) const override SIP_FACTORY;
623 bool removeDuplicateNodes( double epsilon = 4 * std::numeric_limits<double>::epsilon(), bool useZValues = false ) override;
624 void clear() override;
625 bool fromWkb( QgsConstWkbPtr &wkb ) override;
626 bool fromWkt( const QString &wkt ) override;
627 int wkbSize( QgsAbstractGeometry::WkbFlags flags = QgsAbstractGeometry::WkbFlags() ) const override;
628 QByteArray asWkb( QgsAbstractGeometry::WkbFlags = QgsAbstractGeometry::WkbFlags() ) const override;
629 QString asWkt( int precision = 17 ) const override;
630 QDomElement asGml2( QDomDocument &doc, int precision = 17, const QString &ns = "gml", QgsAbstractGeometry::AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY ) const override;
631 QDomElement asGml3( QDomDocument &doc, int precision = 17, const QString &ns = "gml", QgsAbstractGeometry::AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY ) const override;
632 json asJsonObject( int precision = 17 ) const override SIP_SKIP;
633 QString asKml( int precision = 17 ) const override;
634 void draw( QPainter &p ) const override;
635 QPainterPath asQPainterPath() const override;
636 void transform( const QgsCoordinateTransform &ct, Qgis::TransformDirection d = Qgis::TransformDirection::Forward, bool transformZ = false ) override SIP_THROW( QgsCsException );
637 void transform( const QTransform &t, double zTranslate = 0.0, double zScale = 1.0, double mTranslate = 0.0, double mScale = 1.0 ) override;
638 QgsCoordinateSequence coordinateSequence() const override;
639 int nCoordinates() const override SIP_HOLDGIL;
640 int vertexNumberFromVertexId( QgsVertexId id ) const override;
641 QgsAbstractGeometry *boundary() const override SIP_FACTORY;
642 bool isValid( QString &error SIP_OUT, Qgis::GeometryValidityFlags flags = Qgis::GeometryValidityFlags() ) const override SIP_HOLDGIL;
643
644 //low-level editing
645 bool insertVertex( QgsVertexId position, const QgsPoint &vertex ) override;
646 bool moveVertex( QgsVertexId position, const QgsPoint &newPos ) override;
647 bool deleteVertex( QgsVertexId position ) override;
648
649 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;
650 bool nextVertex( QgsVertexId &id, QgsPoint &vertex SIP_OUT ) const override;
651 void adjacentVertices( QgsVertexId vertex, QgsVertexId &previousVertex SIP_OUT, QgsVertexId &nextVertex SIP_OUT ) const override;
652
658 double vertexAngle( QgsVertexId vertex ) const override;
659
660 int vertexCount( int /*part*/ = 0, int /*ring*/ = 0 ) const override;
661 int ringCount( int /*part*/ = 0 ) const override;
662 int partCount() const override;
663 QgsPoint vertexAt( QgsVertexId /*id*/ ) const override;
664 QgsPoint *toCurveType() const override SIP_FACTORY;
665 double segmentLength( QgsVertexId startVertex ) const override;
666 bool boundingBoxIntersects( const QgsRectangle &rectangle ) const override SIP_HOLDGIL;
667 bool boundingBoxIntersects( const QgsBox3D &box3d ) const override SIP_HOLDGIL;
668
669 bool addZValue( double zValue = 0 ) override;
670 bool addMValue( double mValue = 0 ) override;
671 bool dropZValue() override;
672 bool dropMValue() override;
673 void swapXy() override;
674 bool convertTo( Qgis::WkbType type ) override;
675
676 bool transform( QgsAbstractGeometryTransformer *transformer, QgsFeedback *feedback = nullptr ) override;
677
678#ifndef SIP_RUN
679
680 void filterVertices( const std::function< bool( const QgsPoint & ) > &filter ) override;
681 void transformVertices( const std::function< QgsPoint( const QgsPoint & ) > &transform ) override;
682
691 inline static const QgsPoint *cast( const QgsAbstractGeometry *geom )
692 {
693 if ( geom && QgsWkbTypes::flatType( geom->wkbType() ) == Qgis::WkbType::Point )
694 return static_cast<const QgsPoint *>( geom );
695 return nullptr;
696 }
697
706 inline static QgsPoint *cast( QgsAbstractGeometry *geom )
707 {
708 if ( geom && QgsWkbTypes::flatType( geom->wkbType() ) == Qgis::WkbType::Point )
709 return static_cast<QgsPoint *>( geom );
710 return nullptr;
711 }
712#endif
713
715
716#ifdef SIP_RUN
717 SIP_PYOBJECT __repr__();
718 % MethodCode
719 QString str = u"<QgsPoint: %1>"_s.arg( sipCpp->asWkt() );
720 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
721 % End
722#endif
723
724 protected:
725
726 int compareToSameClass( const QgsAbstractGeometry *other ) const final;
727 int childCount() const override;
728 QgsPoint childPoint( int index ) const override;
729
730 private:
731 double mX;
732 double mY;
733 double mZ;
734 double mM;
735};
736
737// clazy:excludeall=qstring-allocations
738
739#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:309
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:251
void setY(double y)
Sets the point's y-coordinate.
Definition qgspoint.h:370
bool operator==(const QgsAbstractGeometry &other) const override
Definition qgspoint.h:280
double distance3D(const QgsPoint &other) const
Returns the Cartesian 3D distance between this point and another point.
Definition qgspoint.h:508
QgsPoint operator-(QgsVector v) const
Subtracts a vector from this point.
Definition qgspoint.h:612
double & rx()
Returns a reference to the x-coordinate of this point.
Definition qgspoint.h:325
QgsVector3D toQgsVector3D() const
Returns the point as a QgsVector3D.
Definition qgspoint.h:438
QVector3D toVector3D() const
Returns the point as a QVector3D.
Definition qgspoint.h:419
QgsPoint operator+(QgsVector v) const
Adds a vector to this point.
Definition qgspoint.h:607
double distanceSquared3D(const QgsPoint &other) const
Returns the Cartesian 3D squared distance between this point and another point.
Definition qgspoint.h:538
void setX(double x)
Sets the point's x-coordinate.
Definition qgspoint.h:359
QgsPoint & operator+=(QgsVector v)
Adds a vector to this point in place.
Definition qgspoint.h:597
static QgsPoint * cast(QgsAbstractGeometry *geom)
Cast the geom to a QgsPoint.
Definition qgspoint.h:706
static const QgsPoint * cast(const QgsAbstractGeometry *geom)
Cast the geom to a QgsPoint.
Definition qgspoint.h:691
QPointF toQPointF() const
Returns the point as a QPointF.
Definition qgspoint.h:409
double distance(const QgsPoint &other) const
Returns the Cartesian 2D distance between this point and another point.
Definition qgspoint.h:460
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:493
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:523
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:398
double y() const
Returns the point's y-coordinate.
Definition qgspoint.h:302
QgsPoint & operator-=(QgsVector v)
Subtracts a vector from this point in place.
Definition qgspoint.h:602
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:222
double distanceSquared(const QgsPoint &other) const
Returns the Cartesian 2D squared distance between this point another point.
Definition qgspoint.h:482
QVector4D toVector4D() const
Returns the point as a QVector4D.
Definition qgspoint.h:429
double distance(double x, double y) const
Returns the Cartesian 2D distance between this point and a specified x, y coordinate.
Definition qgspoint.h:449
double m() const
Returns the point's m value.
Definition qgspoint.h:316
double & ry()
Returns a reference to the y-coordinate of this point.
Definition qgspoint.h:334
void setZ(double z)
Sets the point's z-coordinate.
Definition qgspoint.h:383
double distanceSquared(double x, double y) const
Returns the Cartesian 2D squared distance between this point a specified x, y coordinate.
Definition qgspoint.h:471
double m
Definition qgspoint.h:59
double y
Definition qgspoint.h:57
bool operator!=(const QgsAbstractGeometry &other) const override
Definition qgspoint.h:285
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:343
double & rm()
Returns a reference to the m value of this point.
Definition qgspoint.h:352
double x() const
Returns the point's x-coordinate.
Definition qgspoint.h:295
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: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