Compute the geodesic distance in meters between two points on the
  surface of the Earth.  The latitude and longitude angles are in
  degrees.

  Approximate geodesic distance function (Haversine Formula) assuming
  a perfect sphere of radius 6367 km (see "What are some algorithms
  for calculating the distance between 2 points?" in the GIS Faq at
  http://www.census.gov/geo/www/faq-index.html).  The approximate
  radius is adequate for our needs here, but a more sophisticated
  geodesic function should be used if greater accuracy is required
  (see "When is it NOT okay to assume the Earth is a sphere?" in the
  same faq).

def Distance(lat0, lng0, lat1, lng1):
  """
  Compute the geodesic distance in meters between two points on the
  surface of the Earth.  The latitude and longitude angles are in
  degrees.

  Approximate geodesic distance function (Haversine Formula) assuming
  a perfect sphere of radius 6367 km (see "What are some algorithms
  for calculating the distance between 2 points?" in the GIS Faq at
  http://www.census.gov/geo/www/faq-index.html).  The approximate
  radius is adequate for our needs here, but a more sophisticated
  geodesic function should be used if greater accuracy is required
  (see "When is it NOT okay to assume the Earth is a sphere?" in the
  same faq).
  """
  deg2rad = math.pi / 180.0
  lat0 = lat0 * deg2rad
  lng0 = lng0 * deg2rad
  lat1 = lat1 * deg2rad
  lng1 = lng1 * deg2rad
  dlng = lng1 - lng0
  dlat = lat1 - lat0
  a = math.sin(dlat*0.5)
  b = math.sin(dlng*0.5)
  a = a * a + math.cos(lat0) * math.cos(lat1) * b * b
  c = 2.0 * math.atan2(math.sqrt(a), math.sqrt(1.0 - a))
  return 6367000.0 * c