Getting started with geographical coordinates
Ralph DiMola
rdimola at evergreeninfo.net
Fri Apr 3 17:45:22 EDT 2020
Thanks Bob.
Whoops... I forgot to include this:
Function deg2rad deg
Return (deg * PI / 180.0)
end deg2rad
Ralph DiMola
IT Director
Evergreen Information Services
rdimola at evergreeninfo.net
-----Original Message-----
From: use-livecode [mailto:use-livecode-bounces at lists.runrev.com] On Behalf
Of Bob Sneidar via use-livecode
Sent: Friday, April 03, 2020 5:31 PM
To: How to use LiveCode
Cc: Bob Sneidar
Subject: Re:
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 at 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
> rdimola at evergreeninfo.net
_______________________________________________
use-livecode mailing list
use-livecode at lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
More information about the use-livecode
mailing list