Class: QgsCompoundCurve

class qgis.core.QgsCompoundCurve

Bases: QgsCurve

Compound curve geometry type

Methods

addCurve

Adds a curve to the geometry (takes ownership).

addMValue

param mValue:

addToPainterPath

param path:

addVertex

Adds a vertex to the end of the geometry.

addZValue

param zValue:

asGml2

param doc:

asGml3

param doc:

asWkb

param flags:

asWkt

param precision:

boundingBoxIntersects

param box3d:

calculateBoundingBox

Default calculator for the minimal bounding box for the geometry.

calculateBoundingBox3D

rtype:

QgsBox3D

childCount

Returns number of child geometries (for geometries with child geometries) or child points (for geometries without child geometries - i.e. curve / point).

childGeometry

Returns pointer to child geometry (for geometries with child geometries - i.e. geom.

childPoint

Returns point at index (for geometries without child geometries - i.e. curve / point).

clear

clearCache

Clears any cached parameters associated with the geometry, e.g., bounding boxes

clone

rtype:

Optional[QgsCompoundCurve]

close

Appends first point if not already closed.

closestSegment

param pt:

compareToSameClass

param other:

condenseCurves

Condenses the curves in this geometry by combining adjacent linestrings a to a single continuous linestring, and combining adjacent circularstrings to a single continuous circularstring.

createEmptyWithSameType

rtype:

Optional[QgsCompoundCurve]

curveAt

Returns the curve at the specified index.

curveSubstring

param startDistance:

curveToLine

Returns a new line string geometry corresponding to a segmentized approximation of the curve.

deleteVertex

param position:

dimension

rtype:

int

draw

param p:

drawAsPolygon

param p:

dropMValue

rtype:

bool

dropZValue

rtype:

bool

endPoint

rtype:

QgsPoint

equals

param other:

fromWkb

param wkb:

fromWkt

param wkt:

fuzzyDistanceEqual

param other:

fuzzyEqual

param other:

geometryType

rtype:

str

hasChildGeometries

Returns whether the geometry has any child geometries (False for point / curve, True otherwise)

hasCurvedSegments

rtype:

bool

indexOf

param point:

insertVertex

param position:

interpolatePoint

param distance:

isEmpty

rtype:

bool

isValid

param flags:

length

rtype:

float

mAt

param index:

moveVertex

param position:

nCurves

Returns the number of curves in the geometry.

numPoints

rtype:

int

pointAt

param node:

points

rtype:

List[QgsPoint]

removeCurve

Removes a curve from the geometry.

removeDuplicateNodes

param epsilon:

reversed

rtype:

Optional[QgsCompoundCurve]

scroll

param firstVertexIndex:

segmentLength

param startVertex:

setZMTypeFromSubGeometry

Updates the geometry type based on whether sub geometries contain z or m values.

simplifiedTypeRef

rtype:

Optional[QgsAbstractGeometry]

snappedToGrid

param hSpacing:

sortIndex

Returns the sort index for the geometry, used in the compareTo() method to compare geometries of different types.

startPoint

rtype:

QgsPoint

sumUpArea

rtype:

float

swapXy

toggleCircularAtVertex

Converts the vertex at the given position from/to circular

transform

param ct:

vertexAngle

param vertex:

wkbSize

param flags:

xAt

param index:

yAt

param index:

zAt

param index:

addCurve(self, c: QgsCurve | None, extendPrevious: bool = False)

Adds a curve to the geometry (takes ownership).

Since QGIS 3.20, if extendPrevious is True, then adding a LineString when the last existing curve in the compound curve is also a LineString will cause the existing linestring to be extended with the newly added LineString vertices instead of appending a whole new LineString curve to the compound curve. This can result in simplified compound curves with lesser number of component curves while still being topologically identical to the desired result.

Parameters:
  • c (Optional[QgsCurve])

  • extendPrevious (bool = False)

addMValue(self, mValue: float = 0) bool
Parameters:

mValue (float = 0)

Return type:

bool

addToPainterPath(self, path: QPainterPath)
Parameters:

path (QPainterPath)

addVertex(self, pt: QgsPoint)

Adds a vertex to the end of the geometry.

Parameters:

pt (QgsPoint)

addZValue(self, zValue: float = 0) bool
Parameters:

zValue (float = 0)

Return type:

bool

asGml2(self, doc: QDomDocument, precision: int = 17, ns: str | None = '', axisOrder: QgsAbstractGeometry.AxisOrder = QgsAbstractGeometry.AxisOrder.XY) QDomElement
Parameters:
  • doc (QDomDocument)

  • precision (int = 17)

  • ns (Optional[str] = '')

  • axisOrder (QgsAbstractGeometry.AxisOrder = QgsAbstractGeometry.AxisOrder.XY)

Return type:

QDomElement

asGml3(self, doc: QDomDocument, precision: int = 17, ns: str | None = '', axisOrder: QgsAbstractGeometry.AxisOrder = QgsAbstractGeometry.AxisOrder.XY) QDomElement
Parameters:
  • doc (QDomDocument)

  • precision (int = 17)

  • ns (Optional[str] = '')

  • axisOrder (QgsAbstractGeometry.AxisOrder = QgsAbstractGeometry.AxisOrder.XY)

Return type:

QDomElement

asWkb(self, flags: QgsAbstractGeometry.WkbFlags | QgsAbstractGeometry.WkbFlag = QgsAbstractGeometry.WkbFlags()) QByteArray
Parameters:

flags (Union[QgsAbstractGeometry.WkbFlags)

Return type:

QByteArray

asWkt(self, precision: int = 17) str
Parameters:

precision (int = 17)

Return type:

str

boundingBoxIntersects(self, box3d: QgsBox3D) bool
Parameters:

box3d (QgsBox3D)

Return type:

bool

calculateBoundingBox(self) QgsRectangle

Default calculator for the minimal bounding box for the geometry. Derived classes should override this method if a more efficient bounding box calculation is available.

calculateBoundingBox3D(self) QgsBox3D
Return type:

QgsBox3D

childCount(self) int

Returns number of child geometries (for geometries with child geometries) or child points (for geometries without child geometries - i.e. curve / point)

Note

used for vertex_iterator implementation

childGeometry(self, index: int) QgsAbstractGeometry | None

Returns pointer to child geometry (for geometries with child geometries - i.e. geom. collection / polygon)

Note

used for vertex_iterator implementation

childPoint(self, index: int) QgsPoint

Returns point at index (for geometries without child geometries - i.e. curve / point)

Note

used for vertex_iterator implementation

clear(self)
clearCache(self)

Clears any cached parameters associated with the geometry, e.g., bounding boxes

clone(self) QgsCompoundCurve | None
Return type:

Optional[QgsCompoundCurve]

close(self)

Appends first point if not already closed.

closestSegment(self, pt: QgsPoint, epsilon: float = 4 * DBL_EPSILON)
Parameters:
  • pt (QgsPoint)

  • epsilon (float = 4*DBL_EPSILON) -> (float)

compareToSameClass(self, other: QgsAbstractGeometry | None) int
Parameters:

other (Optional[QgsAbstractGeometry])

Return type:

int

condenseCurves(self)

Condenses the curves in this geometry by combining adjacent linestrings a to a single continuous linestring, and combining adjacent circularstrings to a single continuous circularstring.

Added in version 3.20.

createEmptyWithSameType(self) QgsCompoundCurve | None
Return type:

Optional[QgsCompoundCurve]

curveAt(self, i: int) QgsCurve | None

Returns the curve at the specified index.

Parameters:

i (int)

Return type:

Optional[QgsCurve]

curveSubstring(self, startDistance: float, endDistance: float) QgsCompoundCurve | None
Parameters:
  • startDistance (float)

  • endDistance (float)

Return type:

Optional[QgsCompoundCurve]

curveToLine(self, tolerance: float = M_PI_2 / 90, toleranceType: QgsAbstractGeometry.SegmentationToleranceType = QgsAbstractGeometry.MaximumAngle) QgsLineString | None

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

Return type:

Optional[QgsLineString]

deleteVertex(self, position: QgsVertexId) bool
Parameters:

position (QgsVertexId)

Return type:

bool

dimension(self) int
Return type:

int

draw(self, p: QPainter)
Parameters:

p (QPainter)

drawAsPolygon(self, p: QPainter)
Parameters:

p (QPainter)

dropMValue(self) bool
Return type:

bool

dropZValue(self) bool
Return type:

bool

endPoint(self) QgsPoint
Return type:

QgsPoint

equals(self, other: QgsCurve) bool
Parameters:

other (QgsCurve)

Return type:

bool

fromWkb(self, wkb: QgsConstWkbPtr) bool
Parameters:

wkb (QgsConstWkbPtr)

Return type:

bool

fromWkt(self, wkt: str | None) bool
Parameters:

wkt (Optional[str])

Return type:

bool

fuzzyDistanceEqual(self, other: QgsAbstractGeometry, epsilon: float = 1e-08) bool
Parameters:
Return type:

bool

fuzzyEqual(self, other: QgsAbstractGeometry, epsilon: float = 1e-08) bool
Parameters:
Return type:

bool

geometryType(self) str
Return type:

str

hasChildGeometries(self) bool

Returns whether the geometry has any child geometries (False for point / curve, True otherwise)

Note

used for vertex_iterator implementation

hasCurvedSegments(self) bool
Return type:

bool

indexOf(self, point: QgsPoint) int
Parameters:

point (QgsPoint)

Return type:

int

insertVertex(self, position: QgsVertexId, vertex: QgsPoint) bool
Parameters:
Return type:

bool

interpolatePoint(self, distance: float) QgsPoint | None
Parameters:

distance (float)

Return type:

Optional[QgsPoint]

isEmpty(self) bool
Return type:

bool

isValid(self, flags: Qgis.GeometryValidityFlags | Qgis.GeometryValidityFlag = Qgis.GeometryValidityFlags())
Parameters:

flags (Union[Qgis.GeometryValidityFlags)

length(self) float
Return type:

float

mAt(self, index: int) float
Parameters:

index (int)

Return type:

float

moveVertex(self, position: QgsVertexId, newPos: QgsPoint) bool
Parameters:
Return type:

bool

nCurves(self) int

Returns the number of curves in the geometry.

Return type:

int

numPoints(self) int
Return type:

int

pointAt(self, node: int, point: QgsPoint)
Parameters:
points(self) List[QgsPoint]
Return type:

List[QgsPoint]

removeCurve(self, i: int)

Removes a curve from the geometry.

Parameters:

i (int) – index of curve to remove

removeDuplicateNodes(self, epsilon: float = 4 * DBL_EPSILON, useZValues: bool = False) bool
Parameters:
  • epsilon (float = 4*DBL_EPSILON)

  • useZValues (bool = False)

Return type:

bool

reversed(self) QgsCompoundCurve | None
Return type:

Optional[QgsCompoundCurve]

scroll(self, firstVertexIndex: int)
Parameters:

firstVertexIndex (int)

segmentLength(self, startVertex: QgsVertexId) float
Parameters:

startVertex (QgsVertexId)

Return type:

float

setZMTypeFromSubGeometry(self, subggeom: QgsAbstractGeometry | None, baseGeomType: Qgis.WkbType)

Updates the geometry type based on whether sub geometries contain z or m values.

simplifiedTypeRef(self) QgsAbstractGeometry | None
Return type:

Optional[QgsAbstractGeometry]

snappedToGrid(self, hSpacing: float, vSpacing: float, dSpacing: float = 0, mSpacing: float = 0) QgsCompoundCurve | None
Parameters:
  • hSpacing (float)

  • vSpacing (float)

  • dSpacing (float = 0)

  • mSpacing (float = 0)

Return type:

Optional[QgsCompoundCurve]

sortIndex(self) int

Returns the sort index for the geometry, used in the compareTo() method to compare geometries of different types.

Added in version 3.20.

startPoint(self) QgsPoint
Return type:

QgsPoint

sumUpArea(self) float
Return type:

float

swapXy(self)
toggleCircularAtVertex(self, position: QgsVertexId) bool

Converts the vertex at the given position from/to circular

Return type:

bool

Returns:

False if atVertex does not correspond to a valid vertex on this geometry (including if this geometry is a Point), or if the specified vertex can’t be converted (e.g. start/end points).

Added in version 3.20.

Parameters:

position (QgsVertexId)

transform(self, ct: QgsCoordinateTransform, d: Qgis.TransformDirection = Qgis.TransformDirection.Forward, transformZ: bool = False)
transform(self, t: QTransform, zTranslate: float = 0, zScale: float = 1, mTranslate: float = 0, mScale: float = 1) None
transform(self, transformer: QgsAbstractGeometryTransformer | None, feedback: QgsFeedback | None = None) bool
Parameters:
  • ct (QgsCoordinateTransform)

  • d (Qgis.TransformDirection = Qgis.TransformDirection.Forward)

  • transformZ (bool = False)

vertexAngle(self, vertex: QgsVertexId) float
Parameters:

vertex (QgsVertexId)

Return type:

float

wkbSize(self, flags: QgsAbstractGeometry.WkbFlags | QgsAbstractGeometry.WkbFlag = QgsAbstractGeometry.WkbFlags()) int
Parameters:

flags (Union[QgsAbstractGeometry.WkbFlags)

Return type:

int

xAt(self, index: int) float
Parameters:

index (int)

Return type:

float

yAt(self, index: int) float
Parameters:

index (int)

Return type:

float

zAt(self, index: int) float
Parameters:

index (int)

Return type:

float