QGIS API Documentation  2.14.5-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  if ( mGeometries.isEmpty() )
378  {
379  return false;
380  }
381 
382  QgsAbstractGeometryV2* geom = mGeometries.at( id.part );
383  if ( geom->nextVertex( id, vertex ) )
384  {
385  return true;
386  }
387  if (( id.part + 1 ) >= numGeometries() )
388  {
389  return false;
390  }
391  ++id.part;
392  id.ring = -1;
393  id.vertex = -1;
394  return mGeometries.at( id.part )->nextVertex( id, vertex );
395 }
396 
398 {
399  if ( position.part >= mGeometries.size() )
400  {
401  return false;
402  }
403 
404  bool success = mGeometries.at( position.part )->insertVertex( position, vertex );
405  if ( success )
406  {
407  clearCache(); //set bounding box invalid
408  }
409  return success;
410 }
411 
413 {
414  if ( position.part >= mGeometries.size() )
415  {
416  return false;
417  }
418 
419  bool success = mGeometries.at( position.part )->moveVertex( position, newPos );
420  if ( success )
421  {
422  clearCache(); //set bounding box invalid
423  }
424  return success;
425 }
426 
428 {
429  if ( position.part >= mGeometries.size() )
430  {
431  return false;
432  }
433 
434  QgsAbstractGeometryV2* geom = mGeometries.at( position.part );
435  if ( !geom )
436  {
437  return false;
438  }
439 
440  bool success = geom->deleteVertex( position );
441 
442  //remove geometry if no vertices left
443  if ( geom->isEmpty() )
444  {
445  removeGeometry( position.part );
446  }
447 
448  if ( success )
449  {
450  clearCache(); //set bounding box invalid
451  }
452  return success;
453 }
454 
456 {
457  double length = 0.0;
459  for ( ; geomIt != mGeometries.constEnd(); ++geomIt )
460  {
461  length += ( *geomIt )->length();
462  }
463  return length;
464 }
465 
467 {
468  double area = 0.0;
470  for ( ; geomIt != mGeometries.constEnd(); ++geomIt )
471  {
472  area += ( *geomIt )->area();
473  }
474  return area;
475 }
476 
478 {
479  double perimeter = 0.0;
481  for ( ; geomIt != mGeometries.constEnd(); ++geomIt )
482  {
483  perimeter += ( *geomIt )->perimeter();
484  }
485  return perimeter;
486 }
487 
488 bool QgsGeometryCollectionV2::fromCollectionWkt( const QString &wkt, const QList<QgsAbstractGeometryV2*>& subtypes, const QString& defaultChildWkbType )
489 {
490  clear();
491 
493 
494  if ( QgsWKBTypes::flatType( parts.first ) != QgsWKBTypes::parseType( geometryType() ) )
495  return false;
496  mWkbType = parts.first;
497 
498  QString defChildWkbType = QString( "%1%2%3 " ).arg( defaultChildWkbType, is3D() ? "Z" : "", isMeasure() ? "M" : "" );
499 
500  Q_FOREACH ( const QString& childWkt, QgsGeometryUtils::wktGetChildBlocks( parts.second, defChildWkbType ) )
501  {
503 
504  bool success = false;
505  Q_FOREACH ( const QgsAbstractGeometryV2* geom, subtypes )
506  {
507  if ( QgsWKBTypes::flatType( childParts.first ) == QgsWKBTypes::parseType( geom->geometryType() ) )
508  {
509  mGeometries.append( geom->clone() );
510  if ( mGeometries.back()->fromWkt( childWkt ) )
511  {
512  success = true;
513  break;
514  }
515  }
516  }
517  if ( !success )
518  {
519  clear();
520  qDeleteAll( subtypes );
521  return false;
522  }
523  }
524  qDeleteAll( subtypes );
525 
526  //scan through geometries and check if dimensionality of geometries is different to collection.
527  //if so, update the type dimensionality of the collection to match
528  bool hasZ = false;
529  bool hasM = false;
530  Q_FOREACH ( QgsAbstractGeometryV2* geom, mGeometries )
531  {
532  hasZ = hasZ || geom->is3D();
533  hasM = hasM || geom->isMeasure();
534  if ( hasZ && hasM )
535  break;
536  }
537  if ( hasZ )
538  addZValue( 0 );
539  if ( hasM )
540  addMValue( 0 );
541 
542  return true;
543 }
544 
546 {
548  for ( ; it != mGeometries.constEnd(); ++it )
549  {
550  if (( *it )->hasCurvedSegments() )
551  {
552  return true;
553  }
554  }
555  return false;
556 }
557 
559 {
561  QgsGeometryCollectionV2* geomCollection = dynamic_cast<QgsGeometryCollectionV2*>( geom );
562  if ( !geomCollection )
563  {
564  delete geom;
565  return clone();
566  }
567 
569  for ( ; geomIt != mGeometries.constEnd(); ++geomIt )
570  {
571  geomCollection->addGeometry(( *geomIt )->segmentize() );
572  }
573  return geomCollection;
574 }
575 
577 {
578  if ( vertex.part >= mGeometries.size() )
579  {
580  return 0.0;
581  }
582 
583  QgsAbstractGeometryV2* geom = mGeometries[vertex.part];
584  if ( !geom )
585  {
586  return 0.0;
587  }
588 
589  return geom->vertexAngle( vertex );
590 }
591 
593 {
594  if ( QgsWKBTypes::hasZ( mWkbType ) )
595  return false;
596 
598 
599  Q_FOREACH ( QgsAbstractGeometryV2* geom, mGeometries )
600  {
601  geom->addZValue( zValue );
602  }
603  clearCache();
604  return true;
605 }
606 
608 {
609  if ( QgsWKBTypes::hasM( mWkbType ) )
610  return false;
611 
613 
614  Q_FOREACH ( QgsAbstractGeometryV2* geom, mGeometries )
615  {
616  geom->addMValue( mValue );
617  }
618  clearCache();
619  return true;
620 }
621 
622 
624 {
625  if ( !is3D() )
626  return false;
627 
629  Q_FOREACH ( QgsAbstractGeometryV2* geom, mGeometries )
630  {
631  geom->dropZValue();
632  }
633  clearCache();
634  return true;
635 }
636 
638 {
639  if ( !isMeasure() )
640  return false;
641 
643  Q_FOREACH ( QgsAbstractGeometryV2* geom, mGeometries )
644  {
645  geom->dropMValue();
646  }
647  clearCache();
648  return true;
649 }
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
bool isEmpty() 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.