corrcected msitakes
Some checks failed
Build and deploy the backend to staging / Build and push image (pull_request) Successful in 1m48s
Run linting on the backend code / Build (pull_request) Successful in 27s
Run testing on the backend code / Build (pull_request) Failing after 4m30s
Build and deploy the backend to staging / Deploy to staging (pull_request) Successful in 22s

This commit is contained in:
2025-01-23 16:22:41 +01:00
parent 577ee232fc
commit 259b0d36fd
5 changed files with 70 additions and 65 deletions

View File

@@ -6,7 +6,7 @@ import numpy as np
from sklearn.cluster import DBSCAN
from pydantic import BaseModel
from ..overpass.overpass import Overpass
from ..overpass.overpass import Overpass, get_base_info
from ..structs.landmark import Landmark
from .get_time_distance import get_distance
from ..constants import OSM_CACHE_DIR
@@ -116,17 +116,11 @@ class ClusterManager:
points = []
for osm_type in osm_types :
for elem in result.findall(osm_type):
if osm_type != 'node' :
center = elem.find('center')
lat = float(center.get('lat'))
lon = float(center.get('lon'))
points.append(tuple((lat, lon)))
else :
lat = float(elem.get('lat'))
lon = float(elem.get('lon'))
points.append(tuple((lat, lon)))
# Get coordinates and append them to the points list
_, coords = get_base_info(elem, osm_type)
if coords is not None :
points.append(coords)
if points :
self.all_points = np.array(points)
@@ -263,32 +257,18 @@ class ClusterManager:
for osm_type in osm_types :
for elem in result.findall(osm_type):
name = elem.find("tag[@k='name']").get('v') if elem.find("tag[@k='name']") is not None else None
center = elem.find('center')
# Extract the center latitude and longitude if available.
if name is None :
continue
id, coords, name = get_base_info(elem, osm_type, with_name=True)
if osm_type != 'node' :
lat = float(center.get('lat'))
lon = float(center.get('lon'))
else :
lat = float(elem.get('lat'))
lon = float(elem.get('lon'))
coords = tuple((lat, lon))
if coords is None :
if name is None or coords is None :
continue
d = get_distance(cluster.centroid, coords)
if d < min_dist :
min_dist = d
new_name = name
osm_type = osm_type # Add type: 'way' or 'relation'
osm_id = elem.get('id') # Add OSM id
osm_type = osm_type # Add type: 'way' or 'relation'
osm_id = id # Add OSM id
return Landmark(
name=new_name,

View File

@@ -8,7 +8,7 @@ from ..structs.preferences import Preferences
from ..structs.landmark import Landmark
from .take_most_important import take_most_important
from .cluster_manager import ClusterManager
from ..overpass.overpass import Overpass
from ..overpass.overpass import Overpass, get_base_info
from ..constants import AMENITY_SELECTORS_PATH, LANDMARK_PARAMETERS_PATH, OPTIMIZER_PARAMETERS_PATH, OSM_CACHE_DIR
@@ -239,28 +239,19 @@ class LandmarkManager:
landmarks = []
for osm_type in ['node', 'way', 'relation'] :
for elem in root.findall(osm_type):
name = elem.find("tag[@k='name']").get('v') if elem.find("tag[@k='name']") is not None else None
tags = elem.findall('tag')
if osm_type != 'node' :
center = elem.find('center')
lat = float(center.get('lat'))
lon = float(center.get('lon'))
coords = tuple((lat, lon))
else :
lat = float(elem.get('lat'))
lon = float(elem.get('lon'))
coords = tuple((lat, lon))
id, coords, name = get_base_info(elem, osm_type, with_name=True)
if name is None or coords is None :
continue
tags = elem.findall('tag')
# Convert this to Landmark object
landmark = Landmark(name=name,
type=landmarktype,
location=coords,
osm_id=elem.get('id'),
osm_id=id,
osm_type=osm_type,
attractiveness=0,
n_tags=len(tags))

View File

@@ -2,7 +2,7 @@
import logging
import xml.etree.ElementTree as ET
from ..overpass.overpass import Overpass
from ..overpass.overpass import Overpass, get_base_info
from ..structs.landmark import Toilets
from ..constants import OSM_CACHE_DIR
@@ -98,23 +98,12 @@ class ToiletsManager:
toilets_list = []
for osm_type in ['node', 'way', 'relation'] :
for elem in root.findall(osm_type):
center = elem.find('center')
# Extract the center latitude and longitude if available.
if osm_type != 'node' :
lat = float(center.get('lat'))
lon = float(center.get('lon'))
location = tuple((lat, lon))
else :
lat = float(elem.get('lat'))
lon = float(elem.get('lon'))
location = tuple((lat, lon))
if location is None :
# Get coordinates and append them to the points list
_, coords = get_base_info(elem, osm_type)
if coords is None :
continue
toilets = Toilets(location=location)
toilets = Toilets(location=coords)
# Extract tags as a dictionary
tags = {tag.get('k'): tag.get('v') for tag in elem.findall('tag')}