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))
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)