Move threat zones out of MapModel.

This commit is contained in:
Dan Albert
2022-02-22 19:59:29 -08:00
parent 1c543666b5
commit b1356551c6
10 changed files with 62 additions and 142 deletions

View File

@@ -3,7 +3,9 @@ from __future__ import annotations
from dcs.mapping import LatLng
from pydantic import BaseModel
from game.server.leaflet import LeafletPoly
from game.server.leaflet import LeafletPoly, ShapelyUtil
from game.theater import ConflictTheater
from game.threatzones import ThreatZones
class MapZonesJs(BaseModel):
@@ -15,3 +17,24 @@ class MapZonesJs(BaseModel):
class UnculledZoneJs(BaseModel):
position: LatLng
radius: float
class ThreatZonesJs(BaseModel):
full: list[LeafletPoly]
aircraft: list[LeafletPoly]
air_defenses: list[LeafletPoly]
radar_sams: list[LeafletPoly]
@classmethod
def from_zones(cls, zones: ThreatZones, theater: ConflictTheater) -> ThreatZonesJs:
return ThreatZonesJs(
full=ShapelyUtil.polys_to_leaflet(zones.all, theater),
aircraft=ShapelyUtil.polys_to_leaflet(zones.airbases, theater),
air_defenses=ShapelyUtil.polys_to_leaflet(zones.air_defenses, theater),
radar_sams=ShapelyUtil.polys_to_leaflet(zones.radar_sam_threats, theater),
)
class ThreatZoneContainerJs(BaseModel):
blue: ThreatZonesJs
red: ThreatZonesJs