fixed up clusters
Some checks failed
Build and deploy the backend to staging / Build and push image (pull_request) Successful in 2m28s
Run linting on the backend code / Build (pull_request) Successful in 26s
Run testing on the backend code / Build (pull_request) Failing after 1m51s
Build and deploy the backend to staging / Deploy to staging (pull_request) Successful in 24s

This commit is contained in:
2025-01-23 10:33:32 +01:00
parent ca40de82dd
commit 78f1dcaab4
6 changed files with 105 additions and 84 deletions

View File

@@ -96,10 +96,10 @@ class LandmarkManager:
self.logger.debug('Fetching sightseeing clusters...')
# special pipeline for historic neighborhoods
# neighborhood_manager = ClusterManager(bbox, 'sightseeing')
# historic_clusters = neighborhood_manager.generate_clusters()
# all_landmarks.update(historic_clusters)
# self.logger.debug('Sightseeing clusters done')
neighborhood_manager = ClusterManager(bbox, 'sightseeing')
historic_clusters = neighborhood_manager.generate_clusters()
all_landmarks.update(historic_clusters)
self.logger.debug('Sightseeing clusters done')
# list for nature
if preferences.nature.score != 0:
@@ -120,10 +120,10 @@ class LandmarkManager:
all_landmarks.update(current_landmarks)
# special pipeline for shopping malls
# shopping_manager = ClusterManager(bbox, 'shopping')
# shopping_clusters = shopping_manager.generate_clusters()
# all_landmarks.update(shopping_clusters)
# self.logger.debug('Shopping clusters done')
shopping_manager = ClusterManager(bbox, 'shopping')
shopping_clusters = shopping_manager.generate_clusters()
all_landmarks.update(shopping_clusters)
self.logger.debug('Shopping clusters done')
@@ -210,14 +210,14 @@ class LandmarkManager:
self.logger.error(f"Error fetching landmarks: {e}")
continue
return_list += self.parse_overpass_result(result, landmarktype, preference_level)
return_list += self.xml_to_landmarks(result, landmarktype, preference_level)
self.logger.debug(f"Fetched {len(return_list)} landmarks of type {landmarktype} in {bbox}")
return return_list
def parse_overpass_result(self, root: ET.Element, landmarktype, preference_level) -> list[Landmark]:
def xml_to_landmarks(self, root: ET.Element, landmarktype, preference_level) -> list[Landmark]:
"""
Parse the Overpass API result and extract landmarks.
@@ -239,9 +239,6 @@ class LandmarkManager:
landmarks = []
for osm_type in ['node', 'way', 'relation'] :
for elem in root.findall(osm_type):
# self.logger.debug('new landmark')
# Extract basic info from the landmark.
name = elem.find("tag[@k='name']").get('v') if elem.find("tag[@k='name']") is not None else None
center = elem.find('center')
tags = elem.findall('tag')
@@ -253,6 +250,7 @@ class LandmarkManager:
coords = tuple((lat, lon))
else :
continue
# Convert this to Landmark object
landmark = Landmark(name=name,
@@ -307,6 +305,8 @@ class LandmarkManager:
landmark.duration = 5
else:
# add them to cache here before setting the score
# name should be : 'osm_type + str(osm_id) + 'json'
self.set_landmark_score(landmark, landmarktype, preference_level)
landmarks.append(landmark)
# self.logger.debug('new landmark added')