Exemple #1
0
 def on_selected_target_changed(self):
     target = self.tgt_selection_box.get_selected_target()
     if target is not None:
         self.distanceToTargetLabel.setText("~" + str(
             meter_to_nm(
                 self.flight.from_cp.position.distance_to_point(
                     target.location.position))) + " nm")
         self.threatRangeLabel.setText(
             str(meter_to_nm(target.threat_range)) + " nm")
         self.detectionRangeLabel.setText(
             str(meter_to_nm(target.detection_range)) + " nm")
         self.seadTargetInfoView.setTarget(target)
Exemple #2
0
    def _ground_speed(self, waypoint: FlightWaypoint) -> str:
        if self.last_waypoint is None:
            return "-"

        if waypoint.tot is None:
            return "-"

        if self.last_waypoint.departure_time is not None:
            last_time = self.last_waypoint.departure_time
        elif self.last_waypoint.tot is not None:
            last_time = self.last_waypoint.tot
        else:
            return "-"

        distance = meter_to_nm(self.last_waypoint.position.distance_to_point(
            waypoint.position
        ))
        duration = (waypoint.tot - last_time).total_seconds() / 3600
        try:
            return f"{int(distance / duration)} kt"
        except ZeroDivisionError:
            # TODO: Improve resolution of unit conversions.
            # When waypoints are very close to each other they can end up with
            # identical TOTs because our unit conversion functions truncate to
            # int. When waypoints have the same TOT the duration will be zero.
            # https://github.com/Khopa/dcs_liberation/issues/557
            return "-"
 def on_selected_target_changed(self):
     target = self.tgt_selection_box.get_selected_target()
     self.distanceToTargetLabel.setText("~" + str(
         meter_to_nm(
             self.flight.from_cp.position.distance_to_point(
                 target.location.position))) + " nm")
     self.strike_infos.setTarget(target)
Exemple #4
0
    def _waypoint_distance(self, waypoint: FlightWaypoint) -> str:
        if self.last_waypoint is None:
            return "-"

        distance = meter_to_nm(
            self.last_waypoint.position.distance_to_point(waypoint.position))
        return f"{distance} NM"
 def is_valid_ship_pos(self, scene_position: Point) -> bool:
     world_destination = self._scene_to_dcs_coords(scene_position)
     distance = self.selected_cp.control_point.position.distance_to_point(
         world_destination)
     if meter_to_nm(distance) > MAX_SHIP_DISTANCE:
         return False
     return self.game.theater.is_in_sea(world_destination)
    def on_select_wpt_changed(self):
        super(QCASMissionGenerator, self).on_select_wpt_changed()
        wpts = self.wpt_selection_box.get_selected_waypoints()

        if len(wpts) > 0:
            self.distanceToTargetLabel.setText("~" + str(
                meter_to_nm(
                    self.flight.from_cp.position.distance_to_point(
                        Point(wpts[0].x, wpts[0].y)))) + " nm")
        else:
            self.distanceToTargetLabel.setText("??? nm")
Exemple #7
0
    def updateForecast(self):
        """Updates the Forecast Text and icon with the current conditions wind info.
        """
        icon = []
        if self.conditions.weather.clouds is None:
            cloudDensity = 0
            precipitation = None
        else:
            cloudDensity = self.conditions.weather.clouds.density
            precipitation = self.conditions.weather.clouds.precipitation

        fog = self.conditions.weather.fog or None
        is_night = self.conditions.time_of_day == TimeOfDay.Night
        time = 'night' if is_night else 'day'

        if cloudDensity <= 0:
            self.forecastClouds.setText('Sunny')
            icon = [time, 'clear']
        
        if cloudDensity > 0 and cloudDensity < 3:
            self.forecastClouds.setText('Partly Cloudy')
            icon = [time, 'partly-cloudy']

        if cloudDensity >= 3 and cloudDensity < 5:
            self.forecastClouds.setText('Mostly Cloudy')
            icon = [time, 'partly-cloudy']

        if cloudDensity >= 5:
            self.forecastClouds.setText('Totally Cloudy')
            icon = [time, 'partly-cloudy']

        if precipitation == PydcsWeather.Preceptions.Rain:
            self.forecastRain.setText('Rain')
            icon = [time, 'rain']

        elif precipitation == PydcsWeather.Preceptions.Thunderstorm:
            self.forecastRain.setText('Thunderstorm')
            icon = [time, 'thunderstorm']
            
        else:
            self.forecastRain.setText('No Rain')

        if not fog:
            self.forecastFog.setText('No fog')
        else:       
            visvibilityNm = round(meter_to_nm(fog.visibility), 1)
            self.forecastFog.setText('Fog vis: {}nm'.format(visvibilityNm))
            icon = [time, ('cloudy' if cloudDensity > 1 else None), 'fog']


        icon_key = "Weather_{}".format('-'.join(filter(None.__ne__, icon)))
        icon = CONST.ICONS.get(icon_key) or CONST.ICONS['Weather_night-partly-cloudy']        
        self.weather_icon.setPixmap(icon)
Exemple #8
0
    def _ground_speed(self, waypoint: FlightWaypoint) -> str:
        if self.last_waypoint is None:
            return "-"

        if waypoint.tot is None:
            return "-"

        if self.last_waypoint.departure_time is not None:
            last_time = self.last_waypoint.departure_time
        elif self.last_waypoint.tot is not None:
            last_time = self.last_waypoint.tot
        else:
            return "-"

        distance = meter_to_nm(
            self.last_waypoint.position.distance_to_point(waypoint.position))
        duration = (waypoint.tot - last_time).total_seconds() / 3600
        return f"{int(distance / duration)} kt"
Exemple #9
0
 def between_points(a: Point, b: Point, speed: float) -> timedelta:
     error_factor = 1.1
     distance = meter_to_nm(a.distance_to_point(b))
     return timedelta(hours=distance / speed * error_factor)