Improve IP selection near threat zone centers.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2754.
This commit is contained in:
Dan Albert
2023-07-11 21:55:40 -07:00
committed by Raffson
parent f89ac52bf3
commit 12cdb8646c
5 changed files with 89 additions and 8 deletions

View File

@@ -64,14 +64,16 @@ class IpZonesJs(BaseModel):
ipBubble: LeafletPoly = Field(alias="ipBubble")
permissibleZone: LeafletPoly = Field(alias="permissibleZone")
safeZones: list[LeafletPoly] = Field(alias="safeZones")
preferred_threatened_zones: list[LeafletPoly] = Field(
alias="preferredThreatenedZones"
)
tolerable_threatened_lines: list[LeafletLine] = Field(
alias="tolerableThreatenedLines"
)
class Config:
title = "IpZones"
@classmethod
def empty(cls) -> IpZonesJs:
return IpZonesJs(homeBubble=[], ipBubble=[], permissibleZone=[], safeZones=[])
@classmethod
def for_flight(cls, flight: Flight, game: Game) -> IpZonesJs:
target = flight.package.target
@@ -84,6 +86,12 @@ class IpZonesJs(BaseModel):
geometry.permissible_zone, game.theater
),
safeZones=ShapelyUtil.polys_to_leaflet(geometry.safe_zones, game.theater),
preferredThreatenedZones=ShapelyUtil.polys_to_leaflet(
geometry.preferred_threatened_zones, game.theater
),
tolerableThreatenedLines=ShapelyUtil.lines_to_leaflet(
geometry.tolerable_threatened_lines, game.theater
),
)