Correction in number/float detection for floors, as it caused another crash in overnight rendering.

This commit is contained in:
Marcus Str. 2025-02-04 08:10:57 +01:00
parent 6f9d8d9dd5
commit e3c8e6bd14

View File

@ -203,6 +203,19 @@ class mstr_osmxml:
# Return the found surface type # Return the found surface type
return surface 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) # Find the levels of a building (for shadow rendering)
@ -217,8 +230,9 @@ 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":
lvl = int(float(v)) # <- This blew layergen and maskgen at some buildings with 1.5 floors if self.is_float(v) == True:
break lvl = int(float(v)) # <- This blew layergen and maskgen at some buildings with 1.5 floors
break
return lvl return lvl
# Find minimum level of a building # Find minimum level of a building