Skip to content

Pressure to altitude conversion fixed#2483

Merged
pgrawehr merged 5 commits intodotnet:mainfrom
pgrawehr:PressureAndAltitude
Mar 13, 2026
Merged

Pressure to altitude conversion fixed#2483
pgrawehr merged 5 commits intodotnet:mainfrom
pgrawehr:PressureAndAltitude

Conversation

@pgrawehr
Copy link
Contributor

@pgrawehr pgrawehr commented Mar 12, 2026

Fixes #2481

The formula had a typo, which resulted in values being off around 10%.

The change is breaking, because one overload was removed, as it technically doesn't make sense.

Microsoft Reviewers: Open in CodeFlow

@dotnet-policy-service dotnet-policy-service bot added the area-device-bindings Device Bindings for audio, sensor, motor, and display hardware that can used with System.Device.Gpio label Mar 12, 2026
double meters = ((Math.Pow(seaLevelPressure.Pascals / pressure.Pascals, 1 / 5.255) - 1) * airTemperature.Kelvins) / DefaultTemperatureGradient;
return Length.FromMeters(meters);
}
[Obsolete("Behavior is confusing. Use CalculateAltitude(Pressure, Pressure, Temperature) instead")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove or unobsolete

@pgrawehr pgrawehr merged commit f8d124f into dotnet:main Mar 13, 2026
11 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-device-bindings Device Bindings for audio, sensor, motor, and display hardware that can used with System.Device.Gpio

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WeatherHelper.CalculateAltitude is incorrect

2 participants