Skip to content

Commit

Permalink
bugfix: duplicate definse cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
papko26 committed Dec 2, 2024
1 parent 5387993 commit d0bd0e7
Showing 1 changed file with 0 additions and 29 deletions.
29 changes: 0 additions & 29 deletions app/gtw.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,35 +371,6 @@ def get_coordinates_from_place_id(place_id, api_key):
return None


def extract_coordinates_with_regex(url, last_resort=False):
try:
# Sometimes /places link may contain coordinates of the location, which
# user browsed after he chosed the destination.
# Lets ensure we will not try to parse it.
# Same for /dir/ locations - it is google maps directions (route).
if not url:
logger.error("extract_crds: no url passed")
if not last_resort:
if "/place/" in url or "/dir/" in url:
logger.debug("extract_crds: it is a 'places' or 'dir' link, parsing skipped")
return None
if last_resort:
logger.info("extract_crds_last_resort: lemme try to find any coords no matter what")

# Regex pattern to match latitude and longitude pairs
pattern = r"([-+]?\d+(?:\.\d+)?),\s*([-+]?\d+(?:\.\d+)?)"
match = re.search(pattern, url)
if match:
# Extract latitude and longitude from groups
latitude, longitude = match.groups()
return {"extract_crds: latitude": latitude, "longitude": longitude}
else:
logger.debug("extract_crds: failed to parse cords")
except Exception as e:
logger.error(f"Error extracting coordinates: {e}")
return None


def extract_coordinates_with_regex(url, last_resort=False):
try:
# Sometimes /places link may contain coordinates of the location, which
Expand Down

0 comments on commit d0bd0e7

Please sign in to comment.