首先需要将经纬度按照时间戳排序
def calcu_dist_sum(imei_data):
lng_list = list(imei_data['lng'])
lat_list = list(imei_data['lat'])
lng_guiji = []
lat_guiji = []
previous_lng = -1
previous_lat = -1
for i in range(0, len(lng_list)-1):
if (previous_lng != lng_list[i]):
previous_lng = lng_list[i]
lng_guiji.append(lng_list[i])
lat_guiji.append(lat_list[i])
dist_sum = 0
if (len(lng_guiji) == 1):return 0
else:
for i in range(len(lng_guiji)-1):
dist = haversine(lng_guiji[i], lat_guiji[i], lng_guiji[i+1], lat_guiji[i+1])
if dist > 10000: continue
dist_sum += dist
return dist_sum