Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android - Essentials Geolocation | Added support for MslAltitudeMeters #27579

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bricefriha
Copy link

Description of Change

The goal of this change is to add support for MslAltitudeMeters.
We are setting MslAltitudeMeters as the default value for Location.Altitude. If MslAltitude is unavailable or Android version is lower than 34, we just set the regular Altitude.

Issues Fixed

Fixes #27554

Copy link
Contributor

Hey there @bricefriha! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Feb 5, 2025
@jsuarezruiz jsuarezruiz added platform/android 🤖 area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info labels Feb 5, 2025
@@ -24,7 +24,11 @@ internal static Location ToLocation(this AndroidLocation location) =>
{
Latitude = location.Latitude,
Longitude = location.Longitude,
#if ANDROID34_0_OR_GREATER
Altitude = location.HasMslAltitude ? location.MslAltitudeMeters : location.HasAltitude ? location.Altitude : default(double?),
Copy link
Author

Choose a reason for hiding this comment

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

@jfversluis
(sorry in advance, if you're not the right person to ping here)

Is it ok if we set MslAltitudeMeters as the default? or would it be better to have another option for it?

The reason why I went for this method is to avoid having to add this for all platforms

Copy link
Member

Choose a reason for hiding this comment

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

Hm good question. This is a breaking change because if people rely on location.Altitude they will now be forced to use location.MslAltitudeMeters and there is no way to opt out.

Can those values be different? Is there a way we can add to make it more optional?

Copy link
Author

Choose a reason for hiding this comment

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

According to @cschwarz 's comment on #27554, it should be a default since it offers a more consistent result compared to other platforms. Which checks out, since Apple uses MSL Altitude in their API too

I would personally go for it. We could also add a LegacyAltitude (I'm bad at naming things) property that would represent Location.Altitude.

@bricefriha bricefriha marked this pull request as ready for review February 6, 2025 05:42
@bricefriha bricefriha requested a review from a team as a code owner February 6, 2025 05:42
@jfversluis jfversluis self-assigned this Feb 6, 2025
Copy link
Member

@mattleibow mattleibow left a comment

Choose a reason for hiding this comment

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

I wonder if we should just add a new property? We could even add 2 new properties an be more explicit:

  • EllipsoidalAltitude
  • MeanSeaLevelAltitude

Then we obsolete Altitude and keep it returning what it did. Dows Windows have 2 different APIs?

Also saw this:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info community ✨ Community Contribution platform/android 🤖
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for MslAltitudeMeters in Essentials Geolocation on Android
4 participants