fixed input as coordinates
This commit is contained in:
@@ -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}¶m2={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)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user