Subgroup: Line

Class: QgsLineSegment2D

class qgis.core.QgsLineSegment2D(start: QgsPointXY, end: QgsPointXY)

Bases: sip.wrapper

Constructor for a QgsLineSegment2D from the specified start point to the end point.

QgsLineSegment2D(x1: float, y1: float, x2: float, y2: float) Constructor for a QgsLineSegment2D from the point (x1, y2) to (x2, y2).

QgsLineSegment2D(QgsLineSegment2D)

Represents a single 2D line segment, consisting of a 2D start and end vertex only.

New in version 3.2: Methods

end Returns the segment’s end point.
endX Returns the segment’s end x-coordinate.
endY Returns the segment’s end y-coordinate.
length Returns the length of the segment.
lengthSquared Returns the squared length of the segment.
pointLeftOfLine Tests if a point is to the left of the line segment.
reverse Reverses the line segment, so that the start and end points are flipped.
setEnd Sets the segment’s end point.
setEndX Sets the segment’s end x coordinate.
setEndY Sets the segment’s end y coordinate.
setStart Sets the segment’s start point.
setStartX Sets the segment’s start x coordinate.
setStartY Sets the segment’s start y coordinate.
start Returns the segment’s start point.
startX Returns the segment’s start x-coordinate.
startY Returns the segment’s start y-coordinate.

Signals

Attributes

end(self) → QgsPointXY

Returns the segment’s end point.

See also

start()

See also

endX()

See also

endY()

endX(self) → float

Returns the segment’s end x-coordinate.

See also

end()

See also

endY()

endY(self) → float

Returns the segment’s end y-coordinate.

See also

end()

See also

endX()

length(self) → float

Returns the length of the segment.

See also

lengthSquared()

lengthSquared(self) → float

Returns the squared length of the segment.

See also

length()

pointLeftOfLine(self, point: QgsPointXY) → int

Tests if a point is to the left of the line segment.

Returns -1 if the point falls to the left of the line, or +1 if the point is to the right.

If the return value is 0, then the test was unsuccessful (e.g. due to testing a point exactly on the line, or exactly in line with the segment) and the result is undefined.

reverse(self)

Reverses the line segment, so that the start and end points are flipped.

setEnd(self, end: QgsPointXY)

Sets the segment’s end point.

See also

setEndX()

See also

setEndY()

See also

setStart()

setEndX(self, x: float)

Sets the segment’s end x coordinate.

See also

setStartX()

See also

setEnd()

See also

setEndY()

setEndY(self, y: float)

Sets the segment’s end y coordinate.

See also

setStartY()

See also

setEnd()

See also

setEndX()

setStart(self, start: QgsPointXY)

Sets the segment’s start point.

See also

setStartX()

See also

setStartY()

See also

setEnd()

setStartX(self, x: float)

Sets the segment’s start x coordinate.

See also

setEndX()

See also

setStart()

See also

setStartY()

setStartY(self, y: float)

Sets the segment’s start y coordinate.

See also

setEndY()

See also

setStart()

See also

setStartX()

start(self) → QgsPointXY

Returns the segment’s start point.

See also

end()

See also

startX()

See also

startY()

startX(self) → float

Returns the segment’s start x-coordinate.

See also

start()

See also

startY()

startY(self) → float

Returns the segment’s start y-coordinate.

See also

start()

See also

startX()