Fix handling of empty polys in the new UI.

This was copied from the Qt map and tweaked, but the use cases are
slightly different so this needs to return an empty list for an empty
polygon instead of None.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/1121
This commit is contained in:
Dan Albert 2021-05-25 19:19:45 -07:00
parent de9651533f
commit 81ce7fbb62

View File

@ -52,9 +52,9 @@ LeafletLatLon = List[float]
def shapely_poly_to_leaflet_points(
poly: Polygon, theater: ConflictTheater
) -> Optional[List[LeafletLatLon]]:
) -> List[LeafletLatLon]:
if poly.is_empty:
return None
return []
return [theater.point_to_ll(Point(x, y)).as_list() for x, y in poly.exterior.coords]