QGIS API Documentation  2.14.0-Essen
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 );
76  clearCache(); //set bounding box invalid
77 }
78 
80 {
81  return mGeometries.size();
82 }
83 
85 {
86  return mGeometries.value( n );
87 }
88 
90 {
91  clearCache();
92  return mGeometries.value( n );
93 }
94 
96 {
97  if ( !g )
98  {
99  return false;
100  }
101 
102  mGeometries.append( g );
103  clearCache(); //set bounding box invalid
104  return true;
105 }
106 
108 {
109  if ( !g )
110  {
111  return false;
112  }
113 
114  mGeometries.insert( index, g );
115  clearCache(); //set bounding box invalid
116  return true;
117 }
118 
120 {
121  if ( nr >= mGeometries.size() || nr < 0 )
122  {
123  return false;
124  }
125  delete mGeometries.at( nr );
126  mGeometries.remove( nr );
127  clearCache(); //set bounding box invalid
128  return true;
129 }
130 
132 {
133  int maxDim = 0;
135  for ( ; it != mGeometries.constEnd(); ++it )
136  {
137  int dim = ( *it )->dimension();
138  if ( dim > maxDim )
139  {
140  maxDim = dim;
141  }
142  }
143  return maxDim;
144 }
145 
147 {
148  Q_FOREACH ( QgsAbstractGeometryV2* g, mGeometries )
149  {
150  g->transform( ct, d );
151  }
152  clearCache(); //set bounding box invalid
153 }
154 
156 {
157  Q_FOREACH ( QgsAbstractGeometryV2* g, mGeometries )
158  {
159  g->transform( t );
160  }
161  clearCache(); //set bounding box invalid
162 }
163 
164 #if 0
165 void QgsGeometryCollectionV2::clip( const QgsRectangle& rect )
166 {
168  for ( ; it != mGeometries.end(); ++it )
169  {
170  ( *it )->clip( rect );
171  }
172 }
173 #endif
174 
176 {
178  for ( ; it != mGeometries.constEnd(); ++it )
179  {
180  ( *it )->draw( p );
181  }
182 }
183 
185 {
186  if ( !wkbPtr )
187  {
188  return false;
189  }
190 
191  mWkbType = wkbPtr.readHeader();
192 
193  int nGeometries = 0;
194  wkbPtr >> nGeometries;
195 
196  QList<QgsAbstractGeometryV2*> geometryList;
197  for ( int i = 0; i < nGeometries; ++i )
198  {
200  if ( geom )
201  {
202  geometryList.append( geom );
203  wkbPtr += geom->wkbSize();
204  }
205  }
206 
207  mGeometries.resize( geometryList.size() );
208  for ( int i = 0; i < geometryList.size(); ++i )
209  {
210  mGeometries[i] = geometryList.at( i );
211  }
212  clearCache(); //set bounding box invalid
213 
214  return true;
215 }
216 
218 {
222  << new QgsMultiPolygonV2 << new QgsGeometryCollectionV2, "GeometryCollection" );
223 }
224 
226 {
227  int size = sizeof( char ) + sizeof( quint32 ) + sizeof( quint32 );
228  Q_FOREACH ( const QgsAbstractGeometryV2 *geom, mGeometries )
229  {
230  if ( geom )
231  {
232  size += geom->wkbSize();
233  }
234  }
235  return size;
236 }
237 
238 unsigned char* QgsGeometryCollectionV2::asWkb( int& binarySize ) const
239 {
240  binarySize = wkbSize();
241  unsigned char* geomPtr = new unsigned char[binarySize];
242  QgsWkbPtr wkb( geomPtr, binarySize );
243  wkb << static_cast<char>( QgsApplication::endian() );
244  wkb << static_cast<quint32>( wkbType() );
245  wkb << static_cast<quint32>( mGeometries.size() );
246  Q_FOREACH ( const QgsAbstractGeometryV2 *geom, mGeometries )
247  {
248  int geomWkbLen = 0;
249  if ( geom )
250  {
251  unsigned char* geomWkb = geom->asWkb( geomWkbLen );
252  memcpy( wkb, geomWkb, geomWkbLen );
253  wkb += geomWkbLen;
254  delete[] geomWkb;
255  }
256  }
257  return geomPtr;
258 }
259 
261 {
262  QString wkt = wktTypeStr() + " (";
263  Q_FOREACH ( const QgsAbstractGeometryV2 *geom, mGeometries )
264  {
265  QString childWkt = geom->asWkt( precision );
266  if ( wktOmitChildType() )
267  {
268  childWkt = childWkt.mid( childWkt.indexOf( '(' ) );
269  }
270  wkt += childWkt + ',';
271  }
272  if ( wkt.endsWith( ',' ) )
273  {
274  wkt.chop( 1 ); // Remove last ','
275  }
276  wkt += ')';
277  return wkt;
278 }
279 
280 QDomElement QgsGeometryCollectionV2::asGML2( QDomDocument& doc, int precision, const QString& ns ) const
281 {
282  QDomElement elemMultiGeometry = doc.createElementNS( ns, "MultiGeometry" );
283  Q_FOREACH ( const QgsAbstractGeometryV2 *geom, mGeometries )
284  {
285  QDomElement elemGeometryMember = doc.createElementNS( ns, "geometryMember" );
286  elemGeometryMember.appendChild( geom->asGML2( doc, precision, ns ) );
287  elemMultiGeometry.appendChild( elemGeometryMember );
288  }
289  return elemMultiGeometry;
290 }
291 
292 QDomElement QgsGeometryCollectionV2::asGML3( QDomDocument& doc, int precision, const QString& ns ) const
293 {
294  QDomElement elemMultiGeometry = doc.createElementNS( ns, "MultiGeometry" );
295  Q_FOREACH ( const QgsAbstractGeometryV2 *geom, mGeometries )
296  {
297  QDomElement elemGeometryMember = doc.createElementNS( ns, "geometryMember" );
298  elemGeometryMember.appendChild( geom->asGML3( doc, precision, ns ) );
299  elemMultiGeometry.appendChild( elemGeometryMember );
300  }
301  return elemMultiGeometry;
302 }
303 
305 {
306  QString json = "{\"type\": \"GeometryCollection\", \"geometries\": [";
307  Q_FOREACH ( const QgsAbstractGeometryV2 *geom, mGeometries )
308  {
309  json += geom->asJSON( precision ) + ", ";
310  }
311  if ( json.endsWith( ", " ) )
312  {
313  json.chop( 2 ); // Remove last ", "
314  }
315  json += "] }";
316  return json;
317 }
318 
320 {
321  if ( mBoundingBox.isNull() )
322  {
323  mBoundingBox = calculateBoundingBox();
324  }
325  return mBoundingBox;
326 }
327 
329 {
330  if ( mGeometries.size() < 1 )
331  {
332  return QgsRectangle();
333  }
334 
335  QgsRectangle bbox = mGeometries.at( 0 )->boundingBox();
336  for ( int i = 1; i < mGeometries.size(); ++i )
337  {
338  QgsRectangle geomBox = mGeometries.at( i )->boundingBox();
339  bbox.combineExtentWith( &geomBox );
340  }
341  return bbox;
342 }
343 
345 {
346  if ( !mCoordinateSequence.isEmpty() )
347  return mCoordinateSequence;
348 
350  for ( ; geomIt != mGeometries.constEnd(); ++geomIt )
351  {
352  QgsCoordinateSequenceV2 geomCoords = ( *geomIt )->coordinateSequence();
353 
355  for ( ; cIt != geomCoords.constEnd(); ++cIt )
356  {
357  mCoordinateSequence.push_back( *cIt );
358  }
359  }
360 
361  return mCoordinateSequence;
362 }
363 
364 double QgsGeometryCollectionV2::closestSegment( const QgsPointV2& pt, QgsPointV2& segmentPt, QgsVertexId& vertexAfter, bool* leftOf, double epsilon ) const
365 {
366  return QgsGeometryUtils::closestSegmentFromComponents( mGeometries, QgsGeometryUtils::PART, pt, segmentPt, vertexAfter, leftOf, epsilon );
367 }
368 
370 {
371  if ( id.part < 0 )
372  {
373  id.part = 0;
374  id.ring = -1;
375  id.vertex = -1;
376  }
377 
378  QgsAbstractGeometryV2* geom = mGeometries.at( id.part );
379  if ( geom->nextVertex( id, vertex ) )
380  {
381  return true;
382  }
383  if (( id.part + 1 ) >= numGeometries() )
384  {
385  return false;
386  }
387  ++id.part;
388  id.ring = -1;
389  id.vertex = -1;
390  return mGeometries.at( id.part )->nextVertex( id, vertex );
391 }
392 
394 {
395  if ( position.part >= mGeometries.size() )
396  {
397  return false;
398  }
399 
400  bool success = mGeometries.at( position.part )->insertVertex( position, vertex );
401  if ( success )
402  {
403  clearCache(); //set bounding box invalid
404  }
405  return success;
406 }
407 
409 {
410  if ( position.part >= mGeometries.size() )
411  {
412  return false;
413  }
414 
415  bool success = mGeometries.at( position.part )->moveVertex( position, newPos );
416  if ( success )
417  {
418  clearCache(); //set bounding box invalid
419  }
420  return success;
421 }
422 
424 {
425  if ( position.part >= mGeometries.size() )
426  {
427  return false;
428  }
429 
430  QgsAbstractGeometryV2* geom = mGeometries.at( position.part );
431  if ( !geom )
432  {
433  return false;
434  }
435 
436  bool success = geom->deleteVertex( position );
437 
438  //remove geometry if no vertices left
439  if ( geom->isEmpty() )
440  {
441  removeGeometry( position.part );
442  }
443 
444  if ( success )
445  {
446  clearCache(); //set bounding box invalid
447  }
448  return success;
449 }
450 
452 {
453  double length = 0.0;
455  for ( ; geomIt != mGeometries.constEnd(); ++geomIt )
456  {
457  length += ( *geomIt )->length();
458  }
459  return length;
460 }
461 
463 {
464  double area = 0.0;
466  for ( ; geomIt != mGeometries.constEnd(); ++geomIt )
467  {
468  area += ( *geomIt )->area();
469  }
470  return area;
471 }
472 
474 {
475  double perimeter = 0.0;
477  for ( ; geomIt != mGeometries.constEnd(); ++geomIt )
478  {
479  perimeter += ( *geomIt )->perimeter();
480  }
481  return perimeter;
482 }
483 
484 bool QgsGeometryCollectionV2::fromCollectionWkt( const QString &wkt, const QList<QgsAbstractGeometryV2*>& subtypes, const QString& defaultChildWkbType )
485 {
486  clear();
487 
489 
490  if ( QgsWKBTypes::flatType( parts.first ) != QgsWKBTypes::parseType( geometryType() ) )
491  return false;
492  mWkbType = parts.first;
493 
494  QString defChildWkbType = QString( "%1%2%3 " ).arg( defaultChildWkbType, is3D() ? "Z" : "", isMeasure() ? "M" : "" );
495 
496  Q_FOREACH ( const QString& childWkt, QgsGeometryUtils::wktGetChildBlocks( parts.second, defChildWkbType ) )
497  {
499 
500  bool success = false;
501  Q_FOREACH ( const QgsAbstractGeometryV2* geom, subtypes )
502  {
503  if ( QgsWKBTypes::flatType( childParts.first ) == QgsWKBTypes::parseType( geom->geometryType() ) )
504  {
505  mGeometries.append( geom->clone() );
506  if ( mGeometries.back()->fromWkt( childWkt ) )
507  {
508  success = true;
509  break;
510  }
511  }
512  }
513  if ( !success )
514  {
515  clear();
516  qDeleteAll( subtypes );
517  return false;
518  }
519  }
520  qDeleteAll( subtypes );
521 
522  //scan through geometries and check if dimensionality of geometries is different to collection.
523  //if so, update the type dimensionality of the collection to match
524  bool hasZ = false;
525  bool hasM = false;
526  Q_FOREACH ( QgsAbstractGeometryV2* geom, mGeometries )
527  {
528  hasZ = hasZ || geom->is3D();
529  hasM = hasM || geom->isMeasure();
530  if ( hasZ && hasM )
531  break;
532  }
533  if ( hasZ )
534  addZValue( 0 );
535  if ( hasM )
536  addMValue( 0 );
537 
538  return true;
539 }
540 
542 {
544  for ( ; it != mGeometries.constEnd(); ++it )
545  {
546  if (( *it )->hasCurvedSegments() )
547  {
548  return true;
549  }
550  }
551  return false;
552 }
553 
555 {
557  QgsGeometryCollectionV2* geomCollection = dynamic_cast<QgsGeometryCollectionV2*>( geom );
558  if ( !geomCollection )
559  {
560  delete geom;
561  return clone();
562  }
563 
565  for ( ; geomIt != mGeometries.constEnd(); ++geomIt )
566  {
567  geomCollection->addGeometry(( *geomIt )->segmentize() );
568  }
569  return geomCollection;
570 }
571 
573 {
574  if ( vertex.part >= mGeometries.size() )
575  {
576  return 0.0;
577  }
578 
579  QgsAbstractGeometryV2* geom = mGeometries[vertex.part];
580  if ( !geom )
581  {
582  return 0.0;
583  }
584 
585  return geom->vertexAngle( vertex );
586 }
587 
589 {
590  if ( QgsWKBTypes::hasZ( mWkbType ) )
591  return false;
592 
594 
595  Q_FOREACH ( QgsAbstractGeometryV2* geom, mGeometries )
596  {
597  geom->addZValue( zValue );
598  }
599  clearCache();
600  return true;
601 }
602 
604 {
605  if ( QgsWKBTypes::hasM( mWkbType ) )
606  return false;
607 
609 
610  Q_FOREACH ( QgsAbstractGeometryV2* geom, mGeometries )
611  {
612  geom->addMValue( mValue );
613  }
614  clearCache();
615  return true;
616 }
617 
618 
620 {
621  if ( !is3D() )
622  return false;
623 
625  Q_FOREACH ( QgsAbstractGeometryV2* geom, mGeometries )
626  {
627  geom->dropZValue();
628  }
629  clearCache();
630  return true;
631 }
632 
634 {
635  if ( !isMeasure() )
636  return false;
637 
639  Q_FOREACH ( QgsAbstractGeometryV2* geom, mGeometries )
640  {
641  geom->dropMValue();
642  }
643  clearCache();
644  return true;
645 }
int indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const
static unsigned index
QgsWKBTypes::Type wkbType() const
Returns the WKB type of the geometry.
A rectangle specified with double values.
Definition: qgsrectangle.h:35
virtual bool insertVertex(QgsVertexId position, const QgsPointV2 &vertex) override
Inserts a vertex into the geometry.
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:746
static bool hasM(Type type)
Tests whether a WKB type contains m values.
Definition: qgswkbtypes.h:703
Circular string geometry type.
const_iterator constEnd() const
TransformDirection
Enum used to indicate the direction (forward or inverse) of the transform.
const T & at(int i) const
virtual QString asJSON(int precision=17) const =0
Returns a GeoJSON representation of the geometry.
bool isNull() const
test if the rectangle is null (all coordinates zero or after call to setMinimal()).
void insert(int i, const T &value)
Abstract base class for all geometries.
virtual void transform(const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection d=QgsCoordinateTransform::ForwardTransform) override
Transforms the geometry using a coordinate transform.
static QStringList wktGetChildBlocks(const QString &wkt, const QString &defaultType="")
Parses a WKT string and returns of list of blocks contained in the WKT.
virtual bool wktOmitChildType() const
Returns whether child type names are omitted from Wkt representations of the collection.
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:656
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.
QString wktTypeStr() const
Returns the WKT type string of the geometry.
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.
reference back()
int size() const
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
QgsWKBTypes::Type readHeader() const
Definition: qgswkbptr.cpp:37
Polygon geometry type.
Definition: qgspolygonv2.h:29
void clear()
bool is3D() const
Returns true if the geometry is 3D and contains a z-value.
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.
void combineExtentWith(QgsRectangle *rect)
expand the rectangle so that covers both the original rectangle and the given rectangle ...
void append(const T &value)
static Type dropZ(Type type)
Drops the z dimension (if present) for a WKB type and returns the new type.
Definition: qgswkbtypes.h:800
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:770
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.
bool isMeasure() const
Returns true if the geometry contains m values.
Line string geometry type, with support for z-dimension and m-values.
bool isEmpty() const
Returns true if the geometry is empty.
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.
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 void transform(const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection d=QgsCoordinateTransform::ForwardTransform)=0
Transforms the geometry using a coordinate transform.
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.
bool fromCollectionWkt(const QString &wkt, const QList< QgsAbstractGeometryV2 * > &subtypes, const QString &defaultChildWkbType=QString())
Reads a collection from a WKT string.
virtual double area() const override
Returns the area of the geometry.
virtual QString geometryType() const =0
Returns a unique string representing the geometry type.
virtual bool fromWkt(const QString &wkt) override
Sets the geometry from a WKT string.
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:817
virtual void clearCache() const override
Clears any cached parameters associated with the geometry, eg bounding boxes.
int numGeometries() const
Returns the number of geometries within the collection.
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.
virtual bool deleteVertex(QgsVertexId position)=0
Deletes a vertex within the geometry.
QString mid(int position, int n) const
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.
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.
const QgsAbstractGeometryV2 * geometryN(int n) const
Returns a const reference to a geometry from within the collection.
virtual QString geometryType() const override
Returns a unique string representing the geometry type.
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.
static Type parseType(const QString &wktStr)
Attempts to extract the WKB type from a WKT string.
Definition: qgswkbtypes.cpp:32
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;.
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
QgsAbstractGeometryV2 * segmentize() const override
Returns a geometry without curves.
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 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.