Link | calc_distance |
Author | Tim Taplin |
Category | Utility |
Version | 9.x |
License | Public Domain |
Posted | 26 Mar 2013 |
Updated | 26 Mar 2013 |
More by this author... |
This tag will calculate the distance between two points defined by latitude and longitude in miles with an optional parameter to return kilometers. Internally uses an implementation of the Haversine formula to account for curvature of the earth.
local('curr_coords' = pair(51.027576,-114.058891)) local('dest' = pair(51.011760, -114.066260)) calc_distance( #curr_coords->first, #curr_coords->second, #coord->first, #coord->second ) Returns: 1.172478
Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.
define calc_distance(curr_lat::decimal, curr_lon::decimal, dest_lat::decimal, dest_lon::decimal, meas='m') => { //provide current location and destination as latitude and longitude as decimal //optionally provide meas value of 'k' to return kilometers local(distance = ( ( ( (#curr_lat * pi / 180)->sin * (#dest_lat * pi / 180)->sin + (#curr_lat * pi / 180)->cos * (#dest_lat * pi / 180)->cos * ((#curr_lon - #dest_lon) * pi / 180)->cos )->acos * 180 / pi ) * 60 * 1.1515 )) #meas == 'k' ? return #distance*1.609344 | return #distance //return #distance }
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft
Related tags lp_math_GPSdistance lp_math_GPSradius