mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Remove useless TravelTime class.
This is only called for real in one spot. The other callers should have been deferring to the one real caller.
This commit is contained in:
parent
1902618f45
commit
99eed33241
@ -20,7 +20,7 @@ from game.utils import Distance, Speed, meters
|
|||||||
from .planningerror import PlanningError
|
from .planningerror import PlanningError
|
||||||
from ..flightwaypointtype import FlightWaypointType
|
from ..flightwaypointtype import FlightWaypointType
|
||||||
from ..starttype import StartType
|
from ..starttype import StartType
|
||||||
from ..traveltime import GroundSpeed, TravelTime
|
from ..traveltime import GroundSpeed
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from game.dcs.aircrafttype import FuelConsumption
|
from game.dcs.aircrafttype import FuelConsumption
|
||||||
@ -228,9 +228,10 @@ class FlightPlan(ABC, Generic[LayoutT]):
|
|||||||
def travel_time_between_waypoints(
|
def travel_time_between_waypoints(
|
||||||
self, a: FlightWaypoint, b: FlightWaypoint
|
self, a: FlightWaypoint, b: FlightWaypoint
|
||||||
) -> timedelta:
|
) -> timedelta:
|
||||||
return TravelTime.between_points(
|
error_factor = 1.05
|
||||||
a.position, b.position, self.speed_between_waypoints(a, b)
|
speed = self.speed_between_waypoints(a, b)
|
||||||
)
|
distance = meters(a.position.distance_to_point(b.position))
|
||||||
|
return timedelta(hours=distance.nautical_miles / speed.knots * error_factor)
|
||||||
|
|
||||||
def tot_for_waypoint(self, waypoint: FlightWaypoint) -> datetime | None:
|
def tot_for_waypoint(self, waypoint: FlightWaypoint) -> datetime | None:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|||||||
@ -10,7 +10,6 @@ from game.typeguard import self_type_guard
|
|||||||
from game.utils import Speed
|
from game.utils import Speed
|
||||||
from .flightplan import FlightPlan
|
from .flightplan import FlightPlan
|
||||||
from .loiter import LoiterFlightPlan, LoiterLayout
|
from .loiter import LoiterFlightPlan, LoiterLayout
|
||||||
from ..traveltime import GroundSpeed, TravelTime
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from ..flightwaypoint import FlightWaypoint
|
from ..flightwaypoint import FlightWaypoint
|
||||||
@ -93,10 +92,8 @@ class FormationFlightPlan(LoiterFlightPlan[LayoutT], ABC):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def push_time(self) -> datetime:
|
def push_time(self) -> datetime:
|
||||||
return self.join_time - TravelTime.between_points(
|
return self.join_time - self.travel_time_between_waypoints(
|
||||||
self.layout.hold.position,
|
self.layout.hold, self.layout.join
|
||||||
self.layout.join.position,
|
|
||||||
GroundSpeed.for_flight(self.flight, self.layout.hold.alt),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|||||||
@ -10,7 +10,6 @@ from game.utils import Heading
|
|||||||
from .ibuilder import IBuilder
|
from .ibuilder import IBuilder
|
||||||
from .loiter import LoiterFlightPlan, LoiterLayout
|
from .loiter import LoiterFlightPlan, LoiterLayout
|
||||||
from .waypointbuilder import WaypointBuilder
|
from .waypointbuilder import WaypointBuilder
|
||||||
from ..traveltime import GroundSpeed, TravelTime
|
|
||||||
from ...flightplan import HoldZoneGeometry
|
from ...flightplan import HoldZoneGeometry
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
@ -78,10 +77,8 @@ class SweepFlightPlan(LoiterFlightPlan[SweepLayout]):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def push_time(self) -> datetime:
|
def push_time(self) -> datetime:
|
||||||
return self.sweep_end_time - TravelTime.between_points(
|
return self.sweep_end_time - self.travel_time_between_waypoints(
|
||||||
self.layout.hold.position,
|
self.layout.hold, self.layout.sweep_end
|
||||||
self.layout.sweep_end.position,
|
|
||||||
GroundSpeed.for_flight(self.flight, self.layout.hold.alt),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|||||||
@ -1,17 +1,9 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from dcs.mapping import Point
|
from game.utils import Distance, SPEED_OF_SOUND_AT_SEA_LEVEL, Speed, mach
|
||||||
|
|
||||||
from game.utils import (
|
|
||||||
Distance,
|
|
||||||
SPEED_OF_SOUND_AT_SEA_LEVEL,
|
|
||||||
Speed,
|
|
||||||
mach,
|
|
||||||
meters,
|
|
||||||
)
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from .flight import Flight
|
from .flight import Flight
|
||||||
@ -42,14 +34,6 @@ class GroundSpeed:
|
|||||||
return mach(cruise_mach, altitude)
|
return mach(cruise_mach, altitude)
|
||||||
|
|
||||||
|
|
||||||
class TravelTime:
|
|
||||||
@staticmethod
|
|
||||||
def between_points(a: Point, b: Point, speed: Speed) -> timedelta:
|
|
||||||
error_factor = 1.05
|
|
||||||
distance = meters(a.distance_to_point(b))
|
|
||||||
return timedelta(hours=distance.nautical_miles / speed.knots * error_factor)
|
|
||||||
|
|
||||||
|
|
||||||
# TODO: Most if not all of this should move into FlightPlan.
|
# TODO: Most if not all of this should move into FlightPlan.
|
||||||
class TotEstimator:
|
class TotEstimator:
|
||||||
def __init__(self, package: Package) -> None:
|
def __init__(self, package: Package) -> None:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user