What is the equivelant of the System.Device.Location.GeoCoordinate.GetDistanceTo method in Metro style Windows 8 Applications.
Metro applications have the Geocoordinate class (With a lower case 'C') but no GetDistanceTo method.
Secondly, the Metro Geocoordinate class has no constructor. How can I create an instance of it.
I decompiled the .NET 4.5 GetDistanceTo method as per BlackLight. Copying here to save people some effort.
public double GetDistanceTo(GeoCoordinate other)
{
if (double.IsNaN(this.Latitude) || double.IsNaN(this.Longitude) || double.IsNaN(other.Latitude) || double.IsNaN(other.Longitude))
{
throw new ArgumentException(SR.GetString("Argument_LatitudeOrLongitudeIsNotANumber"));
}
else
{
double latitude = this.Latitude * 0.0174532925199433;
double longitude = this.Longitude * 0.0174532925199433;
double num = other.Latitude * 0.0174532925199433;
double longitude1 = other.Longitude * 0.0174532925199433;
double num1 = longitude1 - longitude;
double num2 = num - latitude;
double num3 = Math.Pow(Math.Sin(num2 / 2), 2) + Math.Cos(latitude) * Math.Cos(num) * Math.Pow(Math.Sin(num1 / 2), 2);
double num4 = 2 * Math.Atan2(Math.Sqrt(num3), Math.Sqrt(1 - num3));
double num5 = 6376500 * num4;
return num5;
}
}
The Metro Geocoordinate
has no public
constructor for some reason. The best way to implement this in my opinion is to use Reflector and copy the implementation of System.Device.Location.GeoCoordinate
which will also give you GetDistanceTo
.
Hopefully this will be re-added to the API at a later time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With