diff --git a/osmxml.py b/osmxml.py index 3826b0a..c90879c 100644 --- a/osmxml.py +++ b/osmxml.py @@ -203,6 +203,19 @@ class mstr_osmxml: # Return the found surface type 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) @@ -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