alexandruc Posted December 15, 2015 Posted December 15, 2015 (edited) Hello,Based on what I read here and on google I put together the following code:Func atan2($y, $x) Return (2 * ATan($y / ($x + Sqrt($x * $x + $y * $y)))) EndFunc Func new_coords($lat,$long,$distance,$dir) $earthRadius = 6371 $lat1 = _Radian($lat) $lon1 = _Radian($long) $bearing = _Radian($dir); $lat2 = asin(sin($lat1) * cos($distance / $earthRadius) + cos($lat1) * sin($distance / $earthRadius) * cos($bearing)) $lon2 = $lon1 + atan2(sin($bearing) * sin($distance / $earthRadius) * cos($lat1), cos($distance / $earthRadius) - sin($lat1) * sin($lat2)) return _Degree($lat2)&","&_Degree($lon2) EndFuncThe function receives as input the current location (for example: 48.4456 , 2.298889) the distance in km and the bearing (0,90,180 etc) for which to generate new GPS coordinates.However, for some reason, in certain cases (I guess due to moving on the map, and passing geographical parallels?) the new coordinates are wrong and just overlap older coordinates. This doesn't happen all the time so I have no idea what's wrong.Can anyone tell me if my function is wrong by design and maybe point me in the right direction (maybe if there already is such an UDF I couldn't find...)?Thank you EDIT: pffff... Sorry, wrong forum section. can a mod please move it to the right place? Sorry again Edited December 15, 2015 by alexandruc
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now