18 #ifndef QGSCIRCULARSTRING_H
19 #define QGSCIRCULARSTRING_H
23 #include "qgis_core.h"
68 const QVector<double> &z = QVector<double>(),
69 const QVector<double> &m = QVector<double>() )
SIP_HOLDGIL;
85 bool useShortestArc =
true );
89 bool fuzzyHelper(
double epsilon,
93 std::function<
bool(
double,
double,
double,
double,
double,
double,
double,
double,
double )> comparator3DMeasure,
94 std::function<
bool(
double,
double,
double,
double,
double,
double,
double )> comparator3D,
95 std::function<
bool(
double,
double,
double,
double,
double,
double,
double )> comparatorMeasure,
96 std::function<
bool(
double,
double,
double,
double,
double )> comparator2D )
const
98 const QgsCircularString *otherLine = qgsgeometry_cast< const QgsCircularString * >( &other );
102 if ( mWkbType != otherLine->
mWkbType )
105 const int size = mX.count();
106 if ( size != otherLine->mX.count() )
110 const double *xData = mX.constData();
111 const double *yData = mY.constData();
112 const double *zData = is3DFlag ? mZ.constData() :
nullptr;
113 const double *mData = isMeasureFlag ? mM.constData() :
nullptr;
114 const double *otherXData = otherLine->mX.constData();
115 const double *otherYData = otherLine->mY.constData();
116 const double *otherZData = is3DFlag ? otherLine->mZ.constData() :
nullptr;
117 const double *otherMData = isMeasureFlag ? otherLine->mM.constData() :
nullptr;
118 for (
int i = 0; i < size; ++i )
120 if ( is3DFlag && isMeasureFlag )
122 result &= comparator3DMeasure( epsilon, *xData++, *yData++, *zData++, *mData++,
123 *otherXData++, *otherYData++, *otherZData++, *otherMData++ );
127 result &= comparator3D( epsilon, *xData++, *yData++, *zData++,
128 *otherXData++, *otherYData++, *otherZData++ );
130 else if ( isMeasureFlag )
132 result &= comparatorMeasure( epsilon, *xData++, *yData++, *mData++,
133 *otherXData++, *otherYData++, *otherMData++ );
137 result &= comparator2D( epsilon, *xData++, *yData++,
138 *otherXData++, *otherYData++ );
158 [](
double epsilon,
double x1,
double y1,
double z1,
double m1,
159 double x2,
double y2,
double z2,
double m2 )
163 [](
double epsilon,
double x1,
double y1,
double z1,
164 double x2,
double y2,
double z2 )
168 [](
double epsilon,
double x1,
double y1,
double m1,
169 double x2,
double y2,
double m2 )
173 [](
double epsilon,
double x1,
double y1,
174 double x2,
double y2 )
187 [](
double epsilon,
double x1,
double y1,
double z1,
double m1,
188 double x2,
double y2,
double z2,
double m2 )
192 [](
double epsilon,
double x1,
double y1,
double z1,
193 double x2,
double y2,
double z2 )
197 [](
double epsilon,
double x1,
double y1,
double m1,
198 double x2,
double y2,
double m2 )
202 [](
double epsilon,
double x1,
double y1,
203 double x2,
double y2 )
218 void clear() override;
221 bool fromWkt( const QString &wkt ) override;
225 QString asWkt(
int precision = 17 ) const override;
230 bool isValid( QString &error
SIP_OUT,
Qgis::GeometryValidityFlags flags =
Qgis::GeometryValidityFlags() ) const override;
232 int indexOf( const
QgsPoint &point ) const final;
258 double length() const override;
261 QgsLineString *curveToLine(
double tolerance = M_PI_2 / 90, SegmentationToleranceType toleranceType = MaximumAngle ) const override
SIP_FACTORY;
262 QgsCircularString *snappedToGrid(
double hSpacing,
double vSpacing,
double dSpacing = 0,
double mSpacing = 0 ) const override
SIP_FACTORY;
263 bool removeDuplicateNodes(
double epsilon = 4 * std::numeric_limits<
double>::epsilon(),
bool useZValues = false ) override;
265 void draw( QPainter &p ) const override;
267 void transform( const QTransform &t,
double zTranslate = 0.0,
double zScale = 1.0,
double mTranslate = 0.0,
double mScale = 1.0 ) override;
268 void addToPainterPath( QPainterPath &path ) const override;
269 void drawAsPolygon( QPainter &p ) const override;
272 bool deleteVertex(
QgsVertexId position ) override;
274 bool pointAt(
int node,
QgsPoint &point,
Qgis::VertexType &type ) const override;
275 void sumUpArea(
double &sum
SIP_OUT ) const override;
276 bool hasCurvedSegments() const override;
277 double vertexAngle(
QgsVertexId vertex ) const override;
278 double segmentLength(
QgsVertexId startVertex ) const override;
282 bool addZValue(
double zValue = 0 ) override;
283 bool addMValue(
double mValue = 0 ) override;
284 bool dropZValue() override;
285 bool dropMValue() override;
286 void swapXy() override;
287 double xAt(
int index ) const override
SIP_HOLDGIL;
288 double yAt(
int index ) const override
SIP_HOLDGIL;
289 double zAt(
int index ) const override
SIP_HOLDGIL;
290 double mAt(
int index ) const override
SIP_HOLDGIL;
293 void scroll(
int firstVertexIndex ) final;
298 std::tuple< std::unique_ptr< QgsCurve >, std::unique_ptr< QgsCurve > >
splitCurveAtVertex(
int index )
const final;
317 SIP_PYOBJECT __repr__();
319 QString wkt = sipCpp->asWkt();
320 if ( wkt.length() > 1000 )
321 wkt = wkt.left( 1000 ) + QStringLiteral(
"..." );
322 QString
str = QStringLiteral(
"<QgsCircularString: %1>" ).arg( wkt );
323 sipRes = PyUnicode_FromString(
str.toUtf8().constData() );
339 static void arcTo( QPainterPath &path, QPointF pt1, QPointF pt2, QPointF pt3 );
343 static QgsPointSequence compassPointsOnSegment(
double p1Angle,
double p2Angle,
double p3Angle,
double centerX,
double centerY,
double radius );
344 static double closestPointOnArc(
double x1,
double y1,
double x2,
double y2,
double x3,
double y3,
346 void insertVertexBetween(
int after,
int before,
int pointOnCircle );
The Qgis class provides global constants for use throughout the application.
@ CircularString
CircularString.
Abstract base class for all geometries.
virtual QgsBox3D calculateBoundingBox3D() const
Calculates the minimal 3D bounding box for the geometry.
bool isMeasure() const
Returns true if the geometry contains m values.
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.
bool is3D() const
Returns true if the geometry is 3D and contains a z-value.
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.
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 deleteVertex(QgsVertexId position)=0
Deletes a vertex within the geometry.
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 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.
Circular string geometry type.
bool equals(const QgsCurve &other) const override
Checks whether this curve exactly equals another curve.
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.
static const QgsCircularString * cast(const QgsAbstractGeometry *geom)
Cast the geom to a QgsCircularString.
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.
static bool fuzzyEqual(T epsilon, const Args &... args) noexcept
Performs fuzzy comparison between pairs of values within a specified epsilon.
static bool fuzzyDistanceEqual(T epsilon, const Args &... args) noexcept
Compare equality between multiple pairs of values with a specified epsilon.
Line string geometry type, with support for z-dimension and m-values.
Point geometry type, with support for z-dimension and m-values.
A rectangle specified with double values.
static Qgis::WkbType flatType(Qgis::WkbType type)
Returns the flat type for a WKB 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 ...
#define SIP_THROW(name,...)
QVector< QgsPoint > QgsPointSequence
void arcTo(QPainterPath &path, QPointF pt1, QPointF pt2, QPointF pt3)
double closestSegment(const QgsPolylineXY &pl, const QgsPointXY &pt, int &vertexAfter, double epsilon)
Utility class for identifying a unique vertex within a geometry.