fixed input as coordinates
Some checks failed
Build and push docker image / Build (pull_request) Failing after 36s
Build and release APK / Build APK (pull_request) Successful in 5m20s
Build web / Build Web (pull_request) Successful in 1m13s

This commit is contained in:
2024-06-04 00:20:54 +02:00
parent bcc91c638d
commit c58c10b057
7 changed files with 274 additions and 80 deletions

View File

@@ -1,7 +1,9 @@
from optimizer import solve_optimization
from landmarks_manager import generate_landmarks
from structs.landmarks import LandmarkTest
from structs.landmarks import Landmark
from structs.preferences import Preferences
from structs.landmarktype import LandmarkType
from structs.preferences import Preferences, Preference
from fastapi import FastAPI, Query, Body
from typing import List
@@ -12,13 +14,22 @@ app = FastAPI()
#"http://127.0.0.1:8000/process?param1={param1}&param2={param2}"
# This should become main at some point
@app.post("/optimizer/{longitude}/{latitude}")
def main(longitude: float, latitude: float, prefrences: Preferences = Body(...)) -> List[Landmark]:
def main(longitude: float, latitude: float, preferences: Preferences = Body(...)) -> List[Landmark]:
# From frontend get longitude, latitude and prefence list
# Generate the landmark list
landmarks = generate_landmarks(tuple((longitude, latitude)), preferences)
# Set the max distance
max_steps = 90
# Compute the visiting order
visiting_order = solve_optimization(landmarks, max_steps, True)
return visiting_order
landmarks = []
return landmarks
@app.get("test")
def test():
@@ -46,6 +57,16 @@ def test():
#return("max steps :", max_steps, "\n", visiting_order)
"""# keep this for debug
if __name__ == "__main__":
main()"""
# input city, country in the form of 'Paris, France'
@app.post("/test2/{city_country}")
def test2(city_country: str, preferences: Preferences = Body(...)) -> List[Landmark]:
landmarks = generate_landmarks(city_country, preferences)
max_steps = 9000000
visiting_order = solve_optimization(landmarks, max_steps, True)