From 097c3cccdd841a36308523cbe4e03a7797817c5f Mon Sep 17 00:00:00 2001 From: Helldragon67 Date: Mon, 5 Aug 2024 16:17:19 +0200 Subject: [PATCH] =?UTF-8?q?les=203=20micro=20changements=20(r=C3=A9=C3=A9q?= =?UTF-8?q?uilibrage)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/structs/landmark.py | 2 +- backend/src/utils/landmarks_manager.py | 4 ++-- backend/src/utils/take_most_important.py | 4 ++++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/backend/src/structs/landmark.py b/backend/src/structs/landmark.py index 2f22d42..32a9741 100644 --- a/backend/src/structs/landmark.py +++ b/backend/src/structs/landmark.py @@ -13,7 +13,7 @@ class Landmark(BaseModel) : osm_type : str osm_id : int attractiveness : int - n_tags : int + n_tags : float image_url : Optional[str] = None # TODO future description : Optional[str] = None # TODO future duration : Optional[int] = 0 # TODO future diff --git a/backend/src/utils/landmarks_manager.py b/backend/src/utils/landmarks_manager.py index 17c1506..a7d59f7 100644 --- a/backend/src/utils/landmarks_manager.py +++ b/backend/src/utils/landmarks_manager.py @@ -321,9 +321,9 @@ class LandmarkManager: if elem_type != "nature": if "leisure" in tag and elem.tag('leisure') == "park": elem_type = "nature" - + if elem_type == "nature": - n_tags += 1 + n_tags += 1.5 if landmarktype != SHOPPING: if "shop" in tag: diff --git a/backend/src/utils/take_most_important.py b/backend/src/utils/take_most_important.py index b363add..2618092 100644 --- a/backend/src/utils/take_most_important.py +++ b/backend/src/utils/take_most_important.py @@ -2,6 +2,10 @@ from structs.landmark import Landmark def take_most_important(landmarks: list[Landmark], N_important) -> list[Landmark] : L = len(landmarks) + + if L < N_important : + return landmarks + L_copy = [] L_clean = [] scores = [0]*len(landmarks)