def est_dist( latitude1, longitude1, latitude2, longitude2 ) :
"""
Returns an estimate of the distance between two geographic points
This is a quick and dirty vinc_dist
which will generally estimate the distance to within 1%
Returns distance in metres
"""
f = 1.0 / 298.257223563 # WGS84
a = 6378137.0 # metres
piD4 = 0.785398163397
latitude1 = latitude1 * piD4 / 45.0
longitude1 = longitude1 * piD4 / 45.0
latitude2 = latitude2 * piD4 / 45.0
longitude2 = longitude2 * piD4 / 45.0
c = math.cos((latitude2+latitude1)/2.0)
return math.sqrt( pow(math.fabs(latitude2-latitude1), 2) + \
pow(math.fabs(longitude2-longitude1)*c, 2) ) * a * ( 1.0 - f + f * c )
# END of rough estimate of the distance.
评论列表
文章目录