Get direction (compass) with two longitude/latitude points

前端 未结 4 1877
遥遥无期
遥遥无期 2020-12-02 12:19

I\'m working on a "compass" for a mobile-device. I have the following points:

point 1 (current location): Latitude = 47.2246, Longitude = 8.8257
poi         


        
4条回答
  •  时光取名叫无心
    2020-12-02 13:09

    I couldn't understand your solution well, calculating the slope worked for me. To modify on efwjames's and your answer. This should do -

    import math
    def getDegrees(lat1, lon1, lat2, lon2,head):
        dLat = math.radians(lat2-lat1)
        dLon = math.radians(lon2-lon1)
        bearing = math.degrees(math.atan2(dLon, dLat))
        return head-bearing
    

提交回复
热议问题