From b911a77517aa6a4486cc06d68f94af263796ac5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Paluch?= Date: Wed, 21 Oct 2026 19:09:40 +0200 Subject: [PATCH] =?UTF-8?q?Fix:=20'pas=20zaj=C4=99ty'=20nie=20odpala=20si?= =?UTF-8?q?=C4=99=20z=20dala=20od=20lotniska=20(>15=20nm)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - wyzwalacz 'pas zajęty' działa tylko w promieniu 15 nm od wybranego pasa - dodano _pilot_latlon() i _dist_nm() (haversine) - po odlocie ATC przestaje mówić o pasie EPWA --- PythonPlugins/PI_XSayATC.py | 41 +++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/PythonPlugins/PI_XSayATC.py b/PythonPlugins/PI_XSayATC.py index 15f69c8..300790e 100644 --- a/PythonPlugins/PI_XSayATC.py +++ b/PythonPlugins/PI_XSayATC.py @@ -1441,18 +1441,43 @@ class XSayATC: if close: return "nearby traffic within 5 nm (issue traffic advisory)" - # 3) Pas zajety — jesli pilot wybral pas i ktos na nim jest (start/ladowanie). + # 3) Pas zajety — tylko gdy pilot jest BLISKO lotniska (< 15 nm). + # Inaczej po odlocie ATC gadalby o pasie oddalonego lotniska w petli. if self.selected_runway and self._runway_icao: - occ = self._runway_occupants(self._runway_icao, self.selected_runway) - if occ: - desc = ", ".join( - f"{o['phase_name']} (key 0x{o['key']:X})" if isinstance(o.get('key'), int) else o['phase_name'] - for o in occ - ) - return f"runway {self.selected_runway} occupied: {desc}" + runway = self._find_runway(self._runway_icao, self.selected_runway) + if runway: + plat, plon = self._pilot_latlon() + if plat is not None: + mid_lat = (runway["lat1"] + runway["lat2"]) / 2.0 + mid_lon = (runway["lon1"] + runway["lon2"]) / 2.0 + if self._dist_nm(plat, plon, mid_lat, mid_lon) < 15.0: + occ = self._runway_occupants(self._runway_icao, self.selected_runway) + if occ: + desc = ", ".join( + f"{o['phase_name']} (key 0x{o['key']:X})" if isinstance(o.get('key'), int) else o['phase_name'] + for o in occ + ) + return f"runway {self.selected_runway} occupied: {desc}" return None + def _pilot_latlon(self): + """Zwraca (lat, lon) pilota lub (None, None).""" + lat = self._get_dataref("sim/flightmodel/position/latitude", is_float=True) + lon = self._get_dataref("sim/flightmodel/position/longitude", is_float=True) + return lat, lon + + def _dist_nm(self, lat1, lon1, lat2, lon2): + """Odleglosc (nm) miedzy dwoma punktami (haversine).""" + import math + R = 3440.065 # promien Ziemi w milach morskich + p1 = math.radians(lat1) + p2 = math.radians(lat2) + dp = math.radians(lat2 - lat1) + dl = math.radians(lon2 - lon1) + a = math.sin(dp / 2) ** 2 + math.cos(p1) * math.cos(p2) * math.sin(dl / 2) ** 2 + return 2 * R * math.asin(math.sqrt(a)) + def _read_int_array(self, ref, count): """Czyta tablice int z datarefu (indeksowaną slotem).""" if ref is None: