Geeks With Blogs

News Please visit me at my new blog!!

profile for Aligned at Stack Overflow, Q&A for professional and enthusiast programmers
"free in Christ Jesus from the law of sin and death." Romans 8:2 (ESV) Check out the Falling Plates video on YouTube.
more about the Gospel
And then listen to Francis Chan speaking at LifeLight in SD.



Programming and Learning from SD

A co-worker (Scott) sent out this email and it was so good I asked him if I could share it with all of you. I changed the latitude and longitude to random locations to protect the innocent.

“Stumbled across this method this morning while coding all the math out by hand to calculate distances. This one is definitely worth filing away for future reference, saved me a ton of work. This was added in v4 of the framework, and is in the core framework install, so should work in services as well as client applications.

var location1 = new GeoCoordinate(40.102, -94.788171);
var location2 = new GeoCoordinate(50.0011, -96.699148);
 
 // distance shown is straight line meters.
Console.WriteLine(location1.GetDistanceTo(location2));
Console.ReadKey();

 

http://msdn.microsoft.com/en-us/library/system.device.location.geocoordinate.getdistanceto(v=vs.100).aspx

http://en.wikipedia.org/wiki/Haversine_formula

Posted on Wednesday, June 26, 2013 11:30 AM Productivity , Tools , .Net | Back to top


Comments on this post: System.Device.Location.GeoLocation

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Aligned | Powered by: GeeksWithBlogs.net