Correction in number/float detection for floors, as it caused another crash in overnight rendering.
This commit is contained in:
parent
6f9d8d9dd5
commit
5adb6733ef
14
osmxml.py
14
osmxml.py
@ -205,6 +205,19 @@ class mstr_osmxml:
|
|||||||
return surface
|
return surface
|
||||||
|
|
||||||
|
|
||||||
|
# Again, a crash on number checking of levels.
|
||||||
|
# Short call for sanity check
|
||||||
|
def is_float(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)
|
# Find the levels of a building (for shadow rendering)
|
||||||
def find_building_levels(self, way_id):
|
def find_building_levels(self, way_id):
|
||||||
lvl = 2 # Standard if we don't find anything else
|
lvl = 2 # Standard if we don't find anything else
|
||||||
@ -217,6 +230,7 @@ class mstr_osmxml:
|
|||||||
a = tag.getAttribute("k")
|
a = tag.getAttribute("k")
|
||||||
v = tag.getAttribute("v")
|
v = tag.getAttribute("v")
|
||||||
if a == "building:levels":
|
if a == "building:levels":
|
||||||
|
if self.is_float(v) == True:
|
||||||
lvl = int(float(v)) # <- This blew layergen and maskgen at some buildings with 1.5 floors
|
lvl = int(float(v)) # <- This blew layergen and maskgen at some buildings with 1.5 floors
|
||||||
break
|
break
|
||||||
return lvl
|
return lvl
|
||||||
|
Loading…
x
Reference in New Issue
Block a user