Haversine Formula in Python (Bearing and Distance between two GPS points)

后端 未结 10 1769
死守一世寂寞
死守一世寂寞 2020-11-22 09:47

Problem

I would like to know how to get the distance and bearing between 2 GPS points. I have researched on the haversine formula. Someone told me

10条回答
  •  失恋的感觉
    2020-11-22 10:27

    You can solve the negative bearing problem by adding 360°. Unfortunately, this might result in bearings larger than 360° for positive bearings. This is a good candidate for the modulo operator, so all in all you should add the line

    Bearing = (Bearing + 360) % 360
    

    at the end of your method.

提交回复
热议问题