import math
#计算两点经纬度的距离
def getDistance2(lonA,latA, lonB,latB):
ra = 6378140 # radius of equator: meter
rb = 6356755 # radius of polar: meter
flatten = (ra - rb) / ra # Partial rate of the earth
# change angle to radians
radLatA = math.radians(latA)
radLonA = math.radians(lonA)
radLatB = math.radians(latB)
radLonB = math.radians(lonB)
pA = math.atan(rb / ra * math.tan(radLatA))
pB = math.atan(rb / ra * math.tan(radLatB))
ss = math.sin(pA) * math.sin(pB) + math.cos(pA) * math.cos(pB) * math.cos(radLonA - radLonB)
if ss>1:
ss = 1
x = math.acos(ss)
c1 = (math.sin(x) - x) * (math.sin(pA) + math.sin(pB)) ** 2 / math.cos(x / 2) ** 2
try:
c2 = (math.sin(x) + x) * (math.sin(pA) - math.sin(pB)) ** 2 / math.sin(x / 2) ** 2
except:
c2=0
dr = flatten / 8 * (c1 - c2)
distance = ra * (x + dr)
return distance
course_angle = 330
duibian = math.sin(course_angle*math.pi/180)*35
zhijiao_bian = math.sqrt(35 * 35 - duibian * duibian);
y = 116.378507
x = 39.124271
# 计算 当前纬度下 的1米的经纬度距离
add_lon = abs(1 / 111000 * math.cos(y))
add_lat = abs(1 / 111000)
if 90 > course_angle >= 0:
x1 = x+add_lon*zhijiao_bian
y1 = y+add_lat*duibian
if 180 > course_angle >= 90:
x1 = x-add_lon*zhijiao_bian
y1 = y+add_lat*duibian
if 270 > course_angle >= 180:
x1 = x-add_lon*zhijiao_bian
y1 = y+add_lat*duibian
if 359.999 > course_angle >= 270:
x1 = x+add_lon*zhijiao_bian
y1 = y+add_lat*duibian
print(y1,",",x1)
print(getDistance2(y,x,y1,x1))
根据航向角和距离计算平移后的经纬坐标
猜你喜欢
转载自blog.csdn.net/wuhchengfei616/article/details/108791708
今日推荐
周排行