linting
Some checks failed
Build and deploy the backend to staging / Build and push image (pull_request) Successful in 2m51s
Run linting on the backend code / Build (pull_request) Successful in 37s
Run testing on the backend code / Build (pull_request) Failing after 3m8s
Build and deploy the backend to staging / Deploy to staging (pull_request) Successful in 24s
Some checks failed
Build and deploy the backend to staging / Build and push image (pull_request) Successful in 2m51s
Run linting on the backend code / Build (pull_request) Successful in 37s
Run testing on the backend code / Build (pull_request) Failing after 3m8s
Build and deploy the backend to staging / Deploy to staging (pull_request) Successful in 24s
This commit is contained in:
@@ -5,11 +5,9 @@ from typing import Literal
|
||||
import numpy as np
|
||||
from sklearn.cluster import DBSCAN
|
||||
from pydantic import BaseModel
|
||||
# from OSMPythonTools.overpass import Overpass, overpassQueryBuilder
|
||||
# from OSMPythonTools.cachingStrategy import CachingStrategy, JSON
|
||||
from ..overpass.overpass import build_query, send_overpass_query
|
||||
from ..overpass.caching_strategy import CachingStrategy
|
||||
|
||||
from ..overpass.overpass import build_query, send_query
|
||||
from ..overpass.caching_strategy import CachingStrategy
|
||||
from ..structs.landmark import Landmark
|
||||
from .get_time_distance import get_distance
|
||||
from ..constants import OSM_CACHE_DIR
|
||||
@@ -81,8 +79,6 @@ class ClusterManager:
|
||||
Args:
|
||||
bbox: The bounding box coordinates (around:radius, center_lat, center_lon).
|
||||
"""
|
||||
# self.overpass = Overpass()
|
||||
# CachingStrategy.use(JSON, cacheDir=OSM_CACHE_DIR)
|
||||
CachingStrategy.use('XML', cache_dir=OSM_CACHE_DIR)
|
||||
|
||||
self.cluster_type = cluster_type
|
||||
@@ -94,6 +90,8 @@ class ClusterManager:
|
||||
osm_types = ['way']
|
||||
sel = '"historic"~"^(monument|building|yes)$"'
|
||||
out = 'ids center'
|
||||
else :
|
||||
raise NotImplementedError("Please choose only an available option for cluster detection")
|
||||
|
||||
# Initialize the points for cluster detection
|
||||
query = build_query(
|
||||
@@ -105,25 +103,25 @@ class ClusterManager:
|
||||
self.logger.debug(f"Cluster query: {query}")
|
||||
|
||||
try:
|
||||
result = send_overpass_query(query)
|
||||
result = send_query(query)
|
||||
except Exception as e:
|
||||
self.logger.error(f"Error fetching landmarks: {e}")
|
||||
|
||||
if result is None :
|
||||
self.logger.error(f"Error fetching {cluster_type} clusters, overpass query returned None.")
|
||||
self.valid = False
|
||||
|
||||
|
||||
else :
|
||||
points = []
|
||||
for osm_type in osm_types :
|
||||
for elem in result.findall(osm_type):
|
||||
center = elem.find('center')
|
||||
|
||||
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'))
|
||||
@@ -136,7 +134,7 @@ class ClusterManager:
|
||||
if self.cluster_type == 'shopping' and len(self.all_points) > 200 :
|
||||
dbscan = DBSCAN(eps=0.00118, min_samples=15, algorithm='kd_tree') # for large cities
|
||||
elif self.cluster_type == 'sightseeing' :
|
||||
dbscan = DBSCAN(eps=0.003, min_samples=10, algorithm='kd_tree') # for historic neighborhoods
|
||||
dbscan = DBSCAN(eps=0.0025, min_samples=15, algorithm='kd_tree') # for historic neighborhoods
|
||||
else :
|
||||
dbscan = DBSCAN(eps=0.00075, min_samples=10, algorithm='kd_tree') # for small cities
|
||||
|
||||
@@ -249,7 +247,7 @@ class ClusterManager:
|
||||
)
|
||||
|
||||
try:
|
||||
result = send_overpass_query(query)
|
||||
result = send_query(query)
|
||||
except Exception as e:
|
||||
self.logger.error(f"Error fetching landmarks: {e}")
|
||||
continue
|
||||
@@ -270,7 +268,7 @@ class ClusterManager:
|
||||
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'))
|
||||
@@ -290,7 +288,7 @@ class ClusterManager:
|
||||
return Landmark(
|
||||
name=new_name,
|
||||
type=self.cluster_type,
|
||||
location=cluster.centroid, # TODO: use the fact the we can also recognize streets.
|
||||
location=cluster.centroid, # later: use the fact the we can also recognize streets.
|
||||
attractiveness=cluster.importance,
|
||||
n_tags=0,
|
||||
osm_id=osm_id,
|
||||
|
||||
Reference in New Issue
Block a user