Determine compass direction from one lat/lon to the other

前端 未结 3 1626
星月不相逢
星月不相逢 2020-12-21 12:25

Does anyone have an algorithm to determine the direction from one lat/lon to another (pseudo-code):

CalculateHeading( lat1, lon1, lat2, long2 ) returns stri         


        
3条回答
  •  醉话见心
    2020-12-21 12:50

    Convert to a numeric angle and use the result to look up the text. For example, -22.5..+22.5 = N. +22.5..67.5 = NE, 67.5..112.5 = E, etc. Of course, that's assuming you're using only N, NE, E, SE, S, SW, W, NW -- if you decide (for example) to go with the old "32 points of the compass", each text string obviously represents a smaller range.

提交回复
热议问题