Interfacing with web services - advice needed

Richard Gaskin ambassador at fourthworld.com
Tue Mar 17 18:23:10 EDT 2015


David Epstein wrote:

> Graham Samuel stipulated that he did not want to code a LiveCode algorithm to solve this problem, but in case it might be useful here is a function that I believe does so.
>
> function earthKM myLat,myLon,Lat0,Lon0, at aid
>   -- return km distance on earth, load aid [angle in degrees] from origin point Lon0,Lat0 to myPoint myLon,myLat
>   put PI/180 into rpd -- radians per degree
>   put myLat*rpd into myLat
>   put myLon*rpd into myLon
>   put Lat0*rpd into Lat0
>   put Lon0*rpd into lon0
>   put (SIN((myLat-Lat0)/2))^2+COS(Lat0)*COS(myLat)*(SIN((myLon-Lon0)/2))^2 into j
>   put 6371*2*ASIN(MIN(1,j^0.5)) into dkm -- distance in km
>   put ATAN2(SIN(myLon-Lon0)*COS(myLat),COS(Lat0)*SIN(myLat)-SIN(Lat0)*COS(myLat)*COS(myLon-Lon0)) into k -- bearing in radians
>   put k/rpd into aid -- in degrees
>   return dkm
> end earthKM

Rockin', David - thanks for posting that!

@Michael Doub:  with Mr. Epstein's permission, I nominate this for 
inclusion in Master Library.

-- 
  Richard Gaskin
  Fourth World Systems
  Software Design and Development for the Desktop, Mobile, and the Web
  ____________________________________________________________________
  Ambassador at FourthWorld.com                http://www.FourthWorld.com




More information about the use-livecode mailing list