I want to calculate the maneuver details (turn-left, turn-right, etc) from the coordinates array returned by google roads API (I'm using JavaScript). I tried to calculate the degrees between two coordinates using this code:
function radians
{ return n * (Math.PI / 180);}function degrees
{ return n * (180 / Math.PI);}function getBearing(startLat,startLong,endLat,endLong){ startLat = radians(startLat); startLong = radians(startLong); endLat = radians(endLat); endLong = radians(endLong); var dLong = endLong - startLong; var dPhi = Math.log(Math.tan(endLat/2.0+Math.PI/4.0)/Math.tan(startLat/2.0+Math.PI/4.0)); if (Math.abs(dLong) > Math.PI){ if (dLong > 0.0) dLong = -(2.0 * Math.PI - dLong); else dLong = (2.0 * Math.PI + dLong); } return (degrees(Math.atan2(dLong, dPhi)) + 360.0) % 360.0;}this function returns degrees, but I don't know how to calculate or what is the logic to manipulate the maneuver details from the degrees?
Is there any other way to calculate maneuver details from coordinates?
أكثر...
function radians
Is there any other way to calculate maneuver details from coordinates?
أكثر...