Class: QgsClipper¶
Trims lines and polygons to within a rectangular region.
The functions in this class are likely to be called from within a render loop and hence need to as CPU efficient as possible.
The main purpose of the functions in this class are to trim lines and polygons to lie within a rectangular region. This is necessary for drawing items to an X11 display which have a limit on the magnitude of the screen coordinates (+/- 32768, i.e. 16 bit integer).
Static Methods
Clips a line segment to a rectangle. |
|
Takes a linestring and clips it to clipExtent |
|
Trims the given feature to a rectangular box. |
|
Trims the given polygon to a rectangular box, by modifying the given polygon in place. |
Attributes
Maximum X-coordinate of the rectangular box used for clipping. |
|
Maximum Y-coordinate of the rectangular box used for clipping. |
|
Minimum X-coordinate of the rectangular box used for clipping. |
|
Minimum Y-coordinate of the rectangular box used for clipping. |
|
- class qgis.core.QgsClipper[source]¶
Bases:
object
- class Boundary¶
Bases:
int
- MAX_X: float = 16000.0¶
Maximum X-coordinate of the rectangular box used for clipping.
- MAX_Y: float = 16000.0¶
Maximum Y-coordinate of the rectangular box used for clipping.
- MIN_X: float = -16000.0¶
Minimum X-coordinate of the rectangular box used for clipping.
- MIN_Y: float = -16000.0¶
Minimum Y-coordinate of the rectangular box used for clipping.
- XMax = 0¶
- XMin = 1¶
- YMax = 2¶
- YMin = 3¶
- ZMax = 4¶
- ZMin = 5¶
- static clipLineSegment(left: float, right: float, bottom: float, top: float, x0: float, y0: float, x1: float, y1: float)[source]¶
Clips a line segment to a rectangle.
An implementation of the ‘Fast clipping’ algorithm (Sobkow et al. 1987, Computers & Graphics Vol.11, 4, p.459-467).
- Parameters:
left (float) – x-coordinate of left side of rectangle
right (float) – x-coordinate of right side of rectangle
bottom (float) – y-coordinate of bottom side of rectangle
top (float) – y-coordinate of top side of rectangle
x0 (float) – x-coordinate of start of line
y0 (float) – y-coordinate of start of line
x1 (float) – x-coordinate of end of line
y1 (float) -> (bool) – y-coordinate of end of line
- Returns:
True
if line was clipped.
Added in version 3.26.
- static clippedLine(curve: QgsCurve, clipExtent: QgsRectangle) QPolygonF [source]¶
Takes a linestring and clips it to clipExtent
- Parameters:
curve (
QgsCurve
) – the linestringclipExtent (
QgsRectangle
) – clipping bounds
- Return type:
QPolygonF
- Returns:
clipped line coordinates
- static clippedLine(curve: QPolygonF, clipExtent: QgsRectangle) QPolygonF [source]
Takes a 2D
curve
and clips it to clipExtent.- Parameters:
curve (QPolygonF) – the linestring
clipExtent (
QgsRectangle
) – clipping bounds
- Return type:
QPolygonF
- Returns:
clipped line coordinates
Added in version 3.16.
- static trimFeature(x: Iterable[float], y: Iterable[float], shapeOpen: bool)[source]¶
Trims the given feature to a rectangular box. Returns the trimmed feature in x and y. The shapeOpen parameter determines whether the function treats the points as a closed shape (polygon), or as an open shape (linestring).
Note
not available in Python bindings on android
- Parameters:
x (Iterable[float])
y (Iterable[float])
shapeOpen (bool)
- static trimPolygon(pts: QPolygonF, clipRect: QgsRectangle)[source]¶
Trims the given polygon to a rectangular box, by modifying the given polygon in place.
- Parameters:
pts (QPolygonF) – polygon as 2D coordinates
clipRect (QgsRectangle) – clipping rectangle