# coding=utf-8
import requests

from math import radians, cos, sin, asin, sqrt


# 计算两点间距离-m
def geodistance(lng1, lat1, lng2, lat2):
    lng1, lat1, lng2, lat2 = map(radians, [lng1, lat1, lng2, lat2])
    dlon = lng2 - lng1
    dlat = lat2 - lat1
    a = sin(dlat / 2) ** 2 + cos(lat1) * cos(lat2) * sin(dlon / 2) ** 2
    dis = 2 * asin(sqrt(a)) * 6371
    return dis


print ("%.3f" % (geodistance(120.110940, 30.296500, 120.145620, 30.318974)),'km')

