示例#1
0
 def test_units_and_separators(self):
     self.assertEqual(-41.38, parse_latitude('-41.38'))
     self.assertEqual(-41.38, parse_latitude('41 22.8S'))
     self.assertEqual(-41.38, parse_latitude('41 22 48S'))
     self.assertAlmostEqual(-41.380008333333336,
                            parse_latitude('41:22:48.03S'))
     self.assertEqual(-41.38, parse_latitude('41 22\' 48" S'))
     self.assertEqual(-41.38, parse_latitude('41 22\' 48\'\' S'))
     self.assertEqual(-41.38, parse_latitude(u' 41°  22\'  48"  S  '))
     self.assertEqual(-41.38, parse_latitude(u'41°22\'48"S'))
     self.assertEqual(-41.38, parse_latitude(u'41°22′48″S'))
示例#2
0
    def test_arithmetic(self):
        self.assertIsNone(parse_latitude(None))
        self.assertIsNone(parse_latitude(''))
        self.assertEqual(1, parse_latitude('1'))
        self.assertEqual(-1, parse_latitude('-1'))
        self.assertEqual(1, parse_latitude('1 n'))
        self.assertEqual(-1, parse_latitude('1 S '))
        self.assertAlmostEqual(1.5111111111111111, parse_latitude('1 30 40 N'))
        self.assertAlmostEqual(1.5111111111111111,
                               parse_longitude('1 30 40 E'))
        self.assertAlmostEqual(-1.5111111111111111,
                               parse_latitude('1 30 40 S'))
        self.assertAlmostEqual(-1.5111111111111111,
                               parse_longitude('1 30 40 W'))
        self.assertAlmostEqual(89.99972222222222, parse_latitude('89 59 59 N'))
        self.assertAlmostEqual(179.99972222, parse_longitude('179 59 59 e'))
        self.assertAlmostEqual(-89.99972222222222,
                               parse_latitude('89 59 59 s'))
        self.assertAlmostEqual(-179.99972222, parse_longitude('179 59 59 w'))

        # DMS values with floating-point minutes
        self.assertAlmostEqual(1.500185, parse_latitude('1 30 0.666 N'))

        # DMS values with floating-point seconds
        self.assertEqual(1.0002777777777778, parse_latitude('1 0 1 N'))
        self.assertAlmostEqual(1.5166666638888888,
                               parse_latitude('1 30 59.99999 N'))
        self.assertAlmostEqual(-179.99999999999721,
                               parse_longitude('179 59 59.99999999 W'))

        # Zero degrees
        self.assertEqual(0.5, parse_latitude('0 30 0 N'))
        self.assertAlmostEqual(0.5083333333333333, parse_latitude('0 30 30 N'))

        # All zeroes
        self.assertEqual(0, parse_latitude('0 0 0 N'))
示例#3
0
    def test_arithmetic(self):
        self.assertEqual(1, parse_latitude('1'))
        self.assertEqual(-1, parse_latitude('-1'))
        self.assertEqual(1, parse_latitude('1 n'))
        self.assertEqual(-1, parse_latitude('1 S '))
        self.assertAlmostEqual(1.5111111111111111,  parse_latitude('1 30 40 N'))
        self.assertAlmostEqual(1.5111111111111111,  parse_longitude('1 30 40 E'))
        self.assertAlmostEqual(-1.5111111111111111, parse_latitude('1 30 40 S'))
        self.assertAlmostEqual(-1.5111111111111111, parse_longitude('1 30 40 W'))
        self.assertAlmostEqual(89.99972222222222,   parse_latitude('89 59 59 N'))
        self.assertAlmostEqual(179.99972222,        parse_longitude('179 59 59 e'))
        self.assertAlmostEqual(-89.99972222222222,  parse_latitude('89 59 59 s'))
        self.assertAlmostEqual(-179.99972222,       parse_longitude('179 59 59 w'))

        # DMS values with floating-point minutes
        self.assertAlmostEqual(1.500185,            parse_latitude('1 30 0.666 N'))

        # DMS values with floating-point seconds
        self.assertEqual(1.0002777777777778,        parse_latitude('1 0 1 N'))
        self.assertAlmostEqual(1.5166666638888888,  parse_latitude('1 30 59.99999 N'))
        self.assertAlmostEqual(-179.99999999999721, parse_longitude('179 59 59.99999999 W'))

        # Zero degrees
        self.assertEqual(0.5,                       parse_latitude('0 30 0 N'))
        self.assertAlmostEqual(0.5083333333333333,  parse_latitude('0 30 30 N'))

        # All zeroes
        self.assertEqual(0, parse_latitude('0 0 0 N'))
示例#4
0
 def test_units_and_separators(self):
     self.assertEqual(-41.38, parse_latitude('-41.38'))
     self.assertEqual(-41.38, parse_latitude(u'-41.38°'))
     self.assertEqual(-41.38, parse_latitude(u'41.38° S'))
     self.assertEqual(-41.38, parse_latitude('41 22.8S'))
     self.assertEqual(-41.38, parse_latitude('41 22 48S'))
     self.assertAlmostEqual(-41.36666666666667, parse_latitude('41:22:00S'))
     self.assertAlmostEqual(-41.380008333333336, parse_latitude('41:22:48.03S'))
     self.assertEqual(-41.38, parse_latitude('41 22\' 48" S'))
     self.assertEqual(-41.38, parse_latitude('41 22\' 48\'\' S'))
     self.assertEqual(-41.38, parse_latitude(u' 41°  22\'  48"  S  '))
     self.assertEqual(-41.38, parse_latitude(u'41°22\'48"S'))
     self.assertEqual(-41.38, parse_latitude(u'41°22′48″S'))
     self.assertEqual(-41,    parse_latitude(u'41°00′00″S'))