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:
Dan Albert 2023-08-22 20:24:29 -07:00 committed by Raffson
parent dcaee350cf
commit 14d3e743d4
No known key found for this signature in database
GPG Key ID: B0402B2C9B764D99
5 changed files with 13 additions and 36 deletions

View File

@ -12,7 +12,6 @@ from .formationattack import (
) )
from .waypointbuilder import WaypointBuilder from .waypointbuilder import WaypointBuilder
from .. import FlightType from .. import FlightType
from ..traveltime import TravelTime, GroundSpeed
from ...utils import feet from ...utils import feet
@ -20,10 +19,9 @@ class EscortFlightPlan(FormationAttackFlightPlan):
@property @property
def push_time(self) -> timedelta: def push_time(self) -> timedelta:
hold2join_time = ( hold2join_time = (
TravelTime.between_points( self.travel_time_between_waypoints(
self.layout.hold.position, self.layout.hold,
self.layout.join.position, self.layout.join,
GroundSpeed.for_flight(self.flight, self.layout.hold.alt),
) )
if self.layout.hold is not None if self.layout.hold is not None
else timedelta(0) else timedelta(0)

View File

@ -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
@ -244,9 +244,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) -> timedelta | None: def tot_for_waypoint(self, waypoint: FlightWaypoint) -> timedelta | None:
raise NotImplementedError raise NotImplementedError

View File

@ -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, ABC):
@property @property
def push_time(self) -> timedelta: def push_time(self) -> timedelta:
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

View File

@ -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:
@ -79,10 +78,8 @@ class SweepFlightPlan(LoiterFlightPlan):
@property @property
def push_time(self) -> timedelta: def push_time(self) -> timedelta:
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

View File

@ -4,15 +4,7 @@ import math
from datetime import timedelta from datetime import timedelta
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, meters
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
@ -43,14 +35,6 @@ class GroundSpeed:
return mach(cruise_mach, altitude if not flight.is_helo else meters(0)) return mach(cruise_mach, altitude if not flight.is_helo else meters(0))
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: