Coverage for /opt/obspy/update-docs/src/obspy/obspy/core/tests/test_util_geodetics : 80%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# -*- coding: utf-8 -*- calcVincentyInverse, gps2DistAzimuth
# checking for geographiclib HAS_GEOGRAPHICLIB = True except ImportError: HAS_GEOGRAPHICLIB = False
""" Test suite for obspy.core.util.geodetics """ """ Tests for the Vincenty's Inverse formulae. """ # the following will raise StopIteration exceptions because of two # nearly antipodal points 15.26804251, 2.93007342, -14.80522806, -177.2299081) 27.3562106, 72.2382356, -27.55995499, -107.78571981) 27.4675551, 17.28133229, -27.65771704, -162.65420626) 27.4675551, 17.28133229, -27.65771704, -162.65420626) # working examples # out of bounds
def test_gps2DistAzimuthWithGeographiclib(self): """ Testing gps2DistAzimuth function using the module geographiclib. """ # nearly antipodal points result = gps2DistAzimuth(15.26804251, 2.93007342, -14.80522806, -177.2299081) self.assertAlmostEquals(result[0], 19951425.048688546) self.assertAlmostEquals(result[1], 8.65553241932755) self.assertAlmostEquals(result[2], 351.36325485132306) # out of bounds self.assertRaises(ValueError, gps2DistAzimuth, 91, 0, 0, 0) self.assertRaises(ValueError, gps2DistAzimuth, -91, 0, 0, 0) self.assertRaises(ValueError, gps2DistAzimuth, 0, 0, 91, 0) self.assertRaises(ValueError, gps2DistAzimuth, 0, 0, -91, 0)
""" Test calcVincentyInverse() method with test data from Geocentric Datum of Australia. (see http://www.icsm.gov.au/gda/gdatm/gdav2.3.pdf) """ # test data: # Point 1: Flinders Peak, Point 2: Buninyong
# calculate result lat2, lon2)
# calculate deviations from test data
# calculate result with +- 360 for lon values lat2, lon2 - 720)
'Module geographiclib is installed, not using calcVincentyInverse') def test_gps2DistAzimuthBUG150(self): """ Test case for #150: UserWarning will be only raised if geographiclib is not installed. """ # this raises UserWarning
""" Simple test of the convenience function. """ # Test if it works. 1.0) # Test if setting the radius actually does something. Round to avoid # some precision problems on different machines. radius=6381), 5), round(0.99843284751606332, 5))
""" Test the location 2 degree conversion. """ # Inline method to avoid messy code. abs(math.radians(locations2degrees(lat1, long1, lat2, long2)) \ * 6371 - approx_distance) <= 20)
# Approximate values from the Great Circle Calculator: # http://williams.best.vwh.net/gccalc.htm
# Random location. # Test several combinations of quadrants. # Test some extreme values.
""" Test for #375. """ dist, azim, bazim = gps2DistAzimuth(50, 10, 50 + 1, 10 + 1) self.assertEqual(round(azim, 0), 32) self.assertEqual(round(bazim, 0), 213) dist, azim, bazim = gps2DistAzimuth(50, 10, 50 + 1, 10 - 1) self.assertEqual(round(azim, 0), 328) self.assertEqual(round(bazim, 0), 147) dist, azim, bazim = gps2DistAzimuth(50, 10, 50 - 1, 10 + 1) self.assertEqual(round(azim, 0), 147) self.assertEqual(round(bazim, 0), 327) dist, azim, bazim = gps2DistAzimuth(50, 10, 50 - 1, 10 - 1) self.assertEqual(round(azim, 0), 213) self.assertEqual(round(bazim, 0), 33)
if __name__ == '__main__': unittest.main(defaultTest='suite') |