From 627a31d3e3392e0d4121093de986689e32782715 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laura=20Kl=C3=BCnder?= Date: Fri, 20 Oct 2017 00:51:30 +0200 Subject: [PATCH] filter out undrawable geometries --- src/c3nav/mapdata/utils/svg.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/c3nav/mapdata/utils/svg.py b/src/c3nav/mapdata/utils/svg.py index 20379dfb..d2e312c5 100644 --- a/src/c3nav/mapdata/utils/svg.py +++ b/src/c3nav/mapdata/utils/svg.py @@ -201,6 +201,17 @@ class SVGImage: # if altitude is set, the geometry will get a calculated shadow relative to the other geometries # if elevation is set, the geometry will get a shadow with exactly this elevation + # if fill_color is set, filter out geometries that cannot be filled + if fill_color is not None: + try: + geometry.geoms + except AttributeError: + pass + else: + geometry = type(geometry)(tuple(geom for geom in geometry.geoms if hasattr(geom, 'exterior'))) + if geometry.is_empty: + pass + attribs = ' fill="'+(fill_color or 'none')+'"' if fill_opacity: attribs += ' fill-opacity="'+str(fill_opacity)[:4]+'"'