QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
Loading...
Searching...
No Matches
qgscircularstring.h
Go to the documentation of this file.
1/***************************************************************************
2 qgscircularstring.h
3 ---------------------
4 begin : September 2014
5 copyright : (C) 2014 by Marco Hugentobler
6 email : marco at sourcepole dot ch
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSCIRCULARSTRING_H
19#define QGSCIRCULARSTRING_H
20
21#include <QVector>
22
23#include "qgis_core.h"
24#include "qgis_sip.h"
25#include "qgscurve.h"
26
27
34class CORE_EXPORT QgsCircularString: public QgsCurve
35{
36 public:
37
42
49 QgsCircularString( const QgsPoint &p1,
50 const QgsPoint &p2,
51 const QgsPoint &p3 ) SIP_HOLDGIL;
52
68 QgsCircularString( const QVector<double> &x, const QVector<double> &y,
69 const QVector<double> &z = QVector<double>(),
70 const QVector<double> &m = QVector<double>() ) SIP_HOLDGIL;
71
72
83 static QgsCircularString fromTwoPointsAndCenter( const QgsPoint &p1,
84 const QgsPoint &p2,
85 const QgsPoint &center,
86 bool useShortestArc = true );
87
88 bool equals( const QgsCurve &other ) const override;
89
90 QString geometryType() const override SIP_HOLDGIL;
91 int dimension() const override SIP_HOLDGIL;
92 QgsCircularString *clone() const override SIP_FACTORY;
93 void clear() override;
94
95 bool fromWkb( QgsConstWkbPtr &wkb ) override;
96 bool fromWkt( const QString &wkt ) override;
97
98 int wkbSize( QgsAbstractGeometry::WkbFlags flags = QgsAbstractGeometry::WkbFlags() ) const override;
99 QByteArray asWkb( QgsAbstractGeometry::WkbFlags flags = QgsAbstractGeometry::WkbFlags() ) const override;
100 QString asWkt( int precision = 17 ) const override;
101 QDomElement asGml2( QDomDocument &doc, int precision = 17, const QString &ns = "gml", QgsAbstractGeometry::AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY ) const override;
102 QDomElement asGml3( QDomDocument &doc, int precision = 17, const QString &ns = "gml", QgsAbstractGeometry::AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY ) const override;
103 json asJsonObject( int precision = 17 ) const override SIP_SKIP;
104 bool isEmpty() const override SIP_HOLDGIL;
105 bool isValid( QString &error SIP_OUT, Qgis::GeometryValidityFlags flags = Qgis::GeometryValidityFlags() ) const override;
106 int numPoints() const override SIP_HOLDGIL;
107 int indexOf( const QgsPoint &point ) const final;
108
112 QgsPoint pointN( int i ) const SIP_HOLDGIL;
113
114 void points( QgsPointSequence &pts SIP_OUT ) const override;
115
119 void setPoints( const QgsPointSequence &points );
120
131 void append( const QgsCircularString *string );
132
133 double length() const override;
134 QgsPoint startPoint() const override SIP_HOLDGIL;
135 QgsPoint endPoint() const override SIP_HOLDGIL;
136 QgsLineString *curveToLine( double tolerance = M_PI_2 / 90, SegmentationToleranceType toleranceType = MaximumAngle ) const override SIP_FACTORY;
137 QgsCircularString *snappedToGrid( double hSpacing, double vSpacing, double dSpacing = 0, double mSpacing = 0 ) const override SIP_FACTORY;
138 bool removeDuplicateNodes( double epsilon = 4 * std::numeric_limits<double>::epsilon(), bool useZValues = false ) override;
139
140 void draw( QPainter &p ) const override;
142 void transform( const QTransform &t, double zTranslate = 0.0, double zScale = 1.0, double mTranslate = 0.0, double mScale = 1.0 ) override;
143 void addToPainterPath( QPainterPath &path ) const override;
144 void drawAsPolygon( QPainter &p ) const override;
145 bool insertVertex( QgsVertexId position, const QgsPoint &vertex ) override;
146 bool moveVertex( QgsVertexId position, const QgsPoint &newPos ) override;
147 bool deleteVertex( QgsVertexId position ) override;
148 double closestSegment( const QgsPoint &pt, QgsPoint &segmentPt SIP_OUT, QgsVertexId &vertexAfter SIP_OUT, int *leftOf SIP_OUT = nullptr, double epsilon = 4 * std::numeric_limits<double>::epsilon() ) const override;
149 bool pointAt( int node, QgsPoint &point, Qgis::VertexType &type ) const override;
150 void sumUpArea( double &sum SIP_OUT ) const override;
151 bool hasCurvedSegments() const override;
152 double vertexAngle( QgsVertexId vertex ) const override;
153 double segmentLength( QgsVertexId startVertex ) const override;
154 QgsCircularString *reversed() const override SIP_FACTORY;
155 QgsPoint *interpolatePoint( double distance ) const override SIP_FACTORY;
156 QgsCircularString *curveSubstring( double startDistance, double endDistance ) const override SIP_FACTORY;
157 bool addZValue( double zValue = 0 ) override;
158 bool addMValue( double mValue = 0 ) override;
159 bool dropZValue() override;
160 bool dropMValue() override;
161 void swapXy() override;
162 double xAt( int index ) const override SIP_HOLDGIL;
163 double yAt( int index ) const override SIP_HOLDGIL;
164 double zAt( int index ) const override SIP_HOLDGIL;
165 double mAt( int index ) const override SIP_HOLDGIL;
166
167 bool transform( QgsAbstractGeometryTransformer *transformer, QgsFeedback *feedback = nullptr ) override;
168 void scroll( int firstVertexIndex ) final;
169
170#ifndef SIP_RUN
171 void filterVertices( const std::function< bool( const QgsPoint & ) > &filter ) override;
172 void transformVertices( const std::function< QgsPoint( const QgsPoint & ) > &transform ) override;
173 std::tuple< std::unique_ptr< QgsCurve >, std::unique_ptr< QgsCurve > > splitCurveAtVertex( int index ) const final;
174
182 inline static const QgsCircularString *cast( const QgsAbstractGeometry *geom )
183 {
185 return static_cast<const QgsCircularString *>( geom );
186 return nullptr;
187 }
188#endif
189
191
192#ifdef SIP_RUN
193 SIP_PYOBJECT __repr__();
194 % MethodCode
195 QString wkt = sipCpp->asWkt();
196 if ( wkt.length() > 1000 )
197 wkt = wkt.left( 1000 ) + QStringLiteral( "..." );
198 QString str = QStringLiteral( "<QgsCircularString: %1>" ).arg( wkt );
199 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
200 % End
201#endif
202
203 protected:
204
205 int compareToSameClass( const QgsAbstractGeometry *other ) const final;
206 QgsBox3D calculateBoundingBox3D() const override;
207
208 private:
209 QVector<double> mX;
210 QVector<double> mY;
211 QVector<double> mZ;
212 QVector<double> mM;
213
214#if 0
215 static void arcTo( QPainterPath &path, QPointF pt1, QPointF pt2, QPointF pt3 );
216#endif
217 //bounding box of a single segment
218 static QgsRectangle segmentBoundingBox( const QgsPoint &pt1, const QgsPoint &pt2, const QgsPoint &pt3 );
219 static QgsPointSequence compassPointsOnSegment( double p1Angle, double p2Angle, double p3Angle, double centerX, double centerY, double radius );
220 static double closestPointOnArc( double x1, double y1, double x2, double y2, double x3, double y3,
221 const QgsPoint &pt, QgsPoint &segmentPt, QgsVertexId &vertexAfter, int *leftOf, double epsilon );
222 void insertVertexBetween( int after, int before, int pointOnCircle );
223 void deleteVertex( int i );
224
225};
226
227// clazy:excludeall=qstring-allocations
228
229#endif // QGSCIRCULARSTRING_H
VertexType
Types of vertex.
Definition qgis.h:2223
@ CircularString
CircularString.
TransformDirection
Flags for raster layer temporal capabilities.
Definition qgis.h:1937
@ Forward
Forward transform (from source to destination)
An abstract base class for classes which transform geometries by transforming input points to output ...
Abstract base class for all geometries.
virtual bool addZValue(double zValue=0)=0
Adds a z-dimension to the geometry, initialized to a preset value.
virtual bool fromWkb(QgsConstWkbPtr &wkb)=0
Sets the geometry from a WKB string.
virtual bool moveVertex(QgsVertexId position, const QgsPoint &newPos)=0
Moves a vertex within the geometry.
SegmentationToleranceType
Segmentation tolerance as maximum angle or maximum difference between approximation and circle.
virtual double vertexAngle(QgsVertexId vertex) const =0
Returns approximate angle at a vertex.
virtual bool dropMValue()=0
Drops any measure values which exist in the geometry.
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.
AxisOrder
Axis order for GML generation.
@ XY
X comes before Y (or lon before lat)
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.
virtual QByteArray asWkb(WkbFlags flags=QgsAbstractGeometry::WkbFlags()) const =0
Returns a WKB representation of the geometry.
virtual QDomElement asGml2(QDomDocument &doc, int precision=17, const QString &ns="gml", AxisOrder axisOrder=QgsAbstractGeometry::AxisOrder::XY) const =0
Returns a GML2 representation of the geometry.
virtual bool addMValue(double mValue=0)=0
Adds a measure to the geometry, initialized to a preset value.
Qgis::WkbType wkbType() const
Returns the WKB type of the geometry.
virtual QgsAbstractGeometry * snappedToGrid(double hSpacing, double vSpacing, double dSpacing=0, double mSpacing=0) const =0
Makes a new geometry with all the points or vertices snapped to the closest point of the grid.
virtual bool insertVertex(QgsVertexId position, const QgsPoint &vertex)=0
Inserts a vertex into the geometry.
virtual void swapXy()=0
Swaps the x and y coordinates from the geometry.
virtual double length() const
Returns the planar, 2-dimensional length of the geometry.
virtual QString asWkt(int precision=17) const =0
Returns a WKT representation of the geometry.
virtual bool isEmpty() const
Returns true if the geometry is empty.
virtual json asJsonObject(int precision=17) const
Returns a json object representation of the geometry.
virtual QDomElement asGml3(QDomDocument &doc, int precision=17, const QString &ns="gml", AxisOrder axisOrder=QgsAbstractGeometry::AxisOrder::XY) const =0
Returns a GML3 representation of the geometry.
virtual bool fromWkt(const QString &wkt)=0
Sets the geometry from a WKT string.
virtual void transform(const QgsCoordinateTransform &ct, Qgis::TransformDirection d=Qgis::TransformDirection::Forward, bool transformZ=false)=0
Transforms the geometry using a coordinate transform.
virtual bool deleteVertex(QgsVertexId position)=0
Deletes a vertex within the geometry.
virtual bool hasCurvedSegments() const
Returns true if the geometry contains curved segments.
virtual void clear()=0
Clears the geometry, ie reset it to a null 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 bool dropZValue()=0
Drops any z-dimensions which exist in the geometry.
virtual int dimension() const =0
Returns the inherent dimension of the geometry.
virtual double segmentLength(QgsVertexId startVertex) const =0
Returns the length of the segment of the geometry which begins at startVertex.
virtual bool removeDuplicateNodes(double epsilon=4 *std::numeric_limits< double >::epsilon(), bool useZValues=false)=0
Removes duplicate nodes from the geometry, wherever removing the nodes does not result in a degenerat...
virtual int wkbSize(QgsAbstractGeometry::WkbFlags flags=QgsAbstractGeometry::WkbFlags()) const =0
Returns the length of the QByteArray returned by asWkb()
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...
virtual double closestSegment(const QgsPoint &pt, QgsPoint &segmentPt, QgsVertexId &vertexAfter, int *leftOf=nullptr, double epsilon=4 *std::numeric_limits< double >::epsilon()) const =0
Searches for the closest segment of the geometry to a given point.
A 3-dimensional box composed of x, y, z coordinates.
Definition qgsbox3d.h:44
Circular string geometry type.
static const QgsCircularString * cast(const QgsAbstractGeometry *geom)
Cast the geom to a QgsCircularString.
A const WKB pointer.
Definition qgswkbptr.h:138
Class for doing transforms between two map coordinate systems.
Custom exception class for Coordinate Reference System related exceptions.
Abstract base class for curved geometry type.
Definition qgscurve.h:36
virtual bool equals(const QgsCurve &other) const =0
Checks whether this curve exactly equals another curve.
virtual int numPoints() const =0
Returns the number of points in the curve.
virtual void scroll(int firstVertexIndex)=0
Scrolls the curve vertices so that they start with the vertex at the given index.
virtual bool pointAt(int node, QgsPoint &point, Qgis::VertexType &type) const =0
Returns the point and vertex id of a point within the curve.
virtual QgsCurve * curveSubstring(double startDistance, double endDistance) const =0
Returns a new curve representing a substring of this curve.
bool isValid(QString &error, Qgis::GeometryValidityFlags flags=Qgis::GeometryValidityFlags()) const override
Checks validity of the geometry, and returns true if the geometry is valid.
Definition qgscurve.cpp:247
virtual void addToPainterPath(QPainterPath &path) const =0
Adds a curve to a painter path.
virtual int indexOf(const QgsPoint &point) const =0
Returns the index of the first vertex matching the given point, or -1 if a matching vertex is not fou...
virtual void sumUpArea(double &sum) const =0
Sums up the area of the curve by iterating over the vertices (shoelace formula).
virtual QgsPoint * interpolatePoint(double distance) const =0
Returns an interpolated point on the curve at the specified distance.
QgsCurve * clone() const override=0
Clones the geometry by performing a deep copy.
virtual double xAt(int index) const =0
Returns the x-coordinate of the specified node in the line string.
virtual QgsPoint startPoint() const =0
Returns the starting point of the curve.
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...
virtual double zAt(int index) const =0
Returns the z-coordinate of the specified node in the line string.
virtual QgsCurve * reversed() const =0
Returns a reversed copy of the curve, where the direction of the curve has been flipped.
virtual void drawAsPolygon(QPainter &p) const =0
Draws the curve as a polygon on the specified QPainter.
virtual double mAt(int index) const =0
Returns the m-coordinate of the specified node in the line string.
virtual QgsPoint endPoint() const =0
Returns the end point of the curve.
virtual double yAt(int index) const =0
Returns the y-coordinate of the specified node in the line string.
virtual void points(QgsPointSequence &pt) const =0
Returns a list of points within the curve.
virtual QgsLineString * curveToLine(double tolerance=M_PI_2/90, SegmentationToleranceType toleranceType=MaximumAngle) const =0
Returns a new line string geometry corresponding to a segmentized approximation of the curve.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition qgsfeedback.h:45
Line string geometry type, with support for z-dimension and m-values.
Point geometry type, with support for z-dimension and m-values.
Definition qgspoint.h:49
A rectangle specified with double values.
static Qgis::WkbType flatType(Qgis::WkbType type)
Returns the flat type for a WKB type.
#define str(x)
Definition qgis.cpp:38
#define SIP_SKIP
Definition qgis_sip.h:126
#define SIP_OUT
Definition qgis_sip.h:58
#define SIP_HOLDGIL
Definition qgis_sip.h:166
#define SIP_FACTORY
Definition qgis_sip.h:76
#define SIP_THROW(name,...)
Definition qgis_sip.h:198
QVector< QgsPoint > QgsPointSequence
void arcTo(QPainterPath &path, QPointF pt1, QPointF pt2, QPointF pt3)
int precision
Utility class for identifying a unique vertex within a geometry.
Definition qgsvertexid.h:31