Skip to content

Commit ee7fee3

Browse files
committed
Only apply temperature correction if temperature is available
Also show current temperature in the menu
1 parent 2c7fb0c commit ee7fee3

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

ILS_Window_Plugin/IWDataTypes.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ struct RGB {
1212
};
1313

1414
struct IWTargetPosition {
15-
int pressureCorrectedAltitude;
15+
int trueAltitude;
1616
double latitude;
1717
double longitude;
1818
};
@@ -27,7 +27,7 @@ struct IWRadarTarget {
2727

2828
struct IWLiveData {
2929
std::vector<IWRadarTarget> radarTargets;
30-
std::map<std::string, float> airportTemperatures;
30+
std::map<std::string, int> airportTemperatures;
3131
};
3232

3333
struct IWApproachDefinition {

ILS_Window_Plugin/IWPlugin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class IWPlugin : public EuroScopePlugIn::CPlugIn, IIWWndEventListener {
2222
IWStyling windowStyling;
2323
IWBehaviourSettings behaviourSettings;
2424
std::map<std::string, CRect> savedWindowPositions;
25-
std::map<std::string, float> airportTemperatures;
25+
std::map<std::string, int> airportTemperatures;
2626

2727
void OpenNewWindow(IWApproachDefinition* approach);
2828
void SyncWithActiveRunways();

ILS_Window_Plugin/IWWindow.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)