From 8e33bd1b3fdca7396935d329d54a2c5e57a7165c Mon Sep 17 00:00:00 2001 From: Remy Moll Date: Wed, 26 Jun 2024 12:27:54 +0200 Subject: [PATCH] base structs as agreed upon --- backend/src/main.py | 20 ++++++++++++++++++++ backend/src/structs/landmarks.py | 22 ++++++++++++++++------ 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/backend/src/main.py b/backend/src/main.py index 692c7f9..89b49fa 100644 --- a/backend/src/main.py +++ b/backend/src/main.py @@ -10,6 +10,10 @@ from typing import List app = FastAPI() +# TODO: needs a global variable to store the landmarks accross function calls +# linked_tour = [] + + # Assuming frontend is calling like this : #"http://127.0.0.1:8000/process?param1={param1}¶m2={param2}" @app.post("/optimizer_coords/{start_lat}/{start_lon}/{finish_lat}/{finish_lon}") @@ -50,11 +54,22 @@ def main1(start_lat: float, start_lon: float, preferences: Preferences = Body(.. # Second stage optimization refined_tour = refine_optimization(landmarks, base_tour, max_walking_time*60+detour, True) + + + # TODO: should look something like this + # # set time to reach and transform into fully functional linked list + # linked_tour += link(refined_tour) + # return { + # 'city_name': 'Paris', + # 'n_stops': len(linked_tour), + # 'first_landmark_uuid': linked_tour[0].uuid, + # } return refined_tour + # input city, country in the form of 'Paris, France' @app.post("/test2/{city_country}") def test2(city_country: str, preferences: Preferences = Body(...)) -> List[Landmark]: @@ -67,4 +82,9 @@ def test2(city_country: str, preferences: Preferences = Body(...)) -> List[Landm +@app.get("/landmark/{landmark_uuid}") +def get_landmark(landmark_uuid: str) -> Landmark: + #cherche dans linked_tour et retourne le landmark correspondant + pass + diff --git a/backend/src/structs/landmarks.py b/backend/src/structs/landmarks.py index 94209f3..d02dc5f 100644 --- a/backend/src/structs/landmarks.py +++ b/backend/src/structs/landmarks.py @@ -1,20 +1,30 @@ from typing import Optional -from pydantic import BaseModel +from pydantic import BaseModel, Field from .landmarktype import LandmarkType - +from uuid import uuid4 # Output to frontend class Landmark(BaseModel) : + # Unique ID of a given landmark + uuid: str = Field(default_factory=uuid4) # TODO implement this ASAP + + # Properties of the landmark name : str type: LandmarkType # De facto mapping depending on how the query was executed with overpass. Should still EXACTLY correspond to the preferences location : tuple osm_type : str osm_id : int attractiveness : int - must_do : bool n_tags : int - time_to_reach : Optional[int] = 0 - - + image_url : Optional[str] = None # TODO future + description : Optional[str] = None # TODO future + duration : Optional[int] = 0 # TODO future + + # Additional properties depending on specific tour + must_do : bool + is_secondary : Optional[bool] = False # TODO future + + time_to_reach_next : Optional[int] = 0 # TODO fix this in existing code + next_uuid : Optional[str] = None # TODO implement this ASAP