import math
def midpoint(x1, y1, x2, y2):
#Input values as degrees
#Convert to radians
lat1 = math.radians(x1)
lon1 = math.radians(x2)
lat2 = math.radians(y1)
lon2 = math.radians(y2)
bx = math.cos(lat2) * math.cos(lon2 - lon1)
by = math.cos(lat2) * math.sin(lon2 - lon1)
lat3 = math.atan2(math.sin(lat1) + math.sin(lat2), /
math.sqrt((math.cos(lat1) + bx) * (math.cos(lat1) /
+ bx) + by**2))
lon3 = lon1 + math.atan2(by, math.cos(lat1) + Bx)
return [round(math.degrees(lat3), 2), round(math.degrees(lon3), 2)]
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/tech/pnotes/8157.html