18#ifndef QGSCURVEPOLYGON_H
19#define QGSCURVEPOLYGON_H
43 bool fuzzyHelper(
const QgsAbstractGeometry &other,
double epsilon,
bool useDistance )
const
45 const QgsCurvePolygon *otherPolygon = qgsgeometry_cast< const QgsCurvePolygon * >( &other );
50 if ( mWkbType != otherPolygon->
mWkbType )
56 if ( mInteriorRings.count() != otherPolygon->
mInteriorRings.count() )
64 if ( !( *mExteriorRing ).fuzzyDistanceEqual( *otherPolygon->
mExteriorRing, epsilon ) )
69 if ( !( *mExteriorRing ).fuzzyEqual( *otherPolygon->
mExteriorRing, epsilon ) )
74 for (
int i = 0; i < mInteriorRings.count(); ++i )
76 if ( ( !mInteriorRings.at( i ) && otherPolygon->
mInteriorRings.at( i ) ) ||
77 ( mInteriorRings.at( i ) && !otherPolygon->
mInteriorRings.at( i ) ) )
82 if ( mInteriorRings.at( i ) && otherPolygon->
mInteriorRings.at( i ) &&
83 !( *mInteriorRings.at( i ) ).fuzzyDistanceEqual( *otherPolygon->
mInteriorRings.at( i ), epsilon ) )
88 if ( mInteriorRings.at( i ) && otherPolygon->
mInteriorRings.at( i ) &&
89 !( *mInteriorRings.at( i ) ).fuzzyEqual( *otherPolygon->
mInteriorRings.at( i ), epsilon ) )
100 return fuzzyHelper( other, epsilon,
false );
104 return fuzzyHelper( other, epsilon,
true );
121 void clear() override;
124 bool fromWkt( const QString &wkt ) override;
128 QString asWkt(
int precision = 17 ) const override;
132 QString asKml(
int precision = 17 ) const override;
140 QgsCurvePolygon *snappedToGrid(
double hSpacing,
double vSpacing,
double dSpacing = 0,
double mSpacing = 0 ) const override
SIP_FACTORY;
141 bool removeDuplicateNodes(
double epsilon = 4 * std::numeric_limits<
double>::epsilon(),
bool useZValues = false ) override;
149 double roundness() const;
160 return mInteriorRings.size();
170 return mExteriorRing.get();
183 return mExteriorRing.get();
196 if ( i < 0 || i >= mInteriorRings.size() )
200 return mInteriorRings.at( i );
213 if ( i < 0 || i >= mInteriorRings.size() )
217 return mInteriorRings.at( i );
231 if ( a0 < 0 || a0 >= sipCpp->numInteriorRings() )
233 PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
238 return sipConvertFromType(
const_cast< QgsCurve *
>( sipCpp->interiorRing( a0 ) ), sipType_QgsCurve, NULL );
249 virtual QgsPolygon *toPolygon(
double tolerance = M_PI_2 / 90, SegmentationToleranceType toleranceType = MaximumAngle )
const SIP_FACTORY;
262 void setInteriorRings(
const QVector<QgsCurve *> &rings
SIP_TRANSFER );
274 bool removeInteriorRing(
int ringIndex );
286 bool removeInteriorRing(
int i );
288 if ( a0 < 0 || a0 >= sipCpp->numInteriorRings() )
290 PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
295 return PyBool_FromLong( sipCpp->removeInteriorRing( a0 ) );
306 void removeInteriorRings(
double minimumAllowedArea = -1 );
314 void removeInvalidRings();
339 void forceClockwise();
349 void forceCounterClockwise();
352 void draw( QPainter &p )
const override;
354 void transform( const QTransform &t,
double zTranslate = 0.0,
double zScale = 1.0,
double mTranslate = 0.0,
double mScale = 1.0 ) override;
358 bool deleteVertex(
QgsVertexId position ) override;
361 int nCoordinates() const override;
362 int vertexNumberFromVertexId(
QgsVertexId id ) const override;
368 bool hasCurvedSegments() const override;
375 QgsAbstractGeometry *segmentize(
double tolerance = M_PI_2 / 90, SegmentationToleranceType toleranceType = MaximumAngle ) const override
SIP_FACTORY;
382 double vertexAngle(
QgsVertexId vertex ) const override;
384 int vertexCount(
int part = 0,
int ring = 0 ) const override;
385 int ringCount(
int part = 0 ) const override
SIP_HOLDGIL;
388 double segmentLength(
QgsVertexId startVertex ) const override;
390 bool addZValue(
double zValue = 0 ) override;
391 bool addMValue(
double mValue = 0 ) override;
392 bool dropZValue() override;
393 bool dropMValue() override;
394 void swapXy() override;
427 SIP_PYOBJECT __repr__();
429 QString wkt = sipCpp->asWkt();
430 if ( wkt.length() > 1000 )
431 wkt = wkt.left( 1000 ) + QStringLiteral(
"..." );
432 QString
str = QStringLiteral(
"<QgsCurvePolygon: %1>" ).arg( wkt );
433 sipRes = PyUnicode_FromString(
str.toUtf8().constData() );
WkbType
The WKB type describes the number of dimensions a geometry has.
@ CurvePolygon
CurvePolygon.
TransformDirection
Flags for raster layer temporal capabilities.
@ Forward
Forward transform (from source to destination)
Abstract base class for all geometries.
virtual QgsBox3D calculateBoundingBox3D() const
Calculates the minimal 3D bounding box for the geometry.
virtual void draw(QPainter &p) const =0
Draws the geometry using the specified QPainter.
virtual int childCount() const
Returns number of child geometries (for geometries with child geometries) or child points (for geomet...
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.
virtual QString geometryType() const =0
Returns a unique string representing the geometry type.
virtual QgsAbstractGeometry * createEmptyWithSameType() const =0
Creates a new geometry with the same class and same WKB type as the original and transfers ownership.
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 QPainterPath asQPainterPath() const =0
Returns the geometry represented as a QPainterPath.
virtual void transform(const QgsCoordinateTransform &ct, Qgis::TransformDirection d=Qgis::TransformDirection::Forward, bool transformZ=false)=0
Transforms the geometry using a coordinate transform.
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 QgsAbstractGeometry * childGeometry(int index) const
Returns pointer to child geometry (for geometries with child geometries - i.e.
virtual bool operator==(const QgsAbstractGeometry &other) const =0
virtual int compareToSameClass(const QgsAbstractGeometry *other) const =0
Compares to an other geometry of the same class, and returns a integer for sorting of the two geometr...
A 3-dimensional box composed of x, y, z coordinates.
Custom exception class for Coordinate Reference System related exceptions.
Curve polygon geometry type.
const QgsCurve * exteriorRing() const
Returns the curve polygon's exterior ring.
QVector< QgsCurve * > mInteriorRings
bool operator!=(const QgsAbstractGeometry &other) const override
const QgsCurve * interiorRing(int i) const
Retrieves an interior ring from the curve polygon.
QgsCurve * interiorRing(int i)
Retrieves an interior ring from the curve polygon.
static const QgsCurvePolygon * cast(const QgsAbstractGeometry *geom)
Cast the geom to a QgsCurvePolygon.
bool fuzzyEqual(const QgsAbstractGeometry &other, double epsilon=1e-8) const override
Performs fuzzy comparison between this geometry and other using an epsilon.
bool fuzzyDistanceEqual(const QgsAbstractGeometry &other, double epsilon=1e-8) const override
Performs fuzzy distance comparison between this geometry and other using an epsilon.
QgsCurve * exteriorRing()
Returns a non-const pointer to the curve polygon's exterior ring.
bool operator==(const QgsAbstractGeometry &other) const override
std::unique_ptr< QgsCurve > mExteriorRing
Abstract base class for curved geometry type.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Point geometry type, with support for z-dimension and m-values.
static Qgis::WkbType flatType(Qgis::WkbType type)
Returns the flat type for a WKB type.
#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.