Correction in number/float detection for floors, as it caused another crash in overnight rendering.
This commit is contained in:
parent
6f9d8d9dd5
commit
e3c8e6bd14
18
osmxml.py
18
osmxml.py
@ -205,6 +205,19 @@ class mstr_osmxml:
|
||||
return surface
|
||||
|
||||
|
||||
# Again, a crash on number checking of levels.
|
||||
# Short call for sanity check
|
||||
def is_float(self, element: any) -> bool:
|
||||
#If you expect None to be passed:
|
||||
if element is None:
|
||||
return False
|
||||
try:
|
||||
float(element)
|
||||
return True
|
||||
except ValueError:
|
||||
return False
|
||||
|
||||
|
||||
# Find the levels of a building (for shadow rendering)
|
||||
def find_building_levels(self, way_id):
|
||||
lvl = 2 # Standard if we don't find anything else
|
||||
@ -217,8 +230,9 @@ class mstr_osmxml:
|
||||
a = tag.getAttribute("k")
|
||||
v = tag.getAttribute("v")
|
||||
if a == "building:levels":
|
||||
lvl = int(float(v)) # <- This blew layergen and maskgen at some buildings with 1.5 floors
|
||||
break
|
||||
if self.is_float(v) == True:
|
||||
lvl = int(float(v)) # <- This blew layergen and maskgen at some buildings with 1.5 floors
|
||||
break
|
||||
return lvl
|
||||
|
||||
# Find minimum level of a building
|
||||
|
Loading…
x
Reference in New Issue
Block a user