QGIS API Documentation  2.14.11-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 
365 {
366  if ( !mCoordinateSequence.isEmpty() )
368 
369  int count = 0;
370 
372  for ( ; geomIt != mGeometries.constEnd(); ++geomIt )
373  {
374  count += ( *geomIt )->nCoordinates();
375  }
376 
377  return count;
378 }
379 
380 double QgsGeometryCollectionV2::closestSegment( const QgsPointV2& pt, QgsPointV2& segmentPt, QgsVertexId& vertexAfter, bool* leftOf, double epsilon ) const
381 {
382  return QgsGeometryUtils::closestSegmentFromComponents( mGeometries, QgsGeometryUtils::PART, pt, segmentPt, vertexAfter, leftOf, epsilon );
383 }
384 
386 {
387  if ( id.part < 0 )
388  {
389  id.part = 0;
390  id.ring = -1;
391  id.vertex = -1;
392  }
393  if ( mGeometries.isEmpty() )
394  {
395  return false;
396  }
397 
398  QgsAbstractGeometryV2* geom = mGeometries.at( id.part );
399  if ( geom->nextVertex( id, vertex ) )
400  {
401  return true;
402  }
403  if (( id.part + 1 ) >= numGeometries() )
404  {
405  return false;
406  }
407  ++id.part;
408  id.ring = -1;
409  id.vertex = -1;
410  return mGeometries.at( id.part )->nextVertex( id, vertex );
411 }
412 
414 {
415  if ( position.part >= mGeometries.size() )
416  {
417  return false;
418  }
419 
420  bool success = mGeometries.at( position.part )->insertVertex( position, vertex );
421  if ( success )
422  {
423  clearCache(); //set bounding box invalid
424  }
425  return success;
426 }
427 
429 {
430  if ( position.part >= mGeometries.size() )
431  {
432  return false;
433  }
434 
435  bool success = mGeometries.at( position.part )->moveVertex( position, newPos );
436  if ( success )
437  {
438  clearCache(); //set bounding box invalid
439  }
440  return success;
441 }
442 
444 {
445  if ( position.part >= mGeometries.size() )
446  {
447  return false;
448  }
449 
450  QgsAbstractGeometryV2* geom = mGeometries.at( position.part );
451  if ( !geom )
452  {
453  return false;
454  }
455 
456  bool success = geom->deleteVertex( position );
457 
458  //remove geometry if no vertices left
459  if ( geom->isEmpty() )
460  {
461  removeGeometry( position.part );
462  }
463 
464  if ( success )
465  {
466  clearCache(); //set bounding box invalid
467  }
468  return success;
469 }
470 
472 {
473  double length = 0.0;
475  for ( ; geomIt != mGeometries.constEnd(); ++geomIt )
476  {
477  length += ( *geomIt )->length();
478  }
479  return length;
480 }
481 
483 {
484  double area = 0.0;
486  for ( ; geomIt != mGeometries.constEnd(); ++geomIt )
487  {
488  area += ( *geomIt )->area();
489  }
490  return area;
491 }
492 
494 {
495  double perimeter = 0.0;
497  for ( ; geomIt != mGeometries.constEnd(); ++geomIt )
498  {
499  perimeter += ( *geomIt )->perimeter();
500  }
501  return perimeter;
502 }
503 
504 bool QgsGeometryCollectionV2::fromCollectionWkt( const QString &wkt, const QList<QgsAbstractGeometryV2*>& subtypes, const QString& defaultChildWkbType )
505 {
506  clear();
507 
509 
510  if ( QgsWKBTypes::flatType( parts.first ) != QgsWKBTypes::parseType( geometryType() ) )
511  return false;
512  mWkbType = parts.first;
513 
514  QString defChildWkbType = QString( "%1%2%3 " ).arg( defaultChildWkbType, is3D() ? "Z" : "", isMeasure() ? "M" : "" );
515 
516  Q_FOREACH ( const QString& childWkt, QgsGeometryUtils::wktGetChildBlocks( parts.second, defChildWkbType ) )
517  {
519 
520  bool success = false;
521  Q_FOREACH ( const QgsAbstractGeometryV2* geom, subtypes )
522  {
523  if ( QgsWKBTypes::flatType( childParts.first ) == QgsWKBTypes::parseType( geom->geometryType() ) )
524  {
525  mGeometries.append( geom->clone() );
526  if ( mGeometries.back()->fromWkt( childWkt ) )
527  {
528  success = true;
529  break;
530  }
531  }
532  }
533  if ( !success )
534  {
535  clear();
536  qDeleteAll( subtypes );
537  return false;
538  }
539  }
540  qDeleteAll( subtypes );
541 
542  //scan through geometries and check if dimensionality of geometries is different to collection.
543  //if so, update the type dimensionality of the collection to match
544  bool hasZ = false;
545  bool hasM = false;
546  Q_FOREACH ( QgsAbstractGeometryV2* geom, mGeometries )
547  {
548  hasZ = hasZ || geom->is3D();
549  hasM = hasM || geom->isMeasure();
550  if ( hasZ && hasM )
551  break;
552  }
553  if ( hasZ )
554  addZValue( 0 );
555  if ( hasM )
556  addMValue( 0 );
557 
558  return true;
559 }
560 
562 {
564  for ( ; it != mGeometries.constEnd(); ++it )
565  {
566  if (( *it )->hasCurvedSegments() )
567  {
568  return true;
569  }
570  }
571  return false;
572 }
573 
575 {
577  QgsGeometryCollectionV2* geomCollection = dynamic_cast<QgsGeometryCollectionV2*>( geom );
578  if ( !geomCollection )
579  {
580  delete geom;
581  return clone();
582  }
583 
585  for ( ; geomIt != mGeometries.constEnd(); ++geomIt )
586  {
587  geomCollection->addGeometry(( *geomIt )->segmentize() );
588  }
589  return geomCollection;
590 }
591 
593 {
594  if ( vertex.part >= mGeometries.size() )
595  {
596  return 0.0;
597  }
598 
599  QgsAbstractGeometryV2* geom = mGeometries[vertex.part];
600  if ( !geom )
601  {
602  return 0.0;
603  }
604 
605  return geom->vertexAngle( vertex );
606 }
607 
609 {
610  if ( QgsWKBTypes::hasZ( mWkbType ) )
611  return false;
612 
614 
615  Q_FOREACH ( QgsAbstractGeometryV2* geom, mGeometries )
616  {
617  geom->addZValue( zValue );
618  }
619  clearCache();
620  return true;
621 }
622 
624 {
625  if ( QgsWKBTypes::hasM( mWkbType ) )
626  return false;
627 
629 
630  Q_FOREACH ( QgsAbstractGeometryV2* geom, mGeometries )
631  {
632  geom->addMValue( mValue );
633  }
634  clearCache();
635  return true;
636 }
637 
638 
640 {
641  if ( !is3D() )
642  return false;
643 
645  Q_FOREACH ( QgsAbstractGeometryV2* geom, mGeometries )
646  {
647  geom->dropZValue();
648  }
649  clearCache();
650  return true;
651 }
652 
654 {
655  if ( !isMeasure() )
656  return false;
657 
659  Q_FOREACH ( QgsAbstractGeometryV2* geom, mGeometries )
660  {
661  geom->dropMValue();
662  }
663  clearCache();
664  return true;
665 }
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 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: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.
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.
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.
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()
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
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.
void combineExtentWith(QgsRectangle *rect)
expand the rectangle so that covers both the original rectangle and the given rectangle ...
const QgsAbstractGeometryV2 * geometryN(int n) const
Returns a const reference to a geometry from within the collection.
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.
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.
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 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 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.
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
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.
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;.
QgsWKBTypes::Type readHeader() const
Definition: qgswkbptr.cpp:37
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()
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.