Exemplo n.º 1
0
 def distance(lat1, lon1, lat2, lon2, R=3959):
     # http://andrew.hedges.name/experiments/haversine/
     dlon = radians(lon2 - lon1)
     dlat = radians(lat2 - lat1)
     a = sin(dlat / 2.0) ** 2 + cos(lat1) * cos(lat2) * sin(dlon / 2.0) ** 2
     return R * 2 * atan2(sqrt(a), sqrt(1 - a))
Exemplo n.º 2
0
 def distance(lat1, lon1, lat2, lon2, R=3959):
     # http://andrew.hedges.name/experiments/haversine/
     dlon = radians(lon2 - lon1)
     dlat = radians(lat2 - lat1)
     a = sin(dlat / 2.0) ** 2 + cos(lat1) * cos(lat2) * sin(dlon / 2.0) ** 2
     return R * 2 * atan2(sqrt(a), sqrt(1 - a))
Exemplo n.º 3
0
 def test_radians(self):
     assert_almost_equal(blaze.radians(180.0), math.pi)
     assert_almost_equal(blaze.radians(-90.0), -0.5*math.pi)
     assert_almost_equal(blaze.deg2rad(180.0), math.pi)
     assert_almost_equal(blaze.deg2rad(-90.0), -0.5*math.pi)