cleaned up folders and defined proper structs
Some checks failed
Build and push docker image / Build (pull_request) Failing after 2m14s
Build and release APK / Build APK (pull_request) Successful in 5m15s
Build web / Build Web (pull_request) Successful in 2m32s

This commit is contained in:
Kilian Scheidecker 2024-05-29 22:57:11 +02:00
parent 7e4538a1bf
commit 03da8441f2
17 changed files with 103 additions and 38 deletions

View File

@ -8,5 +8,6 @@ numpy = "*"
scipy = "*"
fastapi = "*"
osmpythontools = "*"
pydantic = "*"
[dev-packages]

3
backend/Pipfile.lock generated
View File

@ -1,7 +1,7 @@
{
"_meta": {
"hash": {
"sha256": "15cc819367b908ccf7d61e3f2b45574c248556600dfeaa795e19045d6781fe90"
"sha256": "4293390eadd968364de0b376810eb66c68a4876d24a87987dc61010ad92c5712"
},
"pipfile-spec": 6,
"requires": {},
@ -890,6 +890,7 @@
"sha256:71b2945998f9c9b7919a45bde9a50397b289937d215ae141c1d0903ba7149fd7",
"sha256:834ab954175f94e6e68258537dc49402c4a5e9d0409b9f1b86b7e934a8372de7"
],
"index": "pypi",
"markers": "python_version >= '3.8'",
"version": "==2.7.2"
},

View File

@ -1 +0,0 @@
import app.src

View File

@ -1,34 +0,0 @@
from .src.optimizer import solve_optimization
from .src.landmarks_manager import Landmark
from fastapi import FastAPI
app = FastAPI()
@app.get("/optimize/{max_steps}/{print_details}")
def main(max_steps: int, print_details: bool):
# CONSTRAINT TO RESPECT MAX NUMBER OF STEPS
#max_steps = 16
# Initialize all landmarks (+ start and goal). Order matters here
landmarks = []
landmarks.append(Landmark("départ", -1, (0, 0)))
landmarks.append(Landmark("tour eiffel", 99, (0,2))) # PUT IN JSON
landmarks.append(Landmark("arc de triomphe", 99, (0,4)))
landmarks.append(Landmark("louvre", 99, (0,6)))
landmarks.append(Landmark("montmartre", 99, (0,10)))
landmarks.append(Landmark("concorde", 99, (0,8)))
landmarks.append(Landmark("arrivée", -1, (0, 0)))
visiting_order = solve_optimization(landmarks, max_steps, print_details)
#return visiting_order
return("max steps :", max_steps, "\n", visiting_order)
"""if __name__ == "__main__":
main()"""

View File

@ -1,6 +1,7 @@
from OSMPythonTools.api import Api
from OSMPythonTools.overpass import Overpass
from dataclasses import dataclass
from pydantic import BaseModel
# Defines the landmark class (aka some place there is to visit)
@ -10,8 +11,7 @@ class Landmarkkkk :
attractiveness : int
id : int
@dataclass
class Landmark :
class Landmark(BaseModel) :
name : str
attractiveness : int
loc : tuple

42
backend/src/main.py Normal file
View File

@ -0,0 +1,42 @@
from optimizer import solve_optimization
from .structs.landmarks import LandmarkTest
from .structs.preferences import Preferences
from fastapi import FastAPI
app = FastAPI()
# This should become main at some point
@app.post("optimizer/{longitude}/{latitude}")
def get_data(longitude: float, latitude: float, preferences: Preferences) :
# From frontend get longitude, latitude and prefence list
return
@app.get("optimizer/{max_steps}/{print_details}")
def main(max_steps: int, print_details: bool):
# CONSTRAINT TO RESPECT MAX NUMBER OF STEPS
#max_steps = 16
# Initialize all landmarks (+ start and goal). Order matters here
landmarks = []
landmarks.append(LandmarkTest("départ", -1, (0, 0)))
landmarks.append(LandmarkTest("tour eiffel", 99, (0,2))) # PUT IN JSON
landmarks.append(LandmarkTest("arc de triomphe", 99, (0,4)))
landmarks.append(LandmarkTest("louvre", 99, (0,6)))
landmarks.append(LandmarkTest("montmartre", 99, (0,10)))
landmarks.append(LandmarkTest("concorde", 99, (0,8)))
landmarks.append(LandmarkTest("arrivée", -1, (0, 0)))
visiting_order = solve_optimization(landmarks, max_steps, print_details)
#return visiting_order
# should return landmarks = the list of Landmark (ordered list)
return("max steps :", max_steps, "\n", visiting_order)
"""if __name__ == "__main__":
main()"""

View File

@ -0,0 +1,24 @@
from pydantic import BaseModel
from .landmarktype import LandmarkType
from .preferences import Preferences
class LandmarkTest(BaseModel) :
name : str
attractiveness : int
loc : tuple
# Output to frontend
class Landmark(BaseModel) :
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
def score(preferences: Preferences):
# loop through the preferences and assign a score
return 29

View File

@ -0,0 +1,4 @@
from pydantic import BaseModel
class LandmarkType(BaseModel):
landmark_type: str

View File

@ -0,0 +1,28 @@
from pydantic import BaseModel
from .landmarktype import LandmarkType
class Preference(BaseModel) :
name: str
type: LandmarkType
score: int
# Input for optimization
class Preferences(BaseModel) :
# Sightseeing / History & Culture (Musées, bâtiments historiques, opéras, églises)
sightseeing : Preference
# Nature (parcs, jardins, rivières, plages)
nature: Preference
# Shopping (diriger plutôt vers des zones / rues commerçantes)
shopping : Preference
# Food (price low or high. Combien on veut dépenser pour manger à midi/soir)
food_budget : Preference
# Tolérance au détour (ce qui détermine (+ ou -) le chemin emprunté)
detour_tol : Preference