def get_center_of_nodes(nodes):
"""Helper function to get center coordinates of a group of nodes
"""
x = 0
y = 0
z = 0
for node in nodes:
lat = radians(float(node.lat))
lon = radians(float(node.lon))
x += cos(lat) * cos(lon)
y += cos(lat) * sin(lon)
z += sin(lat)
x = float(x / len(nodes))
y = float(y / len(nodes))
z = float(z / len(nodes))
center_lat = degrees(atan2(z, sqrt(x * x + y * y)))
center_lon = degrees(atan2(y, x))
return center_lat, center_lon
评论列表
文章目录