Class: QgsCurve¶
Abstract base class for curved geometry type.
Note
This is an abstract class, with methods which must be implemented by a subclass.
The following methods must be implemented: QgsAbstractGeometry.addMValue()
, addToPainterPath()
, QgsAbstractGeometry.addZValue()
, QgsAbstractGeometry.asGml2()
, QgsAbstractGeometry.asGml3()
, QgsAbstractGeometry.asWkb()
, QgsAbstractGeometry.asWkt()
, QgsAbstractGeometry.clear()
, QgsAbstractGeometry.closestSegment()
, QgsAbstractGeometry.compareToSameClass()
, QgsAbstractGeometry.createEmptyWithSameType()
, curveSubstring()
, curveToLine()
, QgsAbstractGeometry.deleteVertex()
, QgsAbstractGeometry.dimension()
, QgsAbstractGeometry.draw()
, drawAsPolygon()
, QgsAbstractGeometry.dropMValue()
, QgsAbstractGeometry.dropZValue()
, endPoint()
, equals()
, QgsAbstractGeometry.fromWkb()
, QgsAbstractGeometry.fromWkt()
, QgsAbstractGeometry.fuzzyDistanceEqual()
, QgsAbstractGeometry.fuzzyEqual()
, QgsAbstractGeometry.geometryType()
, indexOf()
, QgsAbstractGeometry.insertVertex()
, interpolatePoint()
, mAt()
, QgsAbstractGeometry.moveVertex()
, numPoints()
, pointAt()
, points()
, QgsAbstractGeometry.removeDuplicateNodes()
, reversed()
, scroll()
, QgsAbstractGeometry.segmentLength()
, QgsAbstractGeometry.simplifyByDistance()
, QgsAbstractGeometry.snappedToGrid()
, startPoint()
, sumUpArea()
, QgsAbstractGeometry.swapXy()
, QgsAbstractGeometry.transform()
, QgsAbstractGeometry.vertexAngle()
, QgsAbstractGeometry.wkbSize()
, xAt()
, yAt()
, zAt()
Class Hierarchy¶
Base classes¶
Abstract base class for all geometries. |
Subclasses¶
Circular string geometry type. |
|
Compound curve geometry type. |
|
Line string geometry type, with support for z-dimension and m-values. |
Enums
alias of |
Abstract Methods
Adds a curve to a painter path. |
|
Returns a new curve representing a substring of this curve. |
|
Returns a new line string geometry corresponding to a segmentized approximation of the curve. |
|
Draws the curve as a polygon on the specified QPainter. |
|
Returns the end point of the curve. |
|
Checks whether this curve exactly equals another curve. |
|
Returns the index of the first vertex matching the given point, or -1 if a matching vertex is not found. |
|
Returns an interpolated point on the curve at the specified distance. |
|
Returns the m-coordinate of the specified node in the line string. |
|
Returns the number of points in the curve. |
|
Returns the point and vertex id of a point within the curve. |
|
Returns a list of points within the curve. |
|
Returns a reversed copy of the curve, where the direction of the curve has been flipped. |
|
Scrolls the curve vertices so that they start with the vertex at the given index. |
|
Returns the starting point of the curve. |
|
Sums up the area of the curve by iterating over the vertices (shoelace formula). |
|
Returns the x-coordinate of the specified node in the line string. |
|
Returns the y-coordinate of the specified node in the line string. |
|
Returns the z-coordinate of the specified node in the line string. |
Methods
Returns the curve's orientation, e.g. clockwise or counter-clockwise. |
|
Returns the curve sinuosity, which is the ratio of the curve |
|
Returns the straight distance of the curve, i.e. the direct/euclidean distance between the first and last vertex of the curve. |
Virtual Methods
In PyQGIS, only methods marked as virtual
can be safely overridden in a Python subclass of QgsCurve. See the FAQ for more details.
Returns a QPolygonF representing the points. |
|
Returns |
|
Returns true if the curve is closed. |
|
Returns |
|
Returns a geometry without curves. |
- class qgis.core.QgsCurve[source]¶
Bases:
QgsAbstractGeometry
- Orientation¶
alias of
AngularDirection
- abstract addToPainterPath(self, path: QPainterPath)[source]¶
Adds a curve to a painter path.
- Parameters:
path (QPainterPath)
- virtual asQPolygonF(self) QPolygonF [source]¶
Returns a QPolygonF representing the points.
- Return type:
QPolygonF
- abstract curveSubstring(self, startDistance: float, endDistance: float) QgsCurve | None [source]¶
Returns a new curve representing a substring of this curve.
The
startDistance
andendDistance
arguments specify the length along the curve which the substring should start and end at. If theendDistance
is greater than the total length of the curve then any “extra” length will be ignored.If z or m values are present, the output z and m will be interpolated using the existing vertices’ z or m values.
Added in version 3.4.
- Parameters:
startDistance (float)
endDistance (float)
- Return type:
Optional[QgsCurve]
- abstract curveToLine(self, tolerance: float = M_PI_2 / 90, toleranceType: QgsAbstractGeometry.SegmentationToleranceType = QgsAbstractGeometry.MaximumAngle) QgsLineString | None [source]¶
Returns a new line string geometry corresponding to a segmentized approximation of the curve.
- Parameters:
tolerance (float = M_PI_2/90) – segmentation tolerance
toleranceType (QgsAbstractGeometry.SegmentationToleranceType = QgsAbstractGeometry.MaximumAngle) – maximum segmentation angle or maximum difference between approximation and curve
Uses a MaximumAngle tolerance of 1 degrees by default (360 segments in a full circle)
- Return type:
Optional[QgsLineString]
- abstract drawAsPolygon(self, p: QPainter)[source]¶
Draws the curve as a polygon on the specified QPainter.
- Parameters:
p (QPainter) – destination QPainter
- abstract endPoint(self) QgsPoint [source]¶
Returns the end point of the curve.
See also
- Return type:
- abstract equals(self, other: QgsCurve) bool [source]¶
Checks whether this curve exactly equals another curve.
- Parameters:
other (QgsCurve)
- Return type:
bool
- abstract indexOf(self, point: QgsPoint) int [source]¶
Returns the index of the first vertex matching the given
point
, or -1 if a matching vertex is not found.Note
If the curve has m or z values then the search
point
must have exactly matching m and z values in order to be matched against the curve’s vertices.Note
This method only matches against segment vertices, not curve vertices.
Added in version 3.20.
- Parameters:
point (QgsPoint)
- Return type:
int
- abstract interpolatePoint(self, distance: float) QgsPoint | None [source]¶
Returns an interpolated point on the curve at the specified
distance
.If z or m values are present, the output z and m will be interpolated using the existing vertices’ z or m values.
If distance is negative, or is greater than the length of the curve,
None
will be returned.Added in version 3.4.
- Parameters:
distance (float)
- Return type:
Optional[QgsPoint]
- virtual isClosed(self) bool [source]¶
Returns
True
if the curve is closed.See also
- Return type:
bool
- virtual isClosed2D(self) bool [source]¶
Returns true if the curve is closed.
Unlike isClosed. It looks only for XY coordinates.
See also
Added in version 3.20.
- Return type:
bool
- abstract mAt(self, index: int) float [source]¶
Returns the m-coordinate of the specified node in the line string.
- Parameters:
index (int) – index of node, where the first node in the line is 0
- Return type:
float
- Returns:
m-coordinate of node, or 0.0 if index is out of bounds
Added in version 3.28.
- orientation(self) Qgis.AngularDirection [source]¶
Returns the curve’s orientation, e.g. clockwise or counter-clockwise.
Warning
The result is not predictable for non-closed curves.
Added in version 3.6.
- Return type:
- abstract pointAt(self, node: int)[source]¶
Returns the point and vertex id of a point within the curve.
- Parameters:
node (int) -> (bool) – node number, where the first node is 0
- Returns:
True
if node exists within the curvepoint: point at corresponding node in the curve
type: the vertex type of the node
- abstract points(self) List[QgsPoint] [source]¶
Returns a list of points within the curve.
- Return type:
List[QgsPoint]
- abstract reversed(self) QgsCurve | None [source]¶
Returns a reversed copy of the curve, where the direction of the curve has been flipped.
- Return type:
Optional[QgsCurve]
- abstract scroll(self, firstVertexIndex: int)[source]¶
Scrolls the curve vertices so that they start with the vertex at the given index.
Warning
This should only be called on closed curves, or the shape of the curve will be altered and the result is undefined.
Warning
The
firstVertexIndex
must correspond to a segment vertex and not a curve point or the result is undefined.Added in version 3.20.
- Parameters:
firstVertexIndex (int)
- virtual segmentize(self, tolerance: float = M_PI_2 / 90, toleranceType: QgsAbstractGeometry.SegmentationToleranceType = QgsAbstractGeometry.MaximumAngle) QgsCurve | None [source]¶
Returns a geometry without curves. Caller takes ownership
- Parameters:
tolerance (float = M_PI_2/90) – segmentation tolerance
toleranceType (QgsAbstractGeometry.SegmentationToleranceType = QgsAbstractGeometry.MaximumAngle) – maximum segmentation angle or maximum difference between approximation and curve
- Return type:
Optional[QgsCurve]
- sinuosity(self) float [source]¶
Returns the curve sinuosity, which is the ratio of the curve
length()
to curvestraightDistance2d()
. Larger numbers indicate a more “sinuous” curve (i.e. more “bendy”). The minimum value returned of 1.0 indicates a perfectly straight curve.If a curve
isClosed()
, it has infinite sinuosity and will return NaN.Added in version 3.2.
- Return type:
float
- abstract startPoint(self) QgsPoint [source]¶
Returns the starting point of the curve.
See also
- Return type:
- straightDistance2d(self) float [source]¶
Returns the straight distance of the curve, i.e. the direct/euclidean distance between the first and last vertex of the curve. (Also known as “as the crow flies” distance).
Added in version 3.2.
- Return type:
float
- abstract sumUpArea(self) float [source]¶
Sums up the area of the curve by iterating over the vertices (shoelace formula).
- Return type:
float
- abstract xAt(self, index: int) float [source]¶
Returns the x-coordinate of the specified node in the line string.
- Parameters:
index (int) – index of node, where the first node in the line is 0
- Return type:
float
- Returns:
x-coordinate of node, or 0.0 if index is out of bounds