16#ifndef QGSGEOMETRYCOLLECTION_H
17#define QGSGEOMETRYCOLLECTION_H
62 bool fuzzyHelper(
const QgsAbstractGeometry &other,
double epsilon,
bool useDistance )
const
64 const QgsGeometryCollection *otherCollection = qgsgeometry_cast< const QgsGeometryCollection * >( &other );
65 if ( !otherCollection )
68 if ( mWkbType != otherCollection->
mWkbType )
71 if ( mGeometries.count() != otherCollection->
mGeometries.count() )
74 for (
int i = 0; i < mGeometries.count(); ++i )
88 if ( !( *g1 ).fuzzyDistanceEqual( *g2, epsilon ) )
95 if ( !( *g1 ).fuzzyEqual( *g2, epsilon ) )
108 return fuzzyHelper( other, epsilon,
false );
112 return fuzzyHelper( other, epsilon,
true );
122 return mGeometries.size();
132 sipRes = sipCpp->numGeometries();
136 int __bool__()
const;
150 return mGeometries.value( n );
169 if ( a0 < 0 || a0 >= sipCpp->numGeometries() )
171 PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
176 return sipConvertFromType( sipCpp->geometryN( a0 ), sipType_QgsAbstractGeometry, NULL );
186 void clear() override;
188 bool removeDuplicateNodes(
double epsilon = 4 * std::numeric_limits<
double>::epsilon(),
bool useZValues = false ) override;
191 int vertexNumberFromVertexId(
QgsVertexId id ) const override;
221 virtual bool removeGeometry(
int nr );
230 virtual bool removeGeometry(
int nr );
232 const int count = sipCpp->numGeometries();
233 if ( a0 < 0 || a0 >= count )
235 PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
240 return PyBool_FromLong( sipCpp->removeGeometry( a0 ) );
247 void transform( const QTransform &t,
double zTranslate = 0.0,
double zScale = 1.0,
double mTranslate = 0.0,
double mScale = 1.0 ) override;
249 void draw( QPainter &p ) const override;
250 QPainterPath asQPainterPath() const override;
253 bool fromWkt( const QString &wkt ) override;
257 QString asWkt(
int precision = 17 ) const override;
261 QString asKml(
int precision = 17 ) const override;
263 QgsBox3D boundingBox3D() const override;
266 int nCoordinates() const override;
274 bool deleteVertex(
QgsVertexId position ) override;
280 bool hasCurvedSegments() const override
SIP_HOLDGIL;
287 QgsAbstractGeometry *segmentize(
double tolerance = M_PI_2 / 90, SegmentationToleranceType toleranceType = MaximumAngle ) const override
SIP_FACTORY;
289 double vertexAngle(
QgsVertexId vertex ) const override;
290 double segmentLength(
QgsVertexId startVertex ) const override;
291 int vertexCount(
int part = 0,
int ring = 0 ) const override;
292 int ringCount(
int part = 0 ) const override;
293 int partCount() const override;
295 bool isValid( QString &error
SIP_OUT,
Qgis::GeometryValidityFlags flags =
Qgis::GeometryValidityFlags() ) const override;
297 bool addZValue(
double zValue = 0 ) override;
298 bool addMValue(
double mValue = 0 ) override;
299 bool dropZValue() override;
300 bool dropMValue() override;
301 void swapXy() override;
340 const int count = sipCpp->numGeometries();
341 if ( a0 < -count || a0 >= count )
343 PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
348 return sipConvertFromType( sipCpp->geometryN( a0 ), sipType_QgsAbstractGeometry, NULL );
352 return sipConvertFromType( sipCpp->geometryN( count + a0 ), sipType_QgsAbstractGeometry, NULL );
366 void __delitem__(
int index );
368 const int count = sipCpp->numGeometries();
369 if ( a0 >= 0 && a0 < count )
370 sipCpp->removeGeometry( a0 );
371 else if ( a0 < 0 && a0 >= -count )
372 sipCpp->removeGeometry( count + a0 );
375 PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
387 sipRes = sipConvertFromNewType( new
QgsGeometryPartIterator( sipCpp ), sipType_QgsGeometryPartIterator, Py_None );
409 int childCount() const override;
419 virtual
bool wktOmitChildType() const;
424 bool fromCollectionWkt( const QString &wkt, const QVector<
QgsAbstractGeometry *> &subtypes, const QString &defaultChildWkbType = QString() );
426 QgsBox3D calculateBoundingBox3D() const override;
427 void clearCache() const override;
432 mutable
bool mHasCachedValidity = false;
433 mutable QString mValidityFailureReason;
The Qgis class provides global constants for use throughout the application.
WkbType
The WKB type describes the number of dimensions a geometry has.
Abstract base class for all geometries.
virtual void transformVertices(const std::function< QgsPoint(const QgsPoint &) > &transform)
Transforms the vertices from the geometry in place, applying the transform function to every vertex.
QgsAbstractGeometry & operator=(const QgsAbstractGeometry &geom)
Qgis::WkbType wkbType() const
Returns the WKB type of the geometry.
virtual bool fuzzyEqual(const QgsAbstractGeometry &other, double epsilon=1e-8) const =0
Performs fuzzy comparison between this geometry and other using an epsilon.
virtual bool isEmpty() const
Returns true if the geometry is empty.
virtual void normalize()=0
Reorganizes the geometry into a normalized form (or "canonical" form).
virtual void filterVertices(const std::function< bool(const QgsPoint &) > &filter)
Filters the vertices from the geometry in place, removing any which do not return true for the filter...
virtual bool operator==(const QgsAbstractGeometry &other) const =0
virtual QgsAbstractGeometry * clone() const =0
Clones the geometry by performing a deep copy.
A 3-dimensional box composed of x, y, z coordinates.
Custom exception class for Coordinate Reference System related exceptions.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
bool fuzzyDistanceEqual(const QgsAbstractGeometry &other, double epsilon=1e-8) const override
Performs fuzzy distance comparison between this geometry and other using an epsilon.
QVector< QgsAbstractGeometry * > mGeometries
static const QgsGeometryCollection * cast(const QgsAbstractGeometry *geom)
Cast the geom to a QgsGeometryCollection.
bool operator==(const QgsAbstractGeometry &other) const override
bool fuzzyEqual(const QgsAbstractGeometry &other, double epsilon=1e-8) const override
Performs fuzzy comparison between this geometry and other using an epsilon.
bool operator!=(const QgsAbstractGeometry &other) const override
const QgsAbstractGeometry * geometryN(int n) const
Returns a const reference to a geometry from within the collection.
Java-style iterator for traversal of parts of a geometry.
Point geometry type, with support for z-dimension and m-values.
static bool isMultiType(Qgis::WkbType type)
Returns true if the WKB type is a multi type.
double ANALYSIS_EXPORT leftOf(const QgsPoint &thepoint, const QgsPoint *p1, const QgsPoint *p2)
Returns whether 'thepoint' is left or right of the line from 'p1' to 'p2'. Negative values mean left ...
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
#define SIP_TYPEHINT(type)
#define SIP_THROW(name,...)
QVector< QgsRingSequence > QgsCoordinateSequence
double closestSegment(const QgsPolylineXY &pl, const QgsPointXY &pt, int &vertexAfter, double epsilon)
Utility class for identifying a unique vertex within a geometry.