|
23 | 23 | from urllib.parse import urlparse, urlunparse
|
24 | 24 | from urllib.request import urlopen, Request
|
25 | 25 |
|
26 |
| -from typing import Any, Union, Iterable, ByteString |
| 26 | +from typing import Any, Union, ByteString |
27 | 27 | from collections.abc import Sequence
|
28 | 28 |
|
29 | 29 | # Create named logger
|
@@ -108,7 +108,9 @@ def b(v: Any, encoding="utf-8", encodingErrors="strict") -> bytes:
|
108 | 108 |
|
109 | 109 |
|
110 | 110 | def u(
|
111 |
| - v: Union[bytes, str, None, int, ByteString], encoding="utf-8", encodingErrors="strict" |
| 111 | + v: Union[bytes, str, None, int, ByteString], |
| 112 | + encoding="utf-8", |
| 113 | + encodingErrors="strict", |
112 | 114 | ) -> str:
|
113 | 115 | if isinstance(v, bytes):
|
114 | 116 | # For python 3 decode bytes to str.
|
@@ -145,10 +147,12 @@ class _Array(array.array):
|
145 | 147 | def __repr__(self):
|
146 | 148 | return str(self.tolist())
|
147 | 149 |
|
| 150 | + |
148 | 151 | Point_T = Sequence[float]
|
149 | 152 | Coords_T = Sequence[Point_T]
|
150 | 153 | BBox_T = tuple[float, float, float, float]
|
151 | 154 |
|
| 155 | + |
152 | 156 | def signed_area(coords: Coords_T, fast: bool = False) -> float:
|
153 | 157 | """Return the signed area enclosed by a ring using the linear time
|
154 | 158 | algorithm. A value >= 0 indicates a counter-clockwise oriented ring.
|
@@ -185,19 +189,15 @@ def ring_bbox(coords: Coords_T) -> BBox_T:
|
185 | 189 | return bbox
|
186 | 190 |
|
187 | 191 |
|
188 |
| -def bbox_overlap( |
189 |
| - bbox1: BBox_T, bbox2: BBox_T |
190 |
| -) -> bool: |
| 192 | +def bbox_overlap(bbox1: BBox_T, bbox2: BBox_T) -> bool: |
191 | 193 | """Tests whether two bounding boxes overlap, returning a boolean"""
|
192 | 194 | xmin1, ymin1, xmax1, ymax1 = bbox1
|
193 | 195 | xmin2, ymin2, xmax2, ymax2 = bbox2
|
194 | 196 | overlap = xmin1 <= xmax2 and xmax1 >= xmin2 and ymin1 <= ymax2 and ymax1 >= ymin2
|
195 | 197 | return overlap
|
196 | 198 |
|
197 | 199 |
|
198 |
| -def bbox_contains( |
199 |
| - bbox1: BBox_T, bbox2: BBox_T |
200 |
| -) -> bool: |
| 200 | +def bbox_contains(bbox1: BBox_T, bbox2: BBox_T) -> bool: |
201 | 201 | """Tests whether bbox1 fully contains bbox2, returning a boolean"""
|
202 | 202 | xmin1, ymin1, xmax1, ymax1 = bbox1
|
203 | 203 | xmin2, ymin2, xmax2, ymax2 = bbox2
|
@@ -250,9 +250,7 @@ def ring_contains_point(coords: Coords_T, p: Point_T) -> bool:
|
250 | 250 | return inside_flag
|
251 | 251 |
|
252 | 252 |
|
253 |
| -def ring_sample( |
254 |
| - coords: Coords_T, ccw: bool = False |
255 |
| -) -> Point_T: |
| 253 | +def ring_sample(coords: Coords_T, ccw: bool = False) -> Point_T: |
256 | 254 | """Return a sample point guaranteed to be within a ring, by efficiently
|
257 | 255 | finding the first centroid of a coordinate triplet whose orientation
|
258 | 256 | matches the orientation of the ring and passes the point-in-ring test.
|
|
0 commit comments