根据给定的起始坐标,方位角和距离查找目标坐标 [英] Find destination coordinates given starting coordinates, bearing, and distance
问题描述
我正在查看此处列出的公式: http://www.movable-type.co.uk/scripts/latlong.html
I'm looking at the formula listed here: http://www.movable-type.co.uk/scripts/latlong.html
我似乎遇到了麻烦,因为生成的坐标不是我期望的那样.
I seem to be having trouble as the resulting coordinates are not what I would expect them to be.
提供以下信息:
开始纬度:28.455556
Start lat: 28.455556
开始lon:-80.527778
Start lon: -80.527778
轴承:317.662819(度)
Bearing: 317.662819(Degrees)
距离:130.224835(海里)
Distance: 130.224835(Nautical miles)
def getEndpoint(lat1,lon1,bearing,d):
R = 6378.1 #Radius of the Earth
brng = math.radians(bearing) #convert degrees to radians
d = d*1.852 #convert nautical miles to km
lat2 = math.asin( math.sin(lat1)*math.cos(d/R) + math.cos(lat1)*math.sin(d/R)*math.cos(brng))
lon2 = lon1 + math.atan2(math.sin(brng)*math.sin(d/R)*math.cos(lat1),math.cos(d/R)-math.sin(lat1)*math.sin(lat2))
return lat2,lon2
该函数返回:
最后一位:-0.209110644042
end lat: -0.209110644042
结尾lon:-80.5017472335
end lon: -80.5017472335
但这是我起始位置以东的坐标,这没有任何意义,因为317方位指向我起始位置的西北.
But this is a coordinate east of my beginning location, it doesn't make any sense because 317 bearing is pointing north-west of my starting location.
上面的图片应该是最终的坐标在左上角的样子.
Above picture is what It should look like with the final ending coordinate on the upper left.
哪里出问题了?
推荐答案
根据此页面
math.sin(x)
...返回x弧度的正弦.
math.sin(x)
... Return the sine of x radians.
因此,您需要先将lat1和lon1转换为弧度,然后再将lat2和lon2转换回度.
So, you need to convert lat1 and lon1 to radians before your equation and then later you can convert lat2 and lon2 back into degrees.
这篇关于根据给定的起始坐标,方位角和距离查找目标坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!