jamesmontemagno / GeolocatorPlugin

Geolocation plugin for Xamarin and Windows
MIT License
294 stars 158 forks source link

NaN is better than Zero for Speed, Heading, Accuracy and Altitude Accuracy #338

Closed gmarbury closed 3 years ago

gmarbury commented 4 years ago

Hello James and thank you for all the work you do to benefit the Xamarin community.

In many places in the code, you are doing expressions like this;

if (position.Coordinate.Speed != null) pos.Speed = position.Coordinate.Speed.Value;

This essentially leaves the Speed, Heading, Accuracy, and AltitudeAccuracy set to 0 when they are not defined.

As you are aware, zero is an actual value for these quantities which we desire to treat differently than not having the quantities ( speed, heading, etc)

Can you please either 1) add a setting property like "ReturnNANs" that returns double.NaN instead or 2) allow a way for us to replace the functions that do the conversions with delegates or overrides of our own.

Thank you in advance for your consideration.

NOTE: I have already evaluated Xamarin.Essentials. It appears to have this same undesired behavior too but it also does not allow you to listen to locations.

It looks like these are the relevant methods UWP: GeolocatorImplementation.GetPosition(Geolocation postion), Andoid: GeolocationUtils.ToPosition(this Location location) Apple: Doesn't appear to have one function but has related code in the following methods

gmarbury commented 4 years ago

Looks like this pull request will address the issue too with HasSpeed, HasHeading, etc. What's the status of it? https://github.com/jamesmontemagno/GeolocatorPlugin/pull/311

jamesmontemagno commented 3 years ago

Integrating #311