From d2dcc5e81d237ffcae041a7d9a064004574e5fe3 Mon Sep 17 00:00:00 2001 From: bashrc Date: Tue, 22 Sep 2026 13:18:34 +0100 Subject: [PATCH] Decomal point should be a dot within float strings --- src/city.py | 8 ++++++++ src/maps.py | 44 ++++++++++++++++++++++++++++++++++++++++++++ src/pyjsonld.py | 3 ++- 3 files changed, 54 insertions(+), 1 deletion(-) diff --git a/src/city.py b/src/city.py index d09f14065..8540d585d 100644 --- a/src/city.py +++ b/src/city.py @@ -181,13 +181,16 @@ def parse_nogo_string(nogo_line: str) -> []: if 'E' in longitude_str: longitude_str = \ longitude_str.replace('E', '') + longitude_str = longitude_str.replace(',', '.') longitude = float(longitude_str) elif 'W' in longitude_str: longitude_str = \ longitude_str.replace('W', '') + longitude_str = longitude_str.replace(',', '.') longitude = -float(longitude_str) else: longitude = float(longitude_str) + latitude_str = latitude_str.replace(',', '.') latitude = float(latitude_str) polygon.append([latitude, longitude]) return polygon @@ -272,6 +275,11 @@ def spoof_geolocation(base_dir: str, if 'W' in longitude: longdirection: str = 'W' longitude = longitude.replace('W', '') + + # ensure that decimal point is a dot + latitude = latitude.replace(',', '.') + longitude = longitude.replace(',', '.') + latitude = float(latitude) longitude = float(longitude) # get the time of day at the city diff --git a/src/maps.py b/src/maps.py index 7ceafbd00..3ca9613a2 100644 --- a/src/maps.py +++ b/src/maps.py @@ -326,6 +326,7 @@ def get_location_from_post(post_json_object: {}) -> str: is_west = True if not is_float(longitude): if isinstance(longitude, str): + longitude = longitude.replace(',', '.') longitude = float(longitude) if is_west and longitude > 0: longitude = -longitude @@ -342,6 +343,7 @@ def get_location_from_post(post_json_object: {}) -> str: latitude = latitude.replace('N', '') if not is_float(latitude): if isinstance(latitude, str): + latitude = latitude.replace(',', '.') latitude = float(latitude) if is_south and latitude > 0: latitude = -latitude @@ -511,6 +513,11 @@ def _geocoords_from_osm_link(url: str, osm_domain: str) -> (int, float, float): if not is_float(longitude): return None, None, None zoom = int(zoom) + + # ensure decimal point is a dot + latitude = latitude.replace(',', '.') + longitude = longitude.replace(',', '.') + latitude = float(latitude) longitude = float(longitude) return zoom, latitude, longitude @@ -553,6 +560,11 @@ def _geocoords_from_osmorg_link(url: str) -> (int, float, float): if not zoom.isdigit(): return None, None, None zoom = int(zoom) + + # ensure that decimal place is a dot + latitude = latitude.replace(',', '.') + longitude = longitude.replace(',', '.') + latitude = float(latitude) longitude = float(longitude) return zoom, latitude, longitude @@ -600,6 +612,10 @@ def _geocoords_from_osmand_link(url: str) -> (int, float, float): latitude_str = pin_coords_str.split(',')[0] longitude_str = pin_coords_str.split(',')[1] if is_float(latitude_str) and is_float(longitude_str): + # ensure that decimal point is a dot + latitude_str = latitude_str.replace(',', '.') + longitude_str = longitude_str.replace(',', '.') + latitude = float(latitude_str) longitude = float(longitude_str) @@ -614,6 +630,10 @@ def _geocoords_from_osmand_link(url: str) -> (int, float, float): if zoom_str.isnumeric() and \ is_float(latitude_str) and \ is_float(longitude_str): + # ensure that decimal point is a dot + latitude_str = latitude_str.replace(',', '.') + longitude_str = longitude_str.replace(',', '.') + latitude = float(latitude_str) longitude = float(longitude_str) zoom = int(zoom_str) @@ -642,6 +662,10 @@ def _geocoords_from_geo_link(url: str) -> (int, float, float): if ' ' in longitude_str: longitude_str = longitude_str.split(' ')[0] if is_float(latitude_str) and is_float(longitude_str): + # ensure that decimal point is a dot + latitude_str = latitude_str.replace(',', '.') + longitude_str = longitude_str.replace(',', '.') + latitude = float(latitude_str) longitude = float(longitude_str) return zoom, latitude, longitude @@ -690,6 +714,11 @@ def _geocoords_from_gmaps_link(url: str) -> (int, float, float): if not is_float(longitude): return None, None, None zoom = int(zoom) + + # ensure that decimal point is a dor + latitude = latitude.replace(',', '.') + longitude = longitude.replace(',', '.') + latitude = float(latitude) longitude = float(longitude) return zoom, latitude, longitude @@ -737,6 +766,11 @@ def _geocoords_from_bmaps_link(url: str) -> (int, float, float): if not zoom.isdigit(): return None, None, None zoom = int(zoom) + + # ensure that decimal point is a dor + latitude = latitude.replace(',', '.') + longitude = longitude.replace(',', '.') + latitude = float(latitude) longitude = float(longitude) return zoom, latitude, longitude @@ -783,6 +817,11 @@ def _geocoords_from_waze_link(url: str) -> (int, float, float): if not zoom.isdigit(): return None, None, None zoom = int(zoom) + + # ensure that decimal point is a dor + latitude = latitude.replace(',', '.') + longitude = longitude.replace(',', '.') + latitude = float(latitude) longitude = float(longitude) return zoom, latitude, longitude @@ -819,6 +858,11 @@ def _geocoords_from_wego_link(url: str) -> (int, float, float): if not zoom.isdigit(): return None, None, None zoom = int(zoom) + + # ensure that decimal point is a dor + latitude = latitude.replace(',', '.') + longitude = longitude.replace(',', '.') + latitude = float(latitude) longitude = float(longitude) return zoom, latitude, longitude diff --git a/src/pyjsonld.py b/src/pyjsonld.py index 5051c1d28..21b14b274 100644 --- a/src/pyjsonld.py +++ b/src/pyjsonld.py @@ -2878,7 +2878,8 @@ class JsonLdProcessor(object): if rval['@value'].isdigit(): rval['@value'] = int(rval['@value']) elif type_ == XSD_DOUBLE: - rval['@value'] = float(rval['@value']) + value_str = rval['@value'].replace(',', '.') + rval['@value'] = float(value_str) # do not add native type if type_ not in [XSD_BOOLEAN, XSD_INTEGER, XSD_DOUBLE, XSD_STRING]: