Exemple #1
0
    def testRaisesValueError(self):
        for lat1, lon1, lat2, lon2 in [
                (91., 0., 0., 0.),
                (0., 181., 0., 0.),
                (0., 0., 91., 0.),
                (0., 0., 0., 181.), ]:
            for f in [1, -1]:

                lat1 *= f
                lon1 *= f
                lat2 *= f
                lon2 *= f

                with self.assertRaises(ValueError):
                    orthodrome_ext.azibazi(lat1, lon1, lat2, lon2)

                with self.assertRaises(ValueError):
                    orthodrome_ext.distance_accurate50m(lat1, lon1, lat2, lon2)
    def testRaisesValueError(self):
        for lat1, lon1, lat2, lon2 in [
                (91., 0., 0., 0.),
                (0., 181., 0., 0.),
                (0., 0., 91., 0.),
                (0., 0., 0., 181.), ]:
            for f in [1, -1]:

                lat1 *= f
                lon1 *= f
                lat2 *= f
                lon2 *= f

                with self.assertRaises(ValueError):
                    orthodrome_ext.azibazi(lat1, lon1, lat2, lon2)

                with self.assertRaises(ValueError):
                    orthodrome_ext.distance_accurate50m(lat1, lon1, lat2, lon2)
Exemple #3
0
    def testRaisesValueError(self):
        '''
        Assert that orthodrome_ext implementations raise a ValueError when
        working on undefined lats/lons.
        '''
        for lat1, lon1, lat2, lon2 in [
            (91., 0., 0., 0.),
            (0., 181., 0., 0.),
            (0., 0., 91., 0.),
            (0., 0., 0., 181.),
        ]:
            for f in [1, -1]:

                lat1 *= f
                lon1 *= f
                lat2 *= f
                lon2 *= f

                with self.assertRaises(ValueError):
                    orthodrome_ext.azibazi(lat1, lon1, lat2, lon2)

                with self.assertRaises(ValueError):
                    orthodrome_ext.distance_accurate50m(lat1, lon1, lat2, lon2)
Exemple #4
0
def azibazi(*args, **kwargs):
    alat, alon, blat, blon = _latlon_pair(args)
    if alat == blat and alon == blon:
        return 0., 180.

    implementation = kwargs.get('implementation', 'c')
    assert implementation in ('c', 'python')
    if implementation == 'c':
        from pyrocko import orthodrome_ext
        return orthodrome_ext.azibazi(alat, alon, blat, blon)

    cd = cosdelta(alat, alon, blat, blon)
    azi = r2d * math.atan2(
        math.cos(alat * d2r) * math.cos(blat * d2r) * math.sin(d2r *
                                                               (blon - alon)),
        math.sin(d2r * blat) - math.sin(d2r * alat) * cd)
    bazi = r2d * math.atan2(
        math.cos(blat * d2r) * math.cos(alat * d2r) * math.sin(d2r *
                                                               (alon - blon)),
        math.sin(d2r * alat) - math.sin(d2r * blat) * cd)

    return azi, bazi
Exemple #5
0
def azibazi(*args, **kwargs):
    alat, alon, blat, blon = _latlon_pair(args)
    if alat == blat and alon == blon:
        return 0., 180.

    implementation = kwargs.get('implementation', 'c')
    assert implementation in ('c', 'python')
    if implementation == 'c':
        from pyrocko import orthodrome_ext
        return orthodrome_ext.azibazi(alat, alon, blat, blon)

    cd = cosdelta(alat, alon, blat, blon)
    azi = r2d*math.atan2(
        math.cos(alat*d2r) * math.cos(blat*d2r) *
        math.sin(d2r*(blon-alon)),
        math.sin(d2r*blat) - math.sin(d2r*alat) * cd)
    bazi = r2d*math.atan2(
        math.cos(blat*d2r) * math.cos(alat*d2r) *
        math.sin(d2r*(alon-blon)),
        math.sin(d2r*alat) - math.sin(d2r*blat) * cd)

    return azi, bazi