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;
145 QgsCurvePolygon *snappedToGrid(
double hSpacing,
double vSpacing,
double dSpacing = 0,
double mSpacing = 0,
bool removeRedundantPoints = false ) const override
SIP_FACTORY;
147 bool removeDuplicateNodes(
double epsilon = 4 * std::numeric_limits<
double>::epsilon(),
bool useZValues = false ) override;
155 double roundness() const;
166 return mInteriorRings.size();
176 return mExteriorRing.get();
189 return mExteriorRing.get();
202 if ( i < 0 || i >= mInteriorRings.size() )
206 return mInteriorRings.at( i );
219 if ( i < 0 || i >= mInteriorRings.size() )
223 return mInteriorRings.at( i );
237 if ( a0 < 0 || a0 >= sipCpp->numInteriorRings() )
239 PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
244 return sipConvertFromType(
const_cast< QgsCurve *
>( sipCpp->interiorRing( a0 ) ), sipType_QgsCurve, NULL );
255 virtual QgsPolygon *toPolygon(
double tolerance = M_PI_2 / 90, SegmentationToleranceType toleranceType = MaximumAngle )
const SIP_FACTORY;
268 void setInteriorRings(
const QVector<QgsCurve *> &rings
SIP_TRANSFER );
280 bool removeInteriorRing(
int ringIndex );
292 bool removeInteriorRing(
int i );
294 if ( a0 < 0 || a0 >= sipCpp->numInteriorRings() )
296 PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
301 return PyBool_FromLong( sipCpp->removeInteriorRing( a0 ) );
312 void removeInteriorRings(
double minimumAllowedArea = -1 );
320 void removeInvalidRings();
345 void forceClockwise();
355 void forceCounterClockwise();
358 void draw( QPainter &p )
const override;
360 void transform( const QTransform &t,
double zTranslate = 0.0,
double zScale = 1.0,
double mTranslate = 0.0,
double mScale = 1.0 ) override;
364 bool deleteVertex(
QgsVertexId position ) override;
367 int nCoordinates() const override;
368 int vertexNumberFromVertexId(
QgsVertexId id ) const override;
374 bool hasCurvedSegments() const override;
381 QgsAbstractGeometry *segmentize(
double tolerance = M_PI_2 / 90, SegmentationToleranceType toleranceType = MaximumAngle ) const override
SIP_FACTORY;
388 double vertexAngle(
QgsVertexId vertex ) const override;
390 int vertexCount(
int part = 0,
int ring = 0 ) const override;
391 int ringCount(
int part = 0 ) const override
SIP_HOLDGIL;
394 double segmentLength(
QgsVertexId startVertex ) const override;
396 bool addZValue(
double zValue = 0 ) override;
397 bool addMValue(
double mValue = 0 ) override;
398 bool dropZValue() override;
399 bool dropMValue() override;
400 void swapXy() override;
433 SIP_PYOBJECT __repr__();
435 QString wkt = sipCpp->asWkt();
436 if ( wkt.length() > 1000 )
437 wkt = wkt.left( 1000 ) + QStringLiteral(
"..." );
438 QString str = QStringLiteral(
"<QgsCurvePolygon: %1>" ).arg( wkt );
439 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
WkbType
The WKB type describes the number of dimensions a geometry has.
@ CurvePolygon
CurvePolygon.
TransformDirection
Indicates the direction (forward or inverse) of a transform.
@ 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.