fix possible error with good_representative_point
This commit is contained in:
parent
5bdfe73f6e
commit
cb57090f13
1 changed files with 5 additions and 1 deletions
|
@ -72,7 +72,11 @@ def good_representative_point(geometry):
|
|||
if isinstance(geometry, Point):
|
||||
return geometry
|
||||
c = geometry.centroid
|
||||
x1, y1, x2, y2 = geometry.bounds
|
||||
try:
|
||||
x1, y1, x2, y2 = geometry.bounds
|
||||
except ValueError:
|
||||
# jup, this can happen
|
||||
return c
|
||||
lines = (tuple(assert_multilinestring(LineString(((x1, c.y), (x2, c.y))).intersection(geometry))) +
|
||||
tuple(assert_multilinestring(LineString(((c.x, y1), (c.x, y2))).intersection(geometry))))
|
||||
return min(lines, key=lambda line: (line.distance(c), line.length),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue