Interfacing with web services - advice needed
David Epstein
dfepstein at comcast.net
Tue Mar 17 18:14:37 EDT 2015
>> For those who want to know, my current case involves a succession of points on the Earth’s surface where I know each one's longitude and latitude: I want to convert the intervals between these points to distances in metres (say).
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
David Epstein
More information about the use-livecode
mailing list