<分区>
我正在使用 Python 并完成了以下操作,给定元组坐标列表,找到与指定坐标(Google map 坐标)最近的坐标。
但与我的代码中的谷歌地图相比,最近的坐标不准确。请帮助我。
这是我的代码
def find_coords(c, l):
tmp_list = []
(x,y) = l[0]
for (a,b) in l[1:]:
if (x-c[0])**2 + (y-c[1])**2 > (a-c[0])**2 + (b-c[1])**2:
(x,y) = (a,b)
tmp_list.append((x,y))
return tmp_list
ccoordinate_list = [(11.6702634, 72.313323), (11.6723698, 78.114523), (31.67342698, 78.465323), (12.6702634, 72.313323), (12.67342698, 75.465323)]
coordinate = (11.6723698, 78.114523)
while coordinate_list[1:]:
coordinate_list = find_coords(coordinate, coordinate_list)