QGIS API Documentation  2.99.0-Master (01468d0)
qgspoint.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgspointv2.cpp
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 
19 #include "qgspoint.h"
20 #include "qgsapplication.h"
21 #include "qgscoordinatetransform.h"
22 #include "qgsgeometryutils.h"
23 #include "qgsmaptopixel.h"
24 #include "qgswkbptr.h"
25 #include <QPainter>
26 #include <QRegularExpression>
27 
28 /***************************************************************************
29  * This class is considered CRITICAL and any change MUST be accompanied with
30  * full unit tests.
31  * See details in QEP #17
32  ****************************************************************************/
33 
34 QgsPoint::QgsPoint( double x, double y, double z, double m, QgsWkbTypes::Type wkbType )
36  , mX( x )
37  , mY( y )
38  , mZ( z )
39  , mM( m )
40 {
41  if ( wkbType != QgsWkbTypes::Unknown )
42  {
43  Q_ASSERT( QgsWkbTypes::flatType( wkbType ) == QgsWkbTypes::Point );
44  mWkbType = wkbType;
45  }
46  else if ( std::isnan( z ) )
47  {
48  if ( std::isnan( m ) )
50  else
52  }
53  else if ( std::isnan( m ) )
55  else
57 }
58 
61  , mX( p.x() )
62  , mY( p.y() )
63  , mZ( std::numeric_limits<double>::quiet_NaN() )
64  , mM( std::numeric_limits<double>::quiet_NaN() )
65 {
67 }
68 
69 QgsPoint::QgsPoint( QPointF p )
71  , mX( p.x() )
72  , mY( p.y() )
73  , mZ( std::numeric_limits<double>::quiet_NaN() )
74  , mM( std::numeric_limits<double>::quiet_NaN() )
75 {
77 }
78 
79 QgsPoint::QgsPoint( QgsWkbTypes::Type wkbType, double x, double y, double z, double m )
81  , mX( x )
82  , mY( y )
83  , mZ( z )
84  , mM( m )
85 {
86  Q_ASSERT( QgsWkbTypes::flatType( wkbType ) == QgsWkbTypes::Point );
87  mWkbType = wkbType;
88 }
89 
90 /***************************************************************************
91  * This class is considered CRITICAL and any change MUST be accompanied with
92  * full unit tests.
93  * See details in QEP #17
94  ****************************************************************************/
95 
96 bool QgsPoint::operator==( const QgsPoint &pt ) const
97 {
98  const QgsWkbTypes::Type type = wkbType();
99 
100  bool equal = pt.wkbType() == type;
101  equal &= qgsDoubleNear( pt.x(), mX, 1E-8 );
102  equal &= qgsDoubleNear( pt.y(), mY, 1E-8 );
103  if ( QgsWkbTypes::hasZ( type ) )
104  equal &= qgsDoubleNear( pt.z(), mZ, 1E-8 ) || ( std::isnan( pt.z() ) && std::isnan( mZ ) );
105  if ( QgsWkbTypes::hasM( type ) )
106  equal &= qgsDoubleNear( pt.m(), mM, 1E-8 ) || ( std::isnan( pt.m() ) && std::isnan( mM ) );
107 
108  return equal;
109 }
110 
111 bool QgsPoint::operator!=( const QgsPoint &pt ) const
112 {
113  return !operator==( pt );
114 }
115 
117 {
118  return new QgsPoint( *this );
119 }
120 
122 {
123  QgsWkbTypes::Type type = wkbPtr.readHeader();
124  if ( QgsWkbTypes::flatType( type ) != QgsWkbTypes::Point )
125  {
126  clear();
127  return false;
128  }
129  mWkbType = type;
130 
131  wkbPtr >> mX;
132  wkbPtr >> mY;
133  if ( is3D() )
134  wkbPtr >> mZ;
135  if ( isMeasure() )
136  wkbPtr >> mM;
137 
138  clearCache();
139 
140  return true;
141 }
142 
143 /***************************************************************************
144  * This class is considered CRITICAL and any change MUST be accompanied with
145  * full unit tests.
146  * See details in QEP #17
147  ****************************************************************************/
148 
149 bool QgsPoint::fromWkt( const QString &wkt )
150 {
151  clear();
152 
153  QPair<QgsWkbTypes::Type, QString> parts = QgsGeometryUtils::wktReadBlock( wkt );
154 
155  if ( QgsWkbTypes::flatType( parts.first ) != QgsWkbTypes::Point )
156  return false;
157  mWkbType = parts.first;
158 
159  QRegularExpression rx( "\\s" );
160  QStringList coordinates = parts.second.split( rx, QString::SkipEmptyParts );
161  if ( coordinates.size() < 2 )
162  {
163  clear();
164  return false;
165  }
166  else if ( coordinates.size() == 3 && !is3D() && !isMeasure() )
167  {
168  // 3 dimensional coordinates, but not specifically marked as such. We allow this
169  // anyway and upgrade geometry to have Z dimension
171  }
172  else if ( coordinates.size() >= 4 && ( !is3D() || !isMeasure() ) )
173  {
174  // 4 (or more) dimensional coordinates, but not specifically marked as such. We allow this
175  // anyway and upgrade geometry to have Z&M dimensions
178  }
179 
180  int idx = 0;
181  mX = coordinates[idx++].toDouble();
182  mY = coordinates[idx++].toDouble();
183  if ( is3D() && coordinates.length() > 2 )
184  mZ = coordinates[idx++].toDouble();
185  if ( isMeasure() && coordinates.length() > 2 + is3D() )
186  mM = coordinates[idx++].toDouble();
187 
188  return true;
189 }
190 
191 /***************************************************************************
192  * This class is considered CRITICAL and any change MUST be accompanied with
193  * full unit tests.
194  * See details in QEP #17
195  ****************************************************************************/
196 
197 QByteArray QgsPoint::asWkb() const
198 {
199  int binarySize = sizeof( char ) + sizeof( quint32 );
200  binarySize += ( 2 + is3D() + isMeasure() ) * sizeof( double );
201 
202  QByteArray wkbArray;
203  wkbArray.resize( binarySize );
204  QgsWkbPtr wkb( wkbArray );
205  wkb << static_cast<char>( QgsApplication::endian() );
206  wkb << static_cast<quint32>( wkbType() );
207  wkb << mX << mY;
208  if ( is3D() )
209  {
210  wkb << mZ;
211  }
212  if ( isMeasure() )
213  {
214  wkb << mM;
215  }
216  return wkbArray;
217 }
218 
219 QString QgsPoint::asWkt( int precision ) const
220 {
221  QString wkt = wktTypeStr() + " (";
222  wkt += qgsDoubleToString( mX, precision ) + ' ' + qgsDoubleToString( mY, precision );
223  if ( is3D() )
224  wkt += ' ' + qgsDoubleToString( mZ, precision );
225  if ( isMeasure() )
226  wkt += ' ' + qgsDoubleToString( mM, precision );
227  wkt += ')';
228  return wkt;
229 }
230 
231 QDomElement QgsPoint::asGML2( QDomDocument &doc, int precision, const QString &ns ) const
232 {
233  QDomElement elemPoint = doc.createElementNS( ns, QStringLiteral( "Point" ) );
234  QDomElement elemCoordinates = doc.createElementNS( ns, QStringLiteral( "coordinates" ) );
235 
236  // coordinate separator
237  QString cs = ",";
238  // tupel separator
239  QString ts = " ";
240 
241  elemCoordinates.setAttribute( "cs", cs );
242  elemCoordinates.setAttribute( "ts", ts );
243 
244  QString strCoordinates = qgsDoubleToString( mX, precision ) + cs + qgsDoubleToString( mY, precision );
245  elemCoordinates.appendChild( doc.createTextNode( strCoordinates ) );
246  elemPoint.appendChild( elemCoordinates );
247  return elemPoint;
248 }
249 
250 QDomElement QgsPoint::asGML3( QDomDocument &doc, int precision, const QString &ns ) const
251 {
252  QDomElement elemPoint = doc.createElementNS( ns, QStringLiteral( "Point" ) );
253  QDomElement elemPosList = doc.createElementNS( ns, QStringLiteral( "pos" ) );
254  elemPosList.setAttribute( QStringLiteral( "srsDimension" ), is3D() ? 3 : 2 );
255  QString strCoordinates = qgsDoubleToString( mX, precision ) + ' ' + qgsDoubleToString( mY, precision );
256  if ( is3D() )
257  strCoordinates += ' ' + qgsDoubleToString( mZ, precision );
258 
259  elemPosList.appendChild( doc.createTextNode( strCoordinates ) );
260  elemPoint.appendChild( elemPosList );
261  return elemPoint;
262 }
263 
264 /***************************************************************************
265  * This class is considered CRITICAL and any change MUST be accompanied with
266  * full unit tests.
267  * See details in QEP #17
268  ****************************************************************************/
269 
270 QString QgsPoint::asJSON( int precision ) const
271 {
272  return "{\"type\": \"Point\", \"coordinates\": ["
273  + qgsDoubleToString( mX, precision ) + ", " + qgsDoubleToString( mY, precision )
274  + "]}";
275 }
276 
277 void QgsPoint::draw( QPainter &p ) const
278 {
279  p.drawRect( mX - 2, mY - 2, 4, 4 );
280 }
281 
283 {
284  mX = mY = 0.;
285  if ( is3D() )
286  mZ = 0.;
287  else
288  mZ = std::numeric_limits<double>::quiet_NaN();
289 
290  if ( isMeasure() )
291  mM = 0.;
292  else
293  mM = std::numeric_limits<double>::quiet_NaN();
294 
295  clearCache();
296 }
297 
299 {
300  clearCache();
301  if ( transformZ )
302  {
303  ct.transformInPlace( mX, mY, mZ, d );
304  }
305  else
306  {
307  double z = 0.0;
308  ct.transformInPlace( mX, mY, z, d );
309  }
310 }
311 
313 {
315 
316  cs.append( QgsRingSequence() );
317  cs.back().append( QgsPointSequence() << QgsPoint( *this ) );
318 
319  return cs;
320 }
321 
323 {
324  return nullptr;
325 }
326 
327 /***************************************************************************
328  * This class is considered CRITICAL and any change MUST be accompanied with
329  * full unit tests.
330  * See details in QEP #17
331  ****************************************************************************/
332 
333 bool QgsPoint::moveVertex( QgsVertexId position, const QgsPoint &newPos )
334 {
335  Q_UNUSED( position );
336  clearCache();
337  mX = newPos.mX;
338  mY = newPos.mY;
339  if ( is3D() && newPos.is3D() )
340  {
341  mZ = newPos.mZ;
342  }
343  if ( isMeasure() && newPos.isMeasure() )
344  {
345  mM = newPos.mM;
346  }
347  return true;
348 }
349 
350 double QgsPoint::closestSegment( const QgsPoint &pt, QgsPoint &segmentPt, QgsVertexId &vertexAfter, bool *leftOf, double epsilon ) const
351 {
352  Q_UNUSED( pt );
353  Q_UNUSED( segmentPt );
354  Q_UNUSED( vertexAfter );
355  Q_UNUSED( leftOf );
356  Q_UNUSED( epsilon );
357  return -1; // no segments - return error
358 }
359 
360 bool QgsPoint::nextVertex( QgsVertexId &id, QgsPoint &vertex ) const
361 {
362  if ( id.vertex < 0 )
363  {
364  id.vertex = 0;
365  if ( id.part < 0 )
366  {
367  id.part = 0;
368  }
369  if ( id.ring < 0 )
370  {
371  id.ring = 0;
372  }
373  vertex = *this;
374  return true;
375  }
376  else
377  {
378  return false;
379  }
380 }
381 
382 /***************************************************************************
383  * This class is considered CRITICAL and any change MUST be accompanied with
384  * full unit tests.
385  * See details in QEP #17
386  ****************************************************************************/
387 
388 bool QgsPoint::addZValue( double zValue )
389 {
390  if ( QgsWkbTypes::hasZ( mWkbType ) )
391  return false;
392 
394  mZ = zValue;
395  clearCache();
396  return true;
397 }
398 
399 bool QgsPoint::addMValue( double mValue )
400 {
401  if ( QgsWkbTypes::hasM( mWkbType ) )
402  return false;
403 
405  mM = mValue;
406  clearCache();
407  return true;
408 }
409 
410 void QgsPoint::transform( const QTransform &t )
411 {
412  clearCache();
413  qreal x, y;
414  t.map( mX, mY, &x, &y );
415  mX = x;
416  mY = y;
417 }
418 
419 
421 {
422  if ( !is3D() )
423  return false;
424 
426  mZ = std::numeric_limits<double>::quiet_NaN();
427  clearCache();
428  return true;
429 }
430 
432 {
433  if ( !isMeasure() )
434  return false;
435 
437  mM = std::numeric_limits<double>::quiet_NaN();
438  clearCache();
439  return true;
440 }
441 
443 {
444  if ( type == mWkbType )
445  return true;
446 
447  clearCache();
448 
449  switch ( type )
450  {
451  case QgsWkbTypes::Point:
452  mZ = std::numeric_limits<double>::quiet_NaN();
453  mM = std::numeric_limits<double>::quiet_NaN();
454  mWkbType = type;
455  return true;
456  case QgsWkbTypes::PointZ:
458  mM = std::numeric_limits<double>::quiet_NaN();
459  mWkbType = type;
460  return true;
461  case QgsWkbTypes::PointM:
462  mZ = std::numeric_limits<double>::quiet_NaN();
463  mWkbType = type;
464  return true;
466  mWkbType = type;
467  return true;
468  default:
469  break;
470  }
471 
472  return false;
473 }
474 
475 
476 QPointF QgsPoint::toQPointF() const
477 {
478  return QPointF( mX, mY );
479 }
480 
481 double QgsPoint::distance( double x, double y ) const
482 {
483  return std::sqrt( ( mX - x ) * ( mX - x ) + ( mY - y ) * ( mY - y ) );
484 }
485 
486 double QgsPoint::distance( const QgsPoint &other ) const
487 {
488  return std::sqrt( ( mX - other.x() ) * ( mX - other.x() ) + ( mY - other.y() ) * ( mY - other.y() ) );
489 }
490 
491 double QgsPoint::distanceSquared( double x, double y ) const
492 {
493  return ( mX - x ) * ( mX - x ) + ( mY - y ) * ( mY - y );
494 }
495 
496 double QgsPoint::distanceSquared( const QgsPoint &other ) const
497 {
498  return ( mX - other.x() ) * ( mX - other.x() ) + ( mY - other.y() ) * ( mY - other.y() ) ;
499 }
500 
501 double QgsPoint::distance3D( double x, double y, double z ) const
502 {
503  double zDistSquared = 0.0;
504  if ( is3D() || !std::isnan( z ) )
505  zDistSquared = ( mZ - z ) * ( mZ - z );
506 
507  return std::sqrt( ( mX - x ) * ( mX - x ) + ( mY - y ) * ( mY - y ) + zDistSquared );
508 }
509 
510 double QgsPoint::distance3D( const QgsPoint &other ) const
511 {
512  double zDistSquared = 0.0;
513  if ( is3D() || other.is3D() )
514  zDistSquared = ( mZ - other.z() ) * ( mZ - other.z() );
515 
516  return std::sqrt( ( mX - other.x() ) * ( mX - other.x() ) + ( mY - other.y() ) * ( mY - other.y() ) + zDistSquared );
517 }
518 
519 double QgsPoint::distanceSquared3D( double x, double y, double z ) const
520 {
521  double zDistSquared = 0.0;
522  if ( is3D() || !std::isnan( z ) )
523  zDistSquared = ( mZ - z ) * ( mZ - z );
524 
525  return ( mX - x ) * ( mX - x ) + ( mY - y ) * ( mY - y ) + zDistSquared;
526 }
527 
528 double QgsPoint::distanceSquared3D( const QgsPoint &other ) const
529 {
530  double zDistSquared = 0.0;
531  if ( is3D() || other.is3D() )
532  zDistSquared = ( mZ - other.z() ) * ( mZ - other.z() );
533 
534  return ( mX - other.x() ) * ( mX - other.x() ) + ( mY - other.y() ) * ( mY - other.y() ) + zDistSquared;
535 }
536 
537 double QgsPoint::azimuth( const QgsPoint &other ) const
538 {
539  double dx = other.x() - mX;
540  double dy = other.y() - mY;
541  return ( std::atan2( dx, dy ) * 180.0 / M_PI );
542 }
543 
544 double QgsPoint::inclination( const QgsPoint &other ) const
545 {
546  double distance = distance3D( other );
547  if ( qgsDoubleNear( distance, 0.0 ) )
548  {
549  return 90.0;
550  }
551  double dz = other.z() - mZ;
552 
553  return ( std::acos( dz / distance ) * 180.0 / M_PI );
554 }
555 
556 QgsPoint QgsPoint::project( double distance, double azimuth, double inclination ) const
557 {
558  QgsWkbTypes::Type pType = mWkbType;
559  double radsXy = azimuth * M_PI / 180.0;
560  double dx = 0.0, dy = 0.0, dz = 0.0;
561 
562  inclination = std::fmod( inclination, 360.0 );
563 
564  if ( !qgsDoubleNear( inclination, 90.0 ) )
565  pType = QgsWkbTypes::addZ( pType );
566 
567  if ( !is3D() && qgsDoubleNear( inclination, 90.0 ) )
568  {
569  dx = distance * std::sin( radsXy );
570  dy = distance * std::cos( radsXy );
571  }
572  else
573  {
574  double radsZ = inclination * M_PI / 180.0;
575  dx = distance * std::sin( radsZ ) * std::sin( radsXy );
576  dy = distance * std::sin( radsZ ) * std::cos( radsXy );
577  dz = distance * std::cos( radsZ );
578  }
579 
580  return QgsPoint( mX + dx, mY + dy, mZ + dz, mM, pType );
581 }
bool isMeasure() const
Returns true if the geometry contains m values.
virtual QgsAbstractGeometry * boundary() const override
Returns the closure of the combinatorial boundary of the geometry (ie the topological boundary of the...
Definition: qgspoint.cpp:322
void draw(QPainter &p) const override
Draws the geometry using the specified QPainter.
Definition: qgspoint.cpp:277
double y
Definition: qgspoint.h:41
virtual bool addZValue(double zValue=0) override
Adds a z-dimension to the geometry, initialized to a preset value.
Definition: qgspoint.cpp:388
QPointF toQPointF() const
Returns the point as a QPointF.
Definition: qgspoint.cpp:476
virtual bool fromWkb(QgsConstWkbPtr &wkb) override
Sets the geometry from a WKB string.
Definition: qgspoint.cpp:121
static QPair< QgsWkbTypes::Type, QString > wktReadBlock(const QString &wkt)
Parses a WKT block of the format "TYPE( contents )" and returns a pair of geometry type to contents (...
double ANALYSIS_EXPORT leftOf(QgsPoint *thepoint, QgsPoint *p1, QgsPoint *p2)
Returns whether &#39;thepoint&#39; is left or right of the line from &#39;p1&#39; to &#39;p2&#39;. Negativ values mean left a...
Definition: MathUtils.cpp:292
double distance(double x, double y) const
Returns the distance between this point and a specified x, y coordinate.
Definition: qgspoint.cpp:481
double azimuth(const QgsPoint &other) const
Calculates azimuth between this point and other one (clockwise in degree, starting from north) ...
Definition: qgspoint.cpp:537
A class to represent a 2D point.
Definition: qgspointxy.h:42
TransformDirection
Enum used to indicate the direction (forward or inverse) of the transform.
static endian_t endian()
Returns whether this machine uses big or little endian.
double inclination(const QgsPoint &other) const
Calculates inclination between this point and other one (starting from zenith = 0 to nadir = 180...
Definition: qgspoint.cpp:544
void clear() override
Clears the geometry, ie reset it to a null geometry.
Definition: qgspoint.cpp:282
static bool hasZ(Type type)
Tests whether a WKB type contains the z-dimension.
Definition: qgswkbtypes.h:755
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
Compare two doubles (but allow some difference)
Definition: qgis.h:210
static Type dropM(Type type)
Drops the m dimension (if present) for a WKB type and returns the new type.
Definition: qgswkbtypes.h:920
bool operator!=(const QgsPoint &pt) const
Definition: qgspoint.cpp:111
QgsWkbTypes::Type mWkbType
double y() const
Returns the point&#39;s y-coordinate.
Definition: qgspoint.h:130
virtual bool dropZValue() override
Drops any z-dimensions which exist in the geometry.
Definition: qgspoint.cpp:420
virtual bool moveVertex(QgsVertexId position, const QgsPoint &newPos) override
Moves a vertex within the geometry.
Definition: qgspoint.cpp:333
QString wktTypeStr() const
Returns the WKT type string of the geometry.
QString asJSON(int precision=17) const override
Returns a GeoJSON representation of the geometry.
Definition: qgspoint.cpp:270
Type
The WKB type describes the number of dimensions a geometry has.
Definition: qgswkbtypes.h:66
virtual bool dropMValue() override
Drops any measure values which exist in the geometry.
Definition: qgspoint.cpp:431
virtual void clearCache() const
Clears any cached parameters associated with the geometry, e.g., bounding boxes.
static Type addM(Type type)
Adds the m dimension to a WKB type and returns the new type.
Definition: qgswkbtypes.h:873
QDomElement asGML2(QDomDocument &doc, int precision=17, const QString &ns="gml") const override
Returns a GML2 representation of the geometry.
Definition: qgspoint.cpp:231
Utility class for identifying a unique vertex within a geometry.
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
Definition: qgis.h:198
QString asWkt(int precision=17) const override
Returns a WKT representation of the geometry.
Definition: qgspoint.cpp:219
static Type addZ(Type type)
Adds the z dimension to a WKB type and returns the new type.
Definition: qgswkbtypes.h:849
virtual QgsPoint * clone() const override
Clones the geometry by performing a deep copy.
Definition: qgspoint.cpp:116
double & rx()
Returns a reference to the x-coordinate of this point.
Definition: qgspoint.h:150
Abstract base class for all geometries.
bool nextVertex(QgsVertexId &id, QgsPoint &vertex) const override
Returns next vertex id and coordinates.
Definition: qgspoint.cpp:360
double distanceSquared3D(double x, double y, double z) const
Returns the 3D squared distance between this point a specified x, y, z coordinate.
Definition: qgspoint.cpp:519
QgsWkbTypes::Type wkbType() const
Returns the WKB type of the geometry.
QgsPoint project(double distance, double azimuth, double inclination=90.0) const
Returns a new point which correspond to this point projected by a specified distance with specified a...
Definition: qgspoint.cpp:556
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:36
double m() const
Returns the point&#39;s m value.
Definition: qgspoint.h:142
bool operator==(const QgsPoint &pt) const
Definition: qgspoint.cpp:96
virtual bool fromWkt(const QString &wkt) override
Sets the geometry from a WKT string.
Definition: qgspoint.cpp:149
static Type dropZ(Type type)
Drops the z dimension (if present) for a WKB type and returns the new type.
Definition: qgswkbtypes.h:903
QDomElement asGML3(QDomDocument &doc, int precision=17, const QString &ns="gml") const override
Returns a GML3 representation of the geometry.
Definition: qgspoint.cpp:250
QByteArray asWkb() const override
Returns a WKB representation of the geometry.
Definition: qgspoint.cpp:197
QgsPoint(double x=0.0, double y=0.0, double z=std::numeric_limits< double >::quiet_NaN(), double m=std::numeric_limits< double >::quiet_NaN(), QgsWkbTypes::Type wkbType=QgsWkbTypes::Unknown)
Construct a point with the provided initial coordinate values.
Definition: qgspoint.cpp:34
QList< QgsPointSequence > QgsRingSequence
bool convertTo(QgsWkbTypes::Type type) override
Converts the geometry to a specified type.
Definition: qgspoint.cpp:442
Class for doing transforms between two map coordinate systems.
virtual bool addMValue(double mValue=0) override
Adds a measure to the geometry, initialized to a preset value.
Definition: qgspoint.cpp:399
double z
Definition: qgspoint.h:42
double z() const
Returns the point&#39;s z-coordinate.
Definition: qgspoint.h:136
virtual QgsCoordinateSequence coordinateSequence() const override
Retrieves the sequence of geometries, rings and nodes.
Definition: qgspoint.cpp:312
static bool hasM(Type type)
Tests whether a WKB type contains m values.
Definition: qgswkbtypes.h:804
QList< QgsRingSequence > QgsCoordinateSequence
double distanceSquared(double x, double y) const
Returns the squared distance between this point a specified x, y coordinate.
Definition: qgspoint.cpp:491
QList< QgsPoint > QgsPointSequence
void transformInPlace(double &x, double &y, double &z, TransformDirection direction=ForwardTransform) const
Transforms an array of x, y and z double coordinates in place, from the source CRS to the destination...
static Type flatType(Type type)
Returns the flat type for a WKB type.
Definition: qgswkbtypes.h:423
QgsWkbTypes::Type readHeader() const
readHeader
Definition: qgswkbptr.cpp:53
bool is3D() const
Returns true if the geometry is 3D and contains a z-value.
virtual double closestSegment(const QgsPoint &pt, QgsPoint &segmentPt, QgsVertexId &vertexAfter, bool *leftOf, double epsilon) const override
Searches for the closest segment of the geometry to a given point.
Definition: qgspoint.cpp:350
void transform(const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection d=QgsCoordinateTransform::ForwardTransform, bool transformZ=false) override
Transforms the geometry using a coordinate transform.
Definition: qgspoint.cpp:298
double distance3D(double x, double y, double z) const
Returns the 3D distance between this point and a specified x, y, z coordinate.
Definition: qgspoint.cpp:501
double x() const
Returns the point&#39;s x-coordinate.
Definition: qgspoint.h:124
double m
Definition: qgspoint.h:43
double x
Definition: qgspoint.h:40