mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Draw front lines on the react map.
https://github.com/dcs-liberation/dcs_liberation/issues/2039
This commit is contained in:
@@ -6,6 +6,7 @@ from . import (
|
||||
debuggeometries,
|
||||
eventstream,
|
||||
flights,
|
||||
frontlines,
|
||||
mapzones,
|
||||
navmesh,
|
||||
supplyroutes,
|
||||
@@ -24,6 +25,7 @@ app.include_router(controlpoints.router)
|
||||
app.include_router(debuggeometries.router)
|
||||
app.include_router(eventstream.router)
|
||||
app.include_router(flights.router)
|
||||
app.include_router(frontlines.router)
|
||||
app.include_router(mapzones.router)
|
||||
app.include_router(navmesh.router)
|
||||
app.include_router(supplyroutes.router)
|
||||
|
||||
1
game/server/frontlines/__init__.py
Normal file
1
game/server/frontlines/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from .routes import router
|
||||
9
game/server/frontlines/models.py
Normal file
9
game/server/frontlines/models.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
from game.server.leaflet import LeafletPoint
|
||||
|
||||
|
||||
class FrontLineJs(BaseModel):
|
||||
extents: list[LeafletPoint]
|
||||
22
game/server/frontlines/routes.py
Normal file
22
game/server/frontlines/routes.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from fastapi import APIRouter, Depends
|
||||
|
||||
from game import Game
|
||||
from game.utils import nautical_miles
|
||||
from .models import FrontLineJs
|
||||
from ..dependencies import GameContext
|
||||
|
||||
router: APIRouter = APIRouter(prefix="/front-lines")
|
||||
|
||||
|
||||
@router.get("/")
|
||||
def list_front_lines(game: Game = Depends(GameContext.get)) -> list[FrontLineJs]:
|
||||
front_lines = []
|
||||
for front_line in game.theater.conflicts():
|
||||
a = front_line.position.point_from_heading(
|
||||
front_line.attack_heading.right.degrees, nautical_miles(2).meters
|
||||
)
|
||||
b = front_line.position.point_from_heading(
|
||||
front_line.attack_heading.left.degrees, nautical_miles(2).meters
|
||||
)
|
||||
front_lines.append(FrontLineJs(extents=[a.latlng(), b.latlng()]))
|
||||
return front_lines
|
||||
Reference in New Issue
Block a user