calculating a gps coordinate given a point, bearing and distance

前端 未结 4 381
粉色の甜心
粉色の甜心 2021-02-04 21:30

I have a problem which draws my back in some project for some time now.

I\'m basically looking to trap a polygon using x,y points drawn by some script I\'ve written. lat1

4条回答
  •  野性不改
    2021-02-04 21:51

    The sin and cos functions expect their arguments in radians, not in degrees. The asin and atan2 functions produce a result in radians, not in degrees. In general, one needs to convert input angles (lat1, lon1 and bearing) from degrees to radians using math.radians() and convert output angles (lat2 and lon2) from radians to degrees using math.degrees().

    Note that your code has two other problems:

    (1) It doesn't allow for travel across the 180-degrees meridian of longitude; you need to constrain your answer such that -180 <= longitude_degrees <= +180.

    (2) If you are going to use this function extensively, you might like to remove the redundant calculations: sin(lat1), cos(dr), cos(lat1), and sin(dr) are each calculated twice.

提交回复
热议问题