don't crash
This commit is contained in:
parent
aab85fe32e
commit
d6d20ccd37
13 changed files with 2630 additions and 3924 deletions
|
|
@ -4,7 +4,8 @@ import numpy as np
|
|||
from scipy.spatial import QhullError, Voronoi
|
||||
from shapely import make_valid
|
||||
from shapely.geometry import MultiPolygon, Polygon
|
||||
from shapely.ops import unary_union
|
||||
|
||||
from .geometry import safe_intersection, safe_union
|
||||
|
||||
|
||||
def compute_voronoi_regions(
|
||||
|
|
@ -111,13 +112,13 @@ def compute_voronoi_regions(
|
|||
poly = Polygon(vertices)
|
||||
if not poly.is_valid:
|
||||
poly = make_valid(poly)
|
||||
clipped = poly.intersection(boundary)
|
||||
clipped = safe_intersection(poly, boundary)
|
||||
if not clipped.is_empty:
|
||||
pc_polys[unique_pcs[i]].append(clipped)
|
||||
|
||||
result = {}
|
||||
for pc, parts in pc_polys.items():
|
||||
merged = unary_union(parts)
|
||||
merged = safe_union(parts)
|
||||
if not merged.is_empty:
|
||||
result[pc] = merged
|
||||
return result
|
||||
|
|
@ -143,7 +144,7 @@ def _equal_split_fallback(
|
|||
(min_x, strip_max_y),
|
||||
]
|
||||
)
|
||||
clipped = boundary.intersection(strip)
|
||||
clipped = safe_intersection(boundary, strip)
|
||||
if not clipped.is_empty:
|
||||
result[pc] = clipped
|
||||
return result
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue