Recent PostsRecent Posts Popular TopicsPopular Topics
 Home Search Members Calendar Who's On

 Calculate Distance in Miles from Latitude and Longitude Rate Topic Display Mode Topic Options
Author
 Message
 Posted Friday, February 6, 2009 7:32 AM
 SSCrazy Eights Group: General Forum Members Last Login: Tuesday, October 25, 2016 7:17 AM Points: 9,298, Visits: 9,517
 Comments posted to this topic are about the item Calculate Distance in Miles from Latitude and Longitude -- RBarryYoung, (302)375-0451 blog: MovingSQL.com, Twitter: @RBarryYoungProactive Performance Solutions, Inc. "Performance is our middle name."
Post #651657
 Posted Tuesday, February 17, 2009 1:16 AM
 SSC Veteran Group: General Forum Members Last Login: 2 days ago @ 3:23 AM Points: 262, Visits: 826
 Please could you supply us a "km version" of this nice script.In Europe, Australia, Asia, etc. we don't use miles or feet. ;)
Post #658276
 Posted Tuesday, February 17, 2009 2:52 AM
 SSC Rookie Group: General Forum Members Last Login: Tuesday, November 8, 2016 1:35 AM Points: 44, Visits: 1,013
 Really neat and just what I was looking for.Many thanksTim Tim
Post #658315
 Posted Tuesday, February 17, 2009 6:21 AM
 Ten Centuries Group: General Forum Members Last Login: Friday, January 30, 2015 8:42 AM Points: 1,332, Visits: 19,324
 RBarryYoung, am I missing something here? the function name is LatLonDistance(), but the tests use calculateDistance()? Is there a missing piece to this, or is it just a naming convention typo?Thanks,Jon ---------------------------------------------------------How best to post your questionHow to post performance problemsTally Table:What it is and how it replaces a loop"stewsterl 80804 (10/16/2009)I guess when you stop and try to understand the solution provided you not only learn, but save yourself some headaches when you need to make any slight changes."
Post #658425
 Posted Tuesday, February 17, 2009 7:14 AM
 Forum Newbie Group: General Forum Members Last Login: Friday, April 15, 2011 2:01 PM Points: 2, Visits: 19
 Because the earth is not strictly spherical (it "flattens" a bit due to its rotation), there's a mathematical adjustment that can be made which makes the result even more accurate, given any two locations worldwide.(I researched this about a year ago for a web application involving searching for points of interest within a specified radius of a reference point. I found various algorithms and chose one, which I translated to VBScript. It's nice to see the SQL implementation.)
Post #658477
 Posted Tuesday, February 17, 2009 7:17 AM
 Ten Centuries Group: General Forum Members Last Login: Friday, January 30, 2015 8:42 AM Points: 1,332, Visits: 19,324
 kevin (2/17/2009)Because the earth is not strictly spherical (it "flattens" a bit due to its rotation), there's a mathematical adjustment that can be made which makes the result even more accurate, given any two locations worldwide.(I researched this about a year ago for a web application involving searching for points of interest within a specified radius of a reference point. I found various algorithms and chose one, which I translated to VBScript. It's nice to see the SQL implementation.)And that adjustment is? ---------------------------------------------------------How best to post your questionHow to post performance problemsTally Table:What it is and how it replaces a loop"stewsterl 80804 (10/16/2009)I guess when you stop and try to understand the solution provided you not only learn, but save yourself some headaches when you need to make any slight changes."
Post #658480
 Posted Tuesday, February 17, 2009 7:19 AM
 Forum Newbie Group: General Forum Members Last Login: Wednesday, February 15, 2012 6:37 AM Points: 9, Visits: 31
 As you are using Lat/Long and I do not see any conversion, I am assuming that the distance is measured in Nautical Miles not Statute Miles is it not?
Post #658483
 Posted Tuesday, February 17, 2009 7:27 AM
 SSC-Insane Group: General Forum Members Last Login: Wednesday, April 13, 2016 12:23 AM Points: 20,643, Visits: 9,671
 Henk Schreij (2/17/2009)Please could you supply us a "km version" of this nice script.In Europe, Australia, Asia, etc. we don't use miles or feet. ;)Just do Result time 1.6. Easy enough to include in the function :D.
Post #658492
 Posted Tuesday, February 17, 2009 7:43 AM
 SSC Veteran Group: General Forum Members Last Login: 2 days ago @ 3:23 AM Points: 262, Visits: 826
 Quote: "Just do Result time 1.6. Easy enough to include in the function."I was hoping for new constants in the formula ;)But I realize the formula doesn't need a 6 or more numbers precision.
Post #658514
 Posted Tuesday, February 17, 2009 7:48 AM
 SSC-Insane Group: General Forum Members Last Login: Wednesday, April 13, 2016 12:23 AM Points: 20,643, Visits: 9,671
 I'm sure it's possible... but to avoid redoing 1 year of maths or waiting for someone to redo the calculations for that constant, I'll just take the small perf hit and do result * 1.6 .
Post #658522

 Permissions