mirror of https://gitlab.com/bashrc2/epicyon
Fix geolocation bug
parent
f52bea9445
commit
efd4490101
10
maps.py
10
maps.py
|
@ -591,7 +591,7 @@ def _geocoords_from_gmaps_link(url: str) -> (int, float, float):
|
|||
coords = coords_str.split(',')
|
||||
if len(coords) not in (2, 3):
|
||||
return None, None, None
|
||||
zoom = '100'
|
||||
zoom = 100
|
||||
if zoom_exists:
|
||||
zoom = coords[2]
|
||||
if not zoom.isdigit():
|
||||
|
@ -602,6 +602,8 @@ def _geocoords_from_gmaps_link(url: str) -> (int, float, float):
|
|||
latitude = coords[0]
|
||||
if not is_float(latitude):
|
||||
return None, None, None
|
||||
if '"' in coords[1]:
|
||||
coords[1] = coords[1].split('"')[0]
|
||||
longitude = coords[1]
|
||||
if not is_float(longitude):
|
||||
return None, None, None
|
||||
|
@ -639,6 +641,8 @@ def _geocoords_from_bmaps_link(url: str) -> (int, float, float):
|
|||
if not is_float(latitude):
|
||||
return None, None, None
|
||||
longitude = coords[1]
|
||||
if '"' in coords[1]:
|
||||
coords[1] = coords[1].split('"')[0]
|
||||
if not is_float(longitude):
|
||||
return None, None, None
|
||||
zoom = 17
|
||||
|
@ -685,6 +689,8 @@ def _geocoords_from_waze_link(url: str) -> (int, float, float):
|
|||
if not is_float(latitude):
|
||||
return None, None, None
|
||||
longitude = coords[1]
|
||||
if '"' in coords[1]:
|
||||
coords[1] = coords[1].split('"')[0]
|
||||
if not is_float(longitude):
|
||||
return None, None, None
|
||||
zoom = 17
|
||||
|
@ -723,6 +729,8 @@ def _geocoords_from_wego_link(url: str) -> (int, float, float):
|
|||
if not is_float(latitude):
|
||||
return None, None, None
|
||||
longitude = coords[1]
|
||||
if '"' in coords[1]:
|
||||
coords[1] = coords[1].split('"')[0]
|
||||
if not is_float(longitude):
|
||||
return None, None, None
|
||||
zoom = coords[2]
|
||||
|
|
9
tests.py
9
tests.py
|
@ -8336,6 +8336,15 @@ def _test_hashtag_maps():
|
|||
assert longitude
|
||||
assert int(longitude * 1000) == 135502
|
||||
|
||||
link = "<a href=\"https://www.google.com/maps/place/36.82,-3.15\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" translate=\"no\"><span class=\"invisible\">https://www.</span><span class=\"ellipsis\">google.com/maps/place/36.82</span><span class=\"invisible\">3,-3.15</span></a>"
|
||||
zoom, latitude, longitude = \
|
||||
geocoords_from_map_link(link, 'openstreetmap.org', session)
|
||||
assert zoom == 100
|
||||
assert latitude
|
||||
assert int(latitude * 1000) == 36820
|
||||
assert longitude
|
||||
assert int(longitude * 1000) == -3150
|
||||
|
||||
|
||||
def _test_uninvert():
|
||||
print('test_uninvert')
|
||||
|
|
Loading…
Reference in New Issue