Ralph, this is brilliant. I remember trying to do something similar years ago, 
and giving up because I didn't know how to do the math. I suck at math, or 
rather I am too lazy and impatient to work the problem. 

Bob S

> On Apr 3, 2020, at 14:27 , Ralph DiMola via use-livecode 
> <use-livecode@lists.runrev.com> wrote:
> 
> Graham,
> 
> This my distance calculation for what it's worth.
> 
> Function distance lat1, lon1, lat2, lon2, unit
>   -- Calculate Distance between to points
>   --
>   --lat1, lon1, lat2, lon2 are in deg.fractionalDegrees
>   -- Unit
>   --     if empty then miles
>   --     K = kilometers
>   --     N = nautical miles
>   local theta
>   local dist
> 
>   Put lon1 - lon2 into theta
>   put Sin(deg2rad(lat1)) * Sin(deg2rad(lat2)) + Cos(deg2rad(lat1)) * 
> Cos(deg2rad(lat2)) * Cos(deg2rad(theta)) into dist
> 
>   put Acos(dist) into dist
>   put rad2deg(dist) into dist
>   put dist * 60 * 1.1515 into dist
> 
>   switch unit
>      case "K"
>         put dist * 1.609344 into dist
>      case "N"
>         put dist * 0.8684 into dist
>   end switch
> 
>   Return dist
> 
> End distance
> 
> 
> Function rad2deg rad
>   Return rad / PI * 180.0
> end rad2deg
> 
> 
> Ralph DiMola
> IT Director
> Evergreen Information Services
> rdim...@evergreeninfo.net


_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to