QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
qgsgeometrycollectionv2.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsgeometrycollectionv2.cpp
3  -------------------------------------------------------------------
4 Date : 28 Oct 2014
5 Copyright : (C) 2014 by Marco Hugentobler
6 email : marco.hugentobler at sourcepole dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
17 #include "qgsapplication.h"
18 #include "qgsgeometryfactory.h"
19 #include "qgsgeometryutils.h"
20 #include "qgscircularstringv2.h"
21 #include "qgscompoundcurvev2.h"
22 #include "qgslinestringv2.h"
23 #include "qgsmultilinestringv2.h"
24 #include "qgspointv2.h"
25 #include "qgsmultipointv2.h"
26 #include "qgspolygonv2.h"
27 #include "qgsmultipolygonv2.h"
28 #include "qgswkbptr.h"
29 
31 {
33 }
34 
36 {
37  int nGeoms = c.mGeometries.size();
38  mGeometries.resize( nGeoms );
39  for ( int i = 0; i < nGeoms; ++i )
40  {
41  mGeometries[i] = c.mGeometries.at( i )->clone();
42  }
43 }
44 
46 {
47  if ( &c != this )
48  {
49  clearCache();
51  int nGeoms = c.mGeometries.size();
52  mGeometries.resize( nGeoms );
53  for ( int i = 0; i < nGeoms; ++i )
54  {
55  mGeometries[i] = c.mGeometries.at( i )->clone();
56  }
57  }
58  return *this;
59 }
60 
62 {
63  clear();
64 }
65 
67 {
68  return new QgsGeometryCollectionV2( *this );
69 }
70 
72 {
73  qDeleteAll( mGeometries );
75  clearCache(); //set bounding box invalid
76 }
77 
79 {
80  return nullptr;
81 }
82 
84 {
85  return mGeometries.size();
86 }
87 
89 {
90  return mGeometries.value( n );
91 }
92 
94 {
95  clearCache();
96  return mGeometries.value( n );
97 }
98 
100 {
101  if ( !g )
102  {
103  return false;
104  }
105 
106  mGeometries.append( g );
107  clearCache(); //set bounding box invalid
108  return true;
109 }
110 
112 {
113  if ( !g )
114  {
115  return false;
116  }
117 
118  mGeometries.insert( index, g );
119  clearCache(); //set bounding box invalid
120  return true;
121 }
122 
124 {
125  if ( nr >= mGeometries.size() || nr < 0 )
126  {
127  return false;
128  }
129  delete mGeometries.at( nr );
130  mGeometries.remove( nr );
131  clearCache(); //set bounding box invalid
132  return true;
133 }
134 
136 {
137  int maxDim = 0;
139  for ( ; it != mGeometries.constEnd(); ++it )
140  {
141  int dim = ( *it )->dimension();
142  if ( dim > maxDim )
143  {
144  maxDim = dim;
145  }
146  }
147  return maxDim;
148 }
149 
151 {
152  Q_FOREACH ( QgsAbstractGeometryV2* g, mGeometries )
153  {
154  g->transform( ct, d, transformZ );
155  }
156  clearCache(); //set bounding box invalid
157 }
158 
160 {
161  Q_FOREACH ( QgsAbstractGeometryV2* g, mGeometries )
162  {
163  g->transform( t );
164  }
165  clearCache(); //set bounding box invalid
166 }
167 
168 #if 0
169 void QgsGeometryCollectionV2::clip( const QgsRectangle& rect )
170 {
172  for ( ; it != mGeometries.end(); ++it )
173  {
174  ( *it )->clip( rect );
175  }
176 }
177 #endif
178 
180 {
182  for ( ; it != mGeometries.constEnd(); ++it )
183  {
184  ( *it )->draw( p );
185  }
186 }
187 
189 {
190  if ( !wkbPtr )
191  {
192  return false;
193  }
194 
195  mWkbType = wkbPtr.readHeader();
196 
197  int nGeometries = 0;
198  wkbPtr >> nGeometries;
199 
200  QVector<QgsAbstractGeometryV2*> geometryListBackup = mGeometries;
201  mGeometries.clear();
202  for ( int i = 0; i < nGeometries; ++i )
203  {
205  if ( geom )
206  {
207  if ( !addGeometry( geom ) )
208  {
209  qDeleteAll( mGeometries );
210  mGeometries = geometryListBackup;
211  return false;
212  }
213  wkbPtr += geom->wkbSize();
214  }
215  }
216  qDeleteAll( geometryListBackup );
217 
218  clearCache(); //set bounding box invalid
219 
220  return true;
221 }
222 
224 {
227  << new QgsCurvePolygonV2
230  << new QgsMultiCurveV2 << new QgsMultiSurfaceV2, "GeometryCollection" );
231 }
232 
234 {
235  int size = sizeof( char ) + sizeof( quint32 ) + sizeof( quint32 );
236  Q_FOREACH ( const QgsAbstractGeometryV2 *geom, mGeometries )
237  {
238  if ( geom )
239  {
240  size += geom->wkbSize();
241  }
242  }
243  return size;
244 }
245 
246 unsigned char* QgsGeometryCollectionV2::asWkb( int& binarySize ) const
247 {
248  binarySize = wkbSize();
249  unsigned char* geomPtr = new unsigned char[binarySize];
250  QgsWkbPtr wkb( geomPtr, binarySize );
251  wkb << static_cast<char>( QgsApplication::endian() );
252  wkb << static_cast<quint32>( wkbType() );
253  wkb << static_cast<quint32>( mGeometries.size() );
254  Q_FOREACH ( const QgsAbstractGeometryV2 *geom, mGeometries )
255  {
256  int geomWkbLen = 0;
257  if ( geom )
258  {
259  unsigned char* geomWkb = geom->asWkb( geomWkbLen );
260  memcpy( wkb, geomWkb, geomWkbLen );
261  wkb += geomWkbLen;
262  delete[] geomWkb;
263  }
264  }
265  return geomPtr;
266 }
267 
269 {
270  QString wkt = wktTypeStr() + " (";
271  Q_FOREACH ( const QgsAbstractGeometryV2 *geom, mGeometries )
272  {
273  QString childWkt = geom->asWkt( precision );
274  if ( wktOmitChildType() )
275  {
276  childWkt = childWkt.mid( childWkt.indexOf( '(' ) );
277  }
278  wkt += childWkt + ',';
279  }
280  if ( wkt.endsWith( ',' ) )
281  {
282  wkt.chop( 1 ); // Remove last ','
283  }
284  wkt += ')';
285  return wkt;
286 }
287 
288 QDomElement QgsGeometryCollectionV2::asGML2( QDomDocument& doc, int precision, const QString& ns ) const
289 {
290  QDomElement elemMultiGeometry = doc.createElementNS( ns, "MultiGeometry" );
291  Q_FOREACH ( const QgsAbstractGeometryV2 *geom, mGeometries )
292  {
293  QDomElement elemGeometryMember = doc.createElementNS( ns, "geometryMember" );
294  elemGeometryMember.appendChild( geom->asGML2( doc, precision, ns ) );
295  elemMultiGeometry.appendChild( elemGeometryMember );
296  }
297  return elemMultiGeometry;
298 }
299 
300 QDomElement QgsGeometryCollectionV2::asGML3( QDomDocument& doc, int precision, const QString& ns ) const
301 {
302  QDomElement elemMultiGeometry = doc.createElementNS( ns, "MultiGeometry" );
303  Q_FOREACH ( const QgsAbstractGeometryV2 *geom, mGeometries )
304  {
305  QDomElement elemGeometryMember = doc.createElementNS( ns, "geometryMember" );
306  elemGeometryMember.appendChild( geom->asGML3( doc, precision, ns ) );
307  elemMultiGeometry.appendChild( elemGeometryMember );
308  }
309  return elemMultiGeometry;
310 }
311 
313 {
314  QString json = "{\"type\": \"GeometryCollection\", \"geometries\": [";
315  Q_FOREACH ( const QgsAbstractGeometryV2 *geom, mGeometries )
316  {
317  json += geom->asJSON( precision ) + ", ";
318  }
319  if ( json.endsWith( ", " ) )
320  {
321  json.chop( 2 ); // Remove last ", "
322  }
323  json += "] }";
324  return json;
325 }
326 
328 {
329  if ( mBoundingBox.isNull() )
330  {
331  mBoundingBox = calculateBoundingBox();
332  }
333  return mBoundingBox;
334 }
335 
337 {
338  if ( mGeometries.size() < 1 )
339  {
340  return QgsRectangle();
341  }
342 
343  QgsRectangle bbox = mGeometries.at( 0 )->boundingBox();
344  for ( int i = 1; i < mGeometries.size(); ++i )
345  {
346  QgsRectangle geomBox = mGeometries.at( i )->boundingBox();
347  bbox.combineExtentWith( geomBox );
348  }
349  return bbox;
350 }
351 
353 {
354  if ( !mCoordinateSequence.isEmpty() )
355  return mCoordinateSequence;
356 
358  for ( ; geomIt != mGeometries.constEnd(); ++geomIt )
359  {
360  QgsCoordinateSequenceV2 geomCoords = ( *geomIt )->coordinateSequence();
361 
363  for ( ; cIt != geomCoords.constEnd(); ++cIt )
364  {
365  mCoordinateSequence.push_back( *cIt );
366  }
367  }
368 
369  return mCoordinateSequence;
370 }
371 
373 {
374  if ( !mCoordinateSequence.isEmpty() )
376 
377  int count = 0;
378 
380  for ( ; geomIt != mGeometries.constEnd(); ++geomIt )
381  {
382  count += ( *geomIt )->nCoordinates();
383  }
384 
385  return count;
386 }
387 
388 double QgsGeometryCollectionV2::closestSegment( const QgsPointV2& pt, QgsPointV2& segmentPt, QgsVertexId& vertexAfter, bool* leftOf, double epsilon ) const
389 {
390  return QgsGeometryUtils::closestSegmentFromComponents( mGeometries, QgsGeometryUtils::PART, pt, segmentPt, vertexAfter, leftOf, epsilon );
391 }
392 
394 {
395  if ( id.part < 0 )
396  {
397  id.part = 0;
398  id.ring = -1;
399  id.vertex = -1;
400  }
401  if ( mGeometries.isEmpty() )
402  {
403  return false;
404  }
405 
406  QgsAbstractGeometryV2* geom = mGeometries.at( id.part );
407  if ( geom->nextVertex( id, vertex ) )
408  {
409  return true;
410  }
411  if (( id.part + 1 ) >= numGeometries() )
412  {
413  return false;
414  }
415  ++id.part;
416  id.ring = -1;
417  id.vertex = -1;
418  return mGeometries.at( id.part )->nextVertex( id, vertex );
419 }
420 
422 {
423  if ( position.part >= mGeometries.size() )
424  {
425  return false;
426  }
427 
428  bool success = mGeometries.at( position.part )->insertVertex( position, vertex );
429  if ( success )
430  {
431  clearCache(); //set bounding box invalid
432  }
433  return success;
434 }
435 
437 {
438  if ( position.part >= mGeometries.size() )
439  {
440  return false;
441  }
442 
443  bool success = mGeometries.at( position.part )->moveVertex( position, newPos );
444  if ( success )
445  {
446  clearCache(); //set bounding box invalid
447  }
448  return success;
449 }
450 
452 {
453  if ( position.part >= mGeometries.size() )
454  {
455  return false;
456  }
457 
458  QgsAbstractGeometryV2* geom = mGeometries.at( position.part );
459  if ( !geom )
460  {
461  return false;
462  }
463 
464  bool success = geom->deleteVertex( position );
465 
466  //remove geometry if no vertices left
467  if ( geom->isEmpty() )
468  {
469  removeGeometry( position.part );
470  }
471 
472  if ( success )
473  {
474  clearCache(); //set bounding box invalid
475  }
476  return success;
477 }
478 
480 {
481  double length = 0.0;
483  for ( ; geomIt != mGeometries.constEnd(); ++geomIt )
484  {
485  length += ( *geomIt )->length();
486  }
487  return length;
488 }
489 
491 {
492  double area = 0.0;
494  for ( ; geomIt != mGeometries.constEnd(); ++geomIt )
495  {
496  area += ( *geomIt )->area();
497  }
498  return area;
499 }
500 
502 {
503  double perimeter = 0.0;
505  for ( ; geomIt != mGeometries.constEnd(); ++geomIt )
506  {
507  perimeter += ( *geomIt )->perimeter();
508  }
509  return perimeter;
510 }
511 
512 bool QgsGeometryCollectionV2::fromCollectionWkt( const QString &wkt, const QList<QgsAbstractGeometryV2*>& subtypes, const QString& defaultChildWkbType )
513 {
514  clear();
515 
517 
518  if ( QgsWKBTypes::flatType( parts.first ) != QgsWKBTypes::flatType( wkbType() ) )
519  return false;
520  mWkbType = parts.first;
521 
522  QString defChildWkbType = QString( "%1%2%3 " ).arg( defaultChildWkbType, is3D() ? "Z" : "", isMeasure() ? "M" : "" );
523 
524  Q_FOREACH ( const QString& childWkt, QgsGeometryUtils::wktGetChildBlocks( parts.second, defChildWkbType ) )
525  {
527 
528  bool success = false;
529  Q_FOREACH ( const QgsAbstractGeometryV2* geom, subtypes )
530  {
531  if ( QgsWKBTypes::flatType( childParts.first ) == QgsWKBTypes::flatType( geom->wkbType() ) )
532  {
533  mGeometries.append( geom->clone() );
534  if ( mGeometries.back()->fromWkt( childWkt ) )
535  {
536  success = true;
537  break;
538  }
539  }
540  }
541  if ( !success )
542  {
543  clear();
544  qDeleteAll( subtypes );
545  return false;
546  }
547  }
548  qDeleteAll( subtypes );
549 
550  //scan through geometries and check if dimensionality of geometries is different to collection.
551  //if so, update the type dimensionality of the collection to match
552  bool hasZ = false;
553  bool hasM = false;
554  Q_FOREACH ( QgsAbstractGeometryV2* geom, mGeometries )
555  {
556  hasZ = hasZ || geom->is3D();
557  hasM = hasM || geom->isMeasure();
558  if ( hasZ && hasM )
559  break;
560  }
561  if ( hasZ )
562  addZValue( 0 );
563  if ( hasM )
564  addMValue( 0 );
565 
566  return true;
567 }
568 
570 {
572  for ( ; it != mGeometries.constEnd(); ++it )
573  {
574  if (( *it )->hasCurvedSegments() )
575  {
576  return true;
577  }
578  }
579  return false;
580 }
581 
583 {
585  QgsGeometryCollectionV2* geomCollection = dynamic_cast<QgsGeometryCollectionV2*>( geom );
586  if ( !geomCollection )
587  {
588  delete geom;
589  return clone();
590  }
591 
593  for ( ; geomIt != mGeometries.constEnd(); ++geomIt )
594  {
595  geomCollection->addGeometry(( *geomIt )->segmentize( tolerance, toleranceType ) );
596  }
597  return geomCollection;
598 }
599 
601 {
602  if ( vertex.part >= mGeometries.size() )
603  {
604  return 0.0;
605  }
606 
607  QgsAbstractGeometryV2* geom = mGeometries[vertex.part];
608  if ( !geom )
609  {
610  return 0.0;
611  }
612 
613  return geom->vertexAngle( vertex );
614 }
615 
617 {
618  if ( QgsWKBTypes::hasZ( mWkbType ) )
619  return false;
620 
622 
623  Q_FOREACH ( QgsAbstractGeometryV2* geom, mGeometries )
624  {
625  geom->addZValue( zValue );
626  }
627  clearCache();
628  return true;
629 }
630 
632 {
633  if ( QgsWKBTypes::hasM( mWkbType ) )
634  return false;
635 
637 
638  Q_FOREACH ( QgsAbstractGeometryV2* geom, mGeometries )
639  {
640  geom->addMValue( mValue );
641  }
642  clearCache();
643  return true;
644 }
645 
646 
648 {
649  if ( !is3D() )
650  return false;
651 
653  Q_FOREACH ( QgsAbstractGeometryV2* geom, mGeometries )
654  {
655  geom->dropZValue();
656  }
657  clearCache();
658  return true;
659 }
660 
662 {
663  if ( !isMeasure() )
664  return false;
665 
667  Q_FOREACH ( QgsAbstractGeometryV2* geom, mGeometries )
668  {
669  geom->dropMValue();
670  }
671  clearCache();
672  return true;
673 }
QString wktTypeStr() const
Returns the WKT type string of the geometry.
int indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const
static unsigned index
A rectangle specified with double values.
Definition: qgsrectangle.h:35
int numGeometries() const
Returns the number of geometries within the collection.
virtual QgsAbstractGeometryV2 * boundary() const override
Returns the closure of the combinatorial boundary of the geometry (ie the topological boundary of the...
virtual bool insertVertex(QgsVertexId position, const QgsPointV2 &vertex) override
Inserts a vertex into the geometry.
bool isEmpty() const
Returns true if the geometry is empty.
virtual bool dropMValue()=0
Drops any measure values which exist in the geometry.
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 (...
virtual bool insertGeometry(QgsAbstractGeometryV2 *g, int index)
Inserts a geometry before a specified index and takes ownership.
QgsGeometryCollectionV2 & operator=(const QgsGeometryCollectionV2 &c)
virtual QgsAbstractGeometryV2 & operator=(const QgsAbstractGeometryV2 &geom)
QDomNode appendChild(const QDomNode &newChild)
virtual QgsCoordinateSequenceV2 coordinateSequence() const override
Retrieves the sequence of geometries, rings and nodes.
void append(const T &value)
iterator begin()
void push_back(const T &value)
static Type addZ(Type type)
Adds the z dimension to a WKB type and returns the new type.
Definition: qgswkbtypes.h:757
static bool hasM(Type type)
Tests whether a WKB type contains m values.
Definition: qgswkbtypes.h:714
Circular string geometry type.
Multi curve geometry collection.
SegmentationToleranceType
Segmentation tolerance as maximum angle or maximum difference between approximation and circle...
const_iterator constEnd() const
TransformDirection
Enum used to indicate the direction (forward or inverse) of the transform.
virtual QString asJSON(int precision=17) const =0
Returns a GeoJSON representation of the geometry.
void insert(int i, const T &value)
Abstract base class for all geometries.
static QStringList wktGetChildBlocks(const QString &wkt, const QString &defaultType="")
Parses a WKT string and returns of list of blocks contained in the WKT.
static double closestSegmentFromComponents(T &container, componentType ctype, const QgsPointV2 &pt, QgsPointV2 &segmentPt, QgsVertexId &vertexAfter, bool *leftOf, double epsilon)
virtual bool dropZValue()=0
Drops any z-dimensions which exist in the geometry.
Multi point geometry collection.
QDomElement createElementNS(const QString &nsURI, const QString &qName)
static bool hasZ(Type type)
Tests whether a WKB type contains the z-dimension.
Definition: qgswkbtypes.h:667
QString asWkt(int precision=17) const override
Returns a WKT representation of the geometry.
virtual void clear() override
Clears the geometry, ie reset it to a null geometry.
static QgsAbstractGeometryV2 * geomFromWkb(QgsConstWkbPtr wkb)
Construct geometry from a WKB string.
void chop(int n)
static endian_t endian()
Returns whether this machine uses big or little endian.
Multi line string geometry collection.
virtual int wkbSize() const =0
Returns the size of the WKB representation of the geometry.
QDomElement asGML2(QDomDocument &doc, int precision=17, const QString &ns="gml") const override
Returns a GML2 representation of the geometry.
virtual bool wktOmitChildType() const
Returns whether child type names are omitted from Wkt representations of the collection.
reference back()
virtual bool addMValue(double mValue=0)=0
Adds a measure to the geometry, initialized to a preset value.
bool nextVertex(QgsVertexId &id, QgsPointV2 &vertex) const override
Returns next vertex id and coordinates.
T value(int i) const
Polygon geometry type.
Definition: qgspolygonv2.h:29
void clear()
unsigned char * asWkb(int &binarySize) const override
Returns a WKB representation of the geometry.
bool hasCurvedSegments() const override
Returns true if the geometry contains curved segments.
const QgsAbstractGeometryV2 * geometryN(int n) const
Returns a const reference to a geometry from within the collection.
static Type dropZ(Type type)
Drops the z dimension (if present) for a WKB type and returns the new type.
Definition: qgswkbtypes.h:811
QDomElement asGML3(QDomDocument &doc, int precision=17, const QString &ns="gml") const override
Returns a GML3 representation of the geometry.
static Type addM(Type type)
Adds the m dimension to a WKB type and returns the new type.
Definition: qgswkbtypes.h:781
void resize(int size)
int wkbSize() const override
Returns the size of the WKB representation of the geometry.
Utility class for identifying a unique vertex within a geometry.
Line string geometry type, with support for z-dimension and m-values.
bool isMeasure() const
Returns true if the geometry contains m values.
Point geometry type, with support for z-dimension and m-values.
Definition: qgspointv2.h:34
bool isEmpty() const
void remove(int i)
double vertexAngle(QgsVertexId vertex) const override
Returns approximate rotation angle for a vertex.
Multi surface geometry collection.
virtual unsigned char * asWkb(int &binarySize) const =0
Returns a WKB representation of the geometry.
bool endsWith(const QString &s, Qt::CaseSensitivity cs) const
virtual int nCoordinates() const override
Returns the number of nodes contained in the geometry.
virtual bool addZValue(double zValue=0)=0
Adds a z-dimension to the geometry, initialized to a preset value.
virtual QDomElement asGML3(QDomDocument &doc, int precision=17, const QString &ns="gml") const =0
Returns a GML3 representation of the geometry.
virtual bool nextVertex(QgsVertexId &id, QgsPointV2 &vertex) const =0
Returns next vertex id and coordinates.
virtual bool dropMValue() override
Drops any measure values which exist in the geometry.
static QgsAbstractGeometryV2 * geomFromWkbType(QgsWKBTypes::Type t)
Return empty geometry from wkb type.
virtual bool dropZValue() override
Drops any z-dimensions which exist in the geometry.
virtual double length() const override
Returns the length of the geometry.
QString asJSON(int precision=17) const override
Returns a GeoJSON representation of the geometry.
Compound curve geometry type.
virtual bool moveVertex(QgsVertexId position, const QgsPointV2 &newPos) override
Moves a vertex within the geometry.
virtual int nCoordinates() const
Returns the number of nodes contained in the geometry.
virtual double area() const override
Returns the area of the geometry.
virtual bool fromWkt(const QString &wkt) override
Sets the geometry from a WKT string.
void combineExtentWith(const QgsRectangle &rect)
expand the rectangle so that covers both the original rectangle and the given rectangle ...
virtual bool deleteVertex(QgsVertexId position) override
Deletes a vertex within the geometry.
QVector< QgsAbstractGeometryV2 *> mGeometries
virtual double vertexAngle(QgsVertexId vertex) const =0
Returns approximate angle at a vertex.
static Type dropM(Type type)
Drops the m dimension (if present) for a WKB type and returns the new type.
Definition: qgswkbtypes.h:828
virtual void clearCache() const override
Clears any cached parameters associated with the geometry, eg bounding boxes.
const T & at(int i) const
const_iterator constBegin() const
virtual bool addMValue(double mValue=0) override
Adds a measure to the geometry, initialized to a preset value.
bool fromCollectionWkt(const QString &wkt, const QList< QgsAbstractGeometryV2 *> &subtypes, const QString &defaultChildWkbType=QString())
Reads a collection from a WKT string.
virtual bool deleteVertex(QgsVertexId position)=0
Deletes a vertex within the geometry.
QString mid(int position, int n) const
virtual void transform(const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection d=QgsCoordinateTransform::ForwardTransform, bool transformZ=false) override
Transforms the geometry using a coordinate transform.
bool isEmpty() const
QgsWKBTypes::Type wkbType() const
Returns the WKB type of the geometry.
virtual QgsGeometryCollectionV2 * clone() const override
Clones the geometry by performing a deep copy.
virtual bool addGeometry(QgsAbstractGeometryV2 *g)
Adds a geometry and takes ownership.
virtual void draw(QPainter &p) const override
Draws the geometry using the specified QPainter.
bool isNull() const
test if the rectangle is null (all coordinates zero or after call to setMinimal()).
virtual double closestSegment(const QgsPointV2 &pt, QgsPointV2 &segmentPt, QgsVertexId &vertexAfter, bool *leftOf, double epsilon) const override
Searches for the closest segment of the geometry to a given point.
Class for doing transforms between two map coordinate systems.
virtual QString asWkt(int precision=17) const =0
Returns a WKT representation of the geometry.
virtual QgsRectangle boundingBox() const override
Returns the minimal bounding box for the geometry.
QgsAbstractGeometryV2 * segmentize(double tolerance=M_PI_2/90, SegmentationToleranceType toleranceType=MaximumAngle) const override
Returns a geometry without curves.
virtual bool removeGeometry(int nr)
Removes a geometry from the collection.
bool fromWkb(QgsConstWkbPtr wkb) override
Sets the geometry from a WKB string.
static Type flatType(Type type)
Returns the flat type for a WKB type.
Definition: qgswkbtypes.h:366
Multi polygon geometry collection.
virtual bool addZValue(double zValue=0) override
Adds a z-dimension to the geometry, initialized to a preset value.
double ANALYSIS_EXPORT leftOf(Point3D *thepoint, Point3D *p1, Point3D *p2)
Returns whether &#39;thepoint&#39; is left or right of the line from &#39;p1&#39; to &#39;p2&#39;.
Curve polygon geometry type.
QgsWKBTypes::Type readHeader() const
Definition: qgswkbptr.cpp:38
virtual QDomElement asGML2(QDomDocument &doc, int precision=17, const QString &ns="gml") const =0
Returns a GML2 representation of the geometry.
const_iterator constEnd() const
const_iterator constBegin() const
virtual QgsAbstractGeometryV2 * clone() const =0
Clones the geometry by performing a deep copy.
int size() const
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
iterator end()
virtual void transform(const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection d=QgsCoordinateTransform::ForwardTransform, bool transformZ=false)=0
Transforms the geometry using a coordinate transform.
bool is3D() const
Returns true if the geometry is 3D and contains a z-value.
virtual double perimeter() const override
Returns the perimeter of the geometry.
virtual QgsRectangle calculateBoundingBox() const override
Default calculator for the minimal bounding box for the geometry.
virtual int dimension() const override
Returns the inherent dimension of the geometry.