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

Module clipy

Functions to clip a path or polygon of LatLon points.


Version: 19.01.02

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, inull=False, closed=False)
Clip a polygon against a clip region or box using the Sutherland_Hodgman algorithm.
 
clipSH3(points, corners, inull=False, closed=False)
Clip a polygon against a clip region or box using the Sutherland_Hodgman algorithm.
Variables
  __all__ = _ALL_LAZY.clipy
Function Details

clipCS3(points, lowerleft, upperright, closed=False, inull=False)

 

Clip a path against a rectangular clip box using the Cohen-Sutherland algorithm.

Parameters:
  • 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 3-tuple (start, end, index) for each edge of the 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.
Raises:
  • ValueError - The lowerleft corner is not below and/or not to the left of the upperright corner.

clipSH(points, corners, inull=False, closed=False)

 

Clip a polygon against a clip region or box using the Sutherland_Hodgman algorithm.

Parameters:
  • 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.
  • inull - Optionally, include null edges (bool).
  • closed - Close the clipped points (bool).
Returns:
Yield the clipped points (LatLon[]).
Raises:
  • ValueError - Insufficient number of points or the corners specify a polar, zero-area, non-convex or otherwise invalid clip region.

clipSH3(points, corners, inull=False, closed=False)

 

Clip a polygon against a clip region or box using the Sutherland_Hodgman algorithm.

Parameters:
  • 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.
  • inull - Optionally, include null edges (bool).
  • closed - Close the clipped points (bool).
Returns:
Yield a 3-tuple (start, end, original) for each edge of the clipped polygon. The start and end points LatLon of the portion of the edge inside or on the clip region. The original bool indicates whether the edge is part of the original polygon or part of the clip region.
Raises:
  • ValueError - Insufficient number of points or the corners specify a polar, zero-area, non-convex or otherwise invalid clip region.