def test_ne(self):
        arc1 = Arc(SCoordinate(0, 0),
                   SCoordinate(np.deg2rad(10), np.deg2rad(10)))
        arc2 = Arc(SCoordinate(0, np.deg2rad(10)),
                   SCoordinate(np.deg2rad(10), 0))

        self.assertTrue(arc1 != arc2)

        self.assertFalse(arc1 != arc1)
 def test_repr(self):
     """Check the representation
     """
     d = SCoordinate(0, 0)
     self.assertEqual(repr(d), "(0.0, 0.0)")
 def test_hdistance(self):
     """Test Haversine formula
     """
     d = SCoordinate(0, 0).hdistance(SCoordinate(1, 1))
     self.assertTrue(np.allclose(d, 1.2745557823062943))
 def test_distance(self):
     """Test Vincenty formula
     """
     d = SCoordinate(0, 0).distance(SCoordinate(1, 1))
     self.assertEquals(d, 1.2745557823062943)
    def test_angle(self):
        arc1 = Arc(
            SCoordinate(np.deg2rad(157.5), np.deg2rad(89.234600944314138)),
            SCoordinate(np.deg2rad(90), np.deg2rad(89)))
        arc2 = Arc(
            SCoordinate(np.deg2rad(157.5), np.deg2rad(89.234600944314138)),
            SCoordinate(np.deg2rad(135), np.deg2rad(89)))

        self.assertAlmostEqual(np.rad2deg(arc1.angle(arc2)),
                               -44.996385007218926, 13)

        arc1 = Arc(
            SCoordinate(np.deg2rad(112.5), np.deg2rad(89.234600944314138)),
            SCoordinate(np.deg2rad(90), np.deg2rad(89)))
        arc2 = Arc(
            SCoordinate(np.deg2rad(112.5), np.deg2rad(89.234600944314138)),
            SCoordinate(np.deg2rad(45), np.deg2rad(89)))

        self.assertAlmostEqual(np.rad2deg(arc1.angle(arc2)),
                               44.996385007218883, 13)

        arc1 = Arc(SCoordinate(0, 0), SCoordinate(1, 0))
        self.assertEqual(arc1.angle(arc1), 0)

        arc2 = Arc(SCoordinate(1, 0), SCoordinate(0, 0))
        self.assertEqual(arc1.angle(arc2), 0)

        arc2 = Arc(SCoordinate(0, 0), SCoordinate(-1, 0))
        self.assertEqual(arc1.angle(arc2), np.pi)

        arc2 = Arc(SCoordinate(2, 0), SCoordinate(1, 0))
        self.assertEqual(arc1.angle(arc2), np.pi)

        arc2 = Arc(SCoordinate(2, 0), SCoordinate(3, 0))
        self.assertRaises(ValueError, arc1.angle, arc2)
    def test_intersection(self):
        arc1 = Arc(SCoordinate(0, 0),
                   SCoordinate(np.deg2rad(10), np.deg2rad(10)))
        arc2 = Arc(SCoordinate(0, np.deg2rad(10)),
                   SCoordinate(np.deg2rad(10), 0))
        lon, lat = arc1.intersection(arc2)

        self.assertTrue(np.allclose(np.rad2deg(lon), 5))
        self.assertEquals(np.rad2deg(lat), 5.0575148968282093)

        arc1 = Arc(SCoordinate(0, 0),
                   SCoordinate(np.deg2rad(10), np.deg2rad(10)))

        self.assertTrue(arc1.intersection(arc1) is None)

        arc1 = Arc(
            SCoordinate(np.deg2rad(24.341215776575297),
                        np.deg2rad(44.987819588259327)),
            SCoordinate(np.deg2rad(18.842727517611817),
                        np.deg2rad(46.512483610284178)))
        arc2 = Arc(
            SCoordinate(np.deg2rad(20.165961750361905),
                        np.deg2rad(46.177305385810541)),
            SCoordinate(np.deg2rad(20.253297585831707),
                        np.deg2rad(50.935830837274324)))
        inter = SCoordinate(np.deg2rad(20.165957021925202),
                            np.deg2rad(46.177022633103398))
        self.assertEquals(arc1.intersection(arc2), inter)

        arc1 = Arc(
            SCoordinate(np.deg2rad(-2.4982818108326734),
                        np.deg2rad(48.596644847869655)),
            SCoordinate(np.deg2rad(-2.9571441235622835),
                        np.deg2rad(49.165688435261394)))
        arc2 = Arc(
            SCoordinate(np.deg2rad(-3.4976667413531688),
                        np.deg2rad(48.562704872921373)),
            SCoordinate(np.deg2rad(-5.893976312685715),
                        np.deg2rad(48.445795283217116)))

        self.assertTrue(arc1.intersection(arc2) is None)
 def test_str(self):
     arc1 = Arc(SCoordinate(0, 0),
                SCoordinate(np.deg2rad(10), np.deg2rad(10)))
     self.assertEqual(str(arc1), str(arc1.start) + " -> " + str(arc1.end))
     self.assertEqual(repr(arc1), str(arc1.start) + " -> " + str(arc1.end))
 def test_to_spherical(self):
     """Test converting to spherical coordinates.
     """
     d = CCoordinate((1., 0., 0.))
     c = SCoordinate(0, 0)
     self.assertEqual(d.to_spherical(), c)