Draw flight plan paths in the react UI.

https://github.com/dcs-liberation/dcs_liberation/issues/2039
This commit is contained in:
Dan Albert
2022-03-01 00:08:34 -08:00
parent bd8aa0296b
commit 406a64ae3f
12 changed files with 183 additions and 18 deletions

View File

@@ -5,6 +5,7 @@ from dcs.mapping import LatLng, Point
from fastapi import APIRouter, Depends, HTTPException, status
from game import Game
from game.ato import Flight
from game.ato.flightwaypoint import FlightWaypoint
from game.ato.flightwaypointtype import FlightWaypointType
from game.server import GameContext
@@ -15,11 +16,7 @@ from game.utils import meters
router: APIRouter = APIRouter(prefix="/waypoints")
@router.get("/{flight_id}", response_model=list[FlightWaypointJs])
def all_waypoints_for_flight(
flight_id: UUID, game: Game = Depends(GameContext.get)
) -> list[FlightWaypointJs]:
flight = game.db.flights.get(flight_id)
def waypoints_for_flight(flight: Flight) -> list[FlightWaypointJs]:
departure = FlightWaypointJs.for_waypoint(
FlightWaypoint(
"TAKEOFF",
@@ -34,6 +31,13 @@ def all_waypoints_for_flight(
]
@router.get("/{flight_id}", response_model=list[FlightWaypointJs])
def all_waypoints_for_flight(
flight_id: UUID, game: Game = Depends(GameContext.get)
) -> list[FlightWaypointJs]:
return waypoints_for_flight(game.db.flights.get(flight_id))
@router.post("/{flight_id}/{waypoint_idx}/position")
def set_position(
flight_id: UUID,