mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Remove our old lat/lon support code.
pydcs provides this now.
This commit is contained in:
@@ -2,9 +2,10 @@ from __future__ import annotations
|
||||
|
||||
from uuid import UUID
|
||||
|
||||
from dcs.mapping import LatLng
|
||||
from pydantic import BaseModel
|
||||
|
||||
from game.server.leaflet import LeafletLatLon, LeafletPoly, ShapelyUtil
|
||||
from game.server.leaflet import LeafletPoly, ShapelyUtil
|
||||
from game.sim.combat import FrozenCombat
|
||||
from game.sim.combat.aircombat import AirCombat
|
||||
from game.sim.combat.atip import AtIp
|
||||
@@ -14,8 +15,8 @@ from game.theater import ConflictTheater
|
||||
|
||||
class FrozenCombatJs(BaseModel):
|
||||
id: UUID
|
||||
flight_position: LeafletLatLon | None
|
||||
target_positions: list[LeafletLatLon] | None
|
||||
flight_position: LatLng | None
|
||||
target_positions: list[LatLng] | None
|
||||
footprint: list[LeafletPoly] | None
|
||||
|
||||
@staticmethod
|
||||
@@ -30,20 +31,15 @@ class FrozenCombatJs(BaseModel):
|
||||
if isinstance(combat, AtIp):
|
||||
return FrozenCombatJs(
|
||||
id=combat.id,
|
||||
flight_position=theater.point_to_ll(combat.flight.position()).as_list(),
|
||||
target_positions=[
|
||||
theater.point_to_ll(combat.flight.package.target.position).as_list()
|
||||
],
|
||||
flight_position=combat.flight.position().latlng(),
|
||||
target_positions=[combat.flight.package.target.position.latlng()],
|
||||
footprint=None,
|
||||
)
|
||||
if isinstance(combat, DefendingSam):
|
||||
return FrozenCombatJs(
|
||||
id=combat.id,
|
||||
flight_position=theater.point_to_ll(combat.flight.position()).as_list(),
|
||||
target_positions=[
|
||||
theater.point_to_ll(sam.position).as_list()
|
||||
for sam in combat.air_defenses
|
||||
],
|
||||
flight_position=combat.flight.position().latlng(),
|
||||
target_positions=[sam.position.latlng() for sam in combat.air_defenses],
|
||||
footprint=None,
|
||||
)
|
||||
raise NotImplementedError(f"Unhandled FrozenCombat type: {combat.__class__}")
|
||||
|
||||
@@ -22,8 +22,7 @@ class GameUpdateEventsJs(BaseModel):
|
||||
def from_events(cls, events: GameUpdateEvents, game: Game) -> GameUpdateEventsJs:
|
||||
return GameUpdateEventsJs(
|
||||
updated_flights={
|
||||
f[0].id: game.theater.point_to_ll(f[1]).as_list()
|
||||
for f in events.updated_flights
|
||||
f[0].id: f[1].latlng().as_list() for f in events.updated_flights
|
||||
},
|
||||
new_combats=[
|
||||
FrozenCombatJs.for_combat(c, game.theater) for c in events.new_combats
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from dcs.mapping import LatLng
|
||||
from pydantic.dataclasses import dataclass
|
||||
|
||||
from game.ato import FlightWaypoint
|
||||
from game.ato.flightwaypointtype import FlightWaypointType
|
||||
from game.theater import ConflictTheater, LatLon
|
||||
|
||||
|
||||
@dataclass
|
||||
class FlightWaypointJs:
|
||||
name: str
|
||||
position: LatLon
|
||||
position: LatLng
|
||||
altitude_ft: float
|
||||
altitude_reference: str
|
||||
is_movable: bool
|
||||
@@ -18,9 +18,7 @@ class FlightWaypointJs:
|
||||
include_in_path: bool
|
||||
|
||||
@staticmethod
|
||||
def for_waypoint(
|
||||
waypoint: FlightWaypoint, theater: ConflictTheater
|
||||
) -> FlightWaypointJs:
|
||||
def for_waypoint(waypoint: FlightWaypoint) -> FlightWaypointJs:
|
||||
# Target *points* are the exact location of a unit, whereas the target area is
|
||||
# only the center of the objective. Allow moving the latter since its exact
|
||||
# location isn't very important.
|
||||
@@ -64,7 +62,7 @@ class FlightWaypointJs:
|
||||
|
||||
return FlightWaypointJs(
|
||||
name=waypoint.name,
|
||||
position=theater.point_to_ll(waypoint.position),
|
||||
position=waypoint.position.latlng(),
|
||||
altitude_ft=waypoint.alt.feet,
|
||||
altitude_reference=waypoint.alt_type,
|
||||
is_movable=is_movable,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from datetime import timedelta
|
||||
from uuid import UUID
|
||||
|
||||
from dcs.mapping import LatLng
|
||||
from dcs.mapping import LatLng, Point
|
||||
from fastapi import APIRouter, Depends, HTTPException, status
|
||||
|
||||
from game import Game
|
||||
@@ -26,12 +26,10 @@ def all_waypoints_for_flight(
|
||||
flight.departure.position,
|
||||
meters(0),
|
||||
"RADIO",
|
||||
),
|
||||
game.theater,
|
||||
)
|
||||
)
|
||||
return [departure] + [
|
||||
FlightWaypointJs.for_waypoint(w, game.theater)
|
||||
for w in flight.flight_plan.waypoints
|
||||
FlightWaypointJs.for_waypoint(w) for w in flight.flight_plan.waypoints
|
||||
]
|
||||
|
||||
|
||||
@@ -47,7 +45,7 @@ def set_position(
|
||||
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN)
|
||||
|
||||
waypoint = flight.flight_plan.waypoints[waypoint_idx - 1]
|
||||
waypoint.position = game.theater.ll_to_point(position)
|
||||
waypoint.position = Point.from_latlng(position, game.theater.terrain)
|
||||
package_model = (
|
||||
GameContext.get_model()
|
||||
.ato_model_for(flight.blue)
|
||||
|
||||
Reference in New Issue
Block a user