Package pygeodesy :: Module clipy |
[frames] | no frames]

# Module clipy

Functions to clip a path or polygon of `LatLon` points against a rectangular box or clip region.

Version: 20.04.15

Classes
| ClipError Clip box or clip region invalid.
| ClipCS3Tuple 3-Tuple `(start, end, index)` for each edge of a clipped path with the `start` and `end` points (`LatLon`) of the portion of the edge inside or on the clip box and the `index` (`int`) of the edge in the original path.
| ClipSH3Tuple 3-Tuple `(start, end, original)` for each edge of a clipped polygon, the `start` and `end` points (`LatLon`) of the portion of the edge inside or on the clip region and `original` indicates whether the edge is part of the original polygon or part of the clip region (`bool`).

Functions
clipCS3(points, lowerleft, upperright, closed=False, inull=False) Clip a path against a rectangular clip box using the Cohen-Sutherland algorithm. |
clipSH(points, corners, closed=False, inull=False) Clip a polygon against a clip region or box using the Sutherland-Hodgman algorithm. |
clipSH3(points, corners, closed=False, inull=False) Clip a polygon against a clip region or box using the Sutherland-Hodgman algorithm. |

Function Details

### clipCS3 (points, lowerleft, upperright, closed=False, inull=False) |
Clip a path against a rectangular clip box using the Cohen-Sutherland algorithm. Arguments: `points` - The points (`LatLon`[]). `lowerleft` - Bottom-left corner of the clip box (`LatLon`). `upperright` - Top-right corner of the clip box (`LatLon`). `closed` - Optionally, close the path (`bool`). `inull` - Optionally, include null edges if inside (`bool`). Returns: Yield a ClipCS3Tuple`(start, end, index)` for each edge of the clipped path. Raises: `ClipError` - The `lowerleft` and `upperright` corners specify an invalid clip box. `PointsError` - Insufficient number of `points`.

### clipSH (points, corners, closed=False, inull=False) |
Clip a polygon against a clip region or box using the Sutherland-Hodgman algorithm. Arguments: `points` - The polygon points (`LatLon`[]). `corners` - Three or more points defining a convex clip region (`LatLon`[]) or two points to specify a rectangular clip box. `closed` - Close the clipped points (`bool`). `inull` - Optionally, include null edges (`bool`). Returns: Yield the clipped points (`LatLon`[]). Raises: `ClipError` - The `corners` specify a polar, zero-area, non-convex or otherwise invalid clip box or region. `PointsError` - Insufficient number of `points`.

### clipSH3 (points, corners, closed=False, inull=False) |
Clip a polygon against a clip region or box using the Sutherland-Hodgman algorithm. Arguments: `points` - The polygon points (`LatLon`[]). `corners` - Three or more points defining a convex clip region (`LatLon`[]) or two points to specify a rectangular clip box. `closed` - Close the clipped points (`bool`). `inull` - Optionally, include null edges (`bool`). Returns: Yield a ClipSH3Tuple`(start, end, original)` for each edge of the clipped polygon. Raises: `ClipError` - The `corners` specify a polar, zero-area, non-convex or otherwise invalid clip box or region. `PointsError` - Insufficient number of `points`.