@@ -481,13 +481,14 @@ bool IWWindow::CalculateTargetCoordinates(const IWTargetPosition& position, CPoi
481481 double distanceToThreshold = CalculateDistance (position.latitude , position.longitude , selectedApproach.thresholdLatitude , selectedApproach.thresholdLongitude );
482482 double directionToThreshold = CalculateBearing (position.latitude , position.longitude , selectedApproach.thresholdLatitude , selectedApproach.thresholdLongitude );
483483 double angleDiff = (selectedApproach.localizerCourse - directionToThreshold) / 180.0 * PI; // anglediff in radians
484- double heightAboveThreshold = position.pressureCorrectedAltitude - selectedApproach.thresholdAltitude ;
484+ double heightAboveThreshold = position.trueAltitude - selectedApproach.thresholdAltitude ;
485485
486- if (applyTemperatureCorrection) {
486+ auto airportTemperature = m_latestLiveData.airportTemperatures .find (selectedApproach.airport );
487+ if (applyTemperatureCorrection && airportTemperature != m_latestLiveData.airportTemperatures .end ()) {
487488 // In newer flight simulators true altitude is affected by the temperature.
488489 // In cold weather aircraft will be shown higher than they actually are, unless we correct for it.
489490 // See: https://forums.flightsimulator.com/t/vatsim-ivao-pilotedge-users-be-aware-of-an-important-bug/426142/468
490- int temperatureCorrection = CalculateTemperatureCorrection (position.pressureCorrectedAltitude , selectedApproach.thresholdAltitude , m_latestLiveData. airportTemperatures [selectedApproach. airport ] );
491+ int temperatureCorrection = CalculateTemperatureCorrection (position.trueAltitude , selectedApproach.thresholdAltitude , airportTemperature-> second );
491492 heightAboveThreshold -= temperatureCorrection;
492493 }
493494
@@ -628,10 +629,18 @@ void IWWindow::CreatePopupMenu(CPoint point)
628629 MENU_ITEM_SHOW_LABELS,
629630 _T (" Show labels by default" )
630631 );
632+
633+ auto airportTemperature = m_latestLiveData.airportTemperatures .find (selectedApproach.airport );
634+ auto airportTemperatureMenuText =
635+ " Apply temperature correction ("
636+ + selectedApproach.airport + " : "
637+ + (airportTemperature != m_latestLiveData.airportTemperatures .end () ? std::to_string (airportTemperature->second ) + " °C" : " N/A" )
638+ + " )" ;
639+
631640 menu.AppendMenu (
632641 MF_STRING | (this ->applyTemperatureCorrection ? MF_CHECKED : MF_UNCHECKED),
633642 MENU_ITEM_CORRECT_FOR_TEMPERATURE,
634- _T (" Apply temperature correction " )
643+ _T (airportTemperatureMenuText. c_str () )
635644 );
636645 menu.AppendMenu (
637646 MF_STRING,
0 commit comments