18#ifndef QGSCOMPOUNDCURVE_H
19#define QGSCOMPOUNDCURVE_H
27using namespace Qt::StringLiterals;
44 bool fuzzyHelper(
const QgsAbstractGeometry &other,
double epsilon,
bool useDistance )
const
53 if ( mCurves.size() != otherCurve->mCurves.size() )
56 for (
int i = 0; i < mCurves.size(); ++i )
60 if ( !( *mCurves.at( i ) ).fuzzyDistanceEqual( *otherCurve->mCurves.at( i ), epsilon ) )
68 if ( !( *mCurves.at( i ) ).fuzzyEqual( *otherCurve->mCurves.at( i ), epsilon ) )
82 return fuzzyHelper( other, epsilon,
false );
86 return fuzzyHelper( other, epsilon,
true );
98 void clear() override;
101 bool fromWkt( const QString &wkt ) override;
105 QString asWkt(
int precision = 17 ) const override;
108 json asJsonObject(
int precision = 17 ) const override
SIP_SKIP;
117 bool isValid( QString &error
SIP_OUT,
Qgis::GeometryValidityFlags flags =
Qgis::GeometryValidityFlags() ) const override;
118 int indexOf( const
QgsPoint &point ) const final;
126 QgsLineString *curveToLine(
double tolerance = M_PI_2 / 90, SegmentationToleranceType toleranceType = MaximumAngle ) const override
SIP_FACTORY;
128 QgsCompoundCurve *snappedToGrid(
double hSpacing,
double vSpacing,
double dSpacing = 0,
double mSpacing = 0,
bool removeRedundantPoints = false ) const override
SIP_FACTORY;
130 bool removeDuplicateNodes(
double epsilon = 4 * std::numeric_limits<
double>::epsilon(),
bool useZValues = false ) override;
132 using
QgsCurve::boundingBoxIntersects;
162 void removeCurve(
int i );
167 void addVertex(
const QgsPoint &pt );
175 void condenseCurves();
185 bool toggleCircularAtVertex(
QgsVertexId position );
187 void draw( QPainter &p )
const override;
189 void transform( const QTransform &t,
double zTranslate = 0.0,
double zScale = 1.0,
double mTranslate = 0.0,
double mScale = 1.0 ) override;
190 void addToPainterPath( QPainterPath &path ) const override;
191 void drawAsPolygon( QPainter &p ) const override;
194 bool deleteVertex(
QgsVertexId position ) override;
196 bool pointAt(
int node,
QgsPoint &point,
Qgis::VertexType &type ) const override;
197 void sumUpArea(
double &sum
SIP_OUT ) const override;
198 void sumUpArea3D(
double &sum
SIP_OUT ) const override;
203 bool hasCurvedSegments() const override;
204 double vertexAngle(
QgsVertexId vertex ) const override;
205 double segmentLength(
QgsVertexId startVertex ) const override;
211 bool addZValue(
double zValue = 0 ) override;
212 bool addMValue(
double mValue = 0 ) override;
214 bool dropZValue() override;
215 bool dropMValue() override;
216 void swapXy() override;
218 double xAt(
int index ) const override
SIP_HOLDGIL;
219 double yAt(
int index ) const override
SIP_HOLDGIL;
220 double zAt(
int index ) const override
SIP_HOLDGIL;
221 double mAt(
int index ) const override
SIP_HOLDGIL;
224 void scroll(
int firstVertexIndex ) final;
229 std::tuple< std::unique_ptr< QgsCurve >, std::unique_ptr< QgsCurve > >
splitCurveAtVertex(
int index )
const final;
265 SIP_PYOBJECT __repr__();
267 QString wkt = sipCpp->asWkt();
268 if ( wkt.length() > 1000 )
269 wkt = wkt.left( 1000 ) + u
"..."_s;
270 QString str = u
"<QgsCompoundCurve: %1>"_s.arg( wkt );
271 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
281 QVector< QgsCurve * > mCurves;
287 QVector< QPair<int, QgsVertexId> > curveVertexId(
QgsVertexId id )
const;
Provides global constants and enumerations for use throughout the application.
@ CompoundCurve
CompoundCurve.
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 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 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...
QgsAbstractGeometry()=default
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.
Compound curve geometry type.
bool fuzzyEqual(const QgsAbstractGeometry &other, double epsilon=1e-8) const override
Performs fuzzy comparison between this geometry and other using an epsilon.
int nCurves() const
Returns the number of curves in the geometry.
static QgsCompoundCurve * cast(QgsAbstractGeometry *geom)
Cast the geom to a QgsCompoundCurve.
bool fuzzyDistanceEqual(const QgsAbstractGeometry &other, double epsilon=1e-8) const override
Performs fuzzy distance comparison between this geometry and other using an epsilon.
bool equals(const QgsCurve &other) const override
Checks whether this curve exactly equals another curve.
static const QgsCompoundCurve * cast(const QgsAbstractGeometry *geom)
Cast the geom to a QgsCompoundCurve.
Custom exception class for Coordinate Reference System related exceptions.
Abstract base class for curved geometry type.
virtual std::tuple< std::unique_ptr< QgsCurve >, std::unique_ptr< QgsCurve > > splitCurveAtVertex(int index) const =0
Splits the curve at the specified vertex index, returning two curves which represent the portion of t...
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Line string geometry type, with support for z-dimension and m-values.
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.
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_THROW(name,...)
T qgsgeometry_cast(QgsAbstractGeometry *geom)
QVector< QgsPoint > QgsPointSequence
double closestSegment(const QgsPolylineXY &pl, const QgsPointXY &pt, int &vertexAfter, double epsilon)
Utility class for identifying a unique vertex within a geometry.