예제 #1
0
    def test_distance(self):
        lat_lon1 = LatLon.from_deg_min_sec(('N0 0. 0.00.', 'W121 22. 49.59.'))
        lat_lon2 = LatLon.from_deg_min_sec(('N1 0. 0.00.', 'W122 22. 49.59.'))

        self.assertAlmostEqual(lat_lon1.distance(lat_lon2),
                               157158.34911586,
                               places=7)
예제 #2
0
    def test_lat_lon_eq(self):
        lat_lon1 = LatLon.from_deg_min_sec(
            ('N37 36. 26.00.', 'W122 22. 49.59.'))
        lat_lon2 = LatLon.from_deg_min_sec(
            ('N37 36. 26.00.', 'E122 22. 49.59.'))

        self.assertEqual(lat_lon1, lat_lon1)
        self.assertNotEqual(lat_lon1, lat_lon2)
예제 #3
0
   def test_distance_lon(self):
       lat_lon1 = LatLon.from_deg_min_sec(('N0 0. 0.00.', 'W121 22. 49.59.'))
       lat_lon2 = LatLon.from_deg_min_sec(('N0 0. 0.00.', 'W122 22. 49.59.'))
       lat_lon3 = LatLon.from_deg_min_sec(('N1 0. 0.00.', 'W121 22. 49.59.'))
 
       self.assertAlmostEqual(lat_lon1.distance(lat_lon2), lat_lon1.distance(lat_lon3), places=7)
         
       lat_lon4 = LatLon.from_deg_min_sec(('N90 0. 0.00.', 'W121 22. 49.59.'))
       lat_lon5 = LatLon.from_deg_min_sec(('N90 0. 0.00.', 'W122 22. 49.59.'))
         
       self.assertAlmostEqual(lat_lon4.distance(lat_lon5), 0, places=10)
예제 #4
0
 def test_distance_lat(self):
     lat_lon1 = LatLon.from_deg_min_sec(('N34 36. 26.00.', 'W121 22. 49.59.'))
     lat_lon2 = LatLon.from_deg_min_sec(('N35 36. 26.00.', 'W121 22. 49.59.'))
       
     one_lat = 111130.55555555
       
     self.assertAlmostEqual(lat_lon1.distance(lat_lon2), one_lat, places=7)
     self.assertEqual(lat_lon1.distance(lat_lon2), lat_lon2.distance(lat_lon1))
       
     lat_lon3 = LatLon.from_deg_min_sec(('N36 36. 26.00.', 'W121 22. 49.59.'))
     self.assertAlmostEqual(lat_lon1.distance(lat_lon3), one_lat * 2, places=7)
예제 #5
0
    def test_position_distance(self):
        altitude1 = 0
        altitude2 = 32000
        pos1 = Position.from_deg_min_sec_feet(
            ('N37 36. 26.00.', 'W122 22. 49.59.'), altitude1)
        pos2 = Position.from_deg_min_sec_feet(
            ('N36 36. 26.00.', 'W122 22. 49.59.'), altitude2)

        self.assertAlmostEqual(
            pos1.distance(pos2),
            sqrt((altitude2 * FEET_TO_METERS_CONSTANT)**2 +
                 LatLon(pos1.lat_lon).distance(LatLon(pos2.lat_lon))**2))
예제 #6
0
    def test_distance_lon(self):
        lat_lon1 = LatLon.from_deg_min_sec(('N0 0. 0.00.', 'W121 22. 49.59.'))
        lat_lon2 = LatLon.from_deg_min_sec(('N0 0. 0.00.', 'W122 22. 49.59.'))
        lat_lon3 = LatLon.from_deg_min_sec(('N1 0. 0.00.', 'W121 22. 49.59.'))

        self.assertAlmostEqual(lat_lon1.distance(lat_lon2),
                               lat_lon1.distance(lat_lon3),
                               places=7)

        lat_lon4 = LatLon.from_deg_min_sec(('N90 0. 0.00.', 'W121 22. 49.59.'))
        lat_lon5 = LatLon.from_deg_min_sec(('N90 0. 0.00.', 'W122 22. 49.59.'))

        self.assertAlmostEqual(lat_lon4.distance(lat_lon5), 0, places=10)
예제 #7
0
    def test_distance_lat(self):
        lat_lon1 = LatLon.from_deg_min_sec(
            ('N34 36. 26.00.', 'W121 22. 49.59.'))
        lat_lon2 = LatLon.from_deg_min_sec(
            ('N35 36. 26.00.', 'W121 22. 49.59.'))

        one_lat = 111130.55555555

        self.assertAlmostEqual(lat_lon1.distance(lat_lon2), one_lat, places=7)
        self.assertEqual(lat_lon1.distance(lat_lon2),
                         lat_lon2.distance(lat_lon1))

        lat_lon3 = LatLon.from_deg_min_sec(
            ('N36 36. 26.00.', 'W121 22. 49.59.'))
        self.assertAlmostEqual(lat_lon1.distance(lat_lon3),
                               one_lat * 2,
                               places=7)
예제 #8
0
 def test_lat_lon_from_deg_min_sec(self):
     lat_lon1 = LatLon.from_deg_min_sec(('N37 36. 26.00.', 'W122 22. 49.59.'))
       
     self.assertTrue(lat_lon1 is not None)
     self.assertAlmostEqual(lat_lon1.get_lat(), 37.607222, places=5)
     self.assertAlmostEqual(lat_lon1.get_lon(), -122.38044166666666, places=10)
      
     self.assertEqual(lat_lon1.get_lat_in_radians(), radians(lat_lon1.get_lat()))
     self.assertEqual(lat_lon1.get_lon_in_radians(), radians(lat_lon1.get_lon()))
예제 #9
0
    def test_move(self):
        lat_lon1 = LatLon.from_deg_min_sec(('N0 0. 0.00.', 'W121 22. 49.59.'))
        lat_lon2 = LatLon.from_deg_min_sec(('N1 47. 58.87.', 'W121 22. 49.59.'))
        
        lat_lon1.move(200000, 0)
        
        # epsilon is 0.11 so we take 0.2 (20cm)
        self.assertLess(lat_lon1.distance(lat_lon2), 0.2)
        
        # move back and forth
        lat_lon3 = LatLon.from_deg_min_sec(('N1 47. 58.87.', 'W121 22. 49.59.'))
        
        lat_lon2.move(123456, 0)
        self.assertAlmostEqual(lat_lon2.distance(lat_lon3), 123456, places=10)
        self.assertAlmostEqual(lat_lon3.distance(lat_lon2), 123456, places=10)

        lat_lon2.move(123456, 180)
        self.assertAlmostEqual(lat_lon3.distance(lat_lon2), 0, places=10)
        self.assertAlmostEqual(lat_lon2.distance(lat_lon3), 0, places=10)
예제 #10
0
    def test_move(self):
        lat_lon1 = LatLon.from_deg_min_sec(('N0 0. 0.00.', 'W121 22. 49.59.'))
        lat_lon2 = LatLon.from_deg_min_sec(
            ('N1 47. 58.87.', 'W121 22. 49.59.'))

        lat_lon1.move(200000, 0)

        # epsilon is 0.11 so we take 0.2 (20cm)
        self.assertLess(lat_lon1.distance(lat_lon2), 0.2)

        # move back and forth
        lat_lon3 = LatLon.from_deg_min_sec(
            ('N1 47. 58.87.', 'W121 22. 49.59.'))

        lat_lon2.move(123456, 0)
        self.assertAlmostEqual(lat_lon2.distance(lat_lon3), 123456, places=10)
        self.assertAlmostEqual(lat_lon3.distance(lat_lon2), 123456, places=10)

        lat_lon2.move(123456, 180)
        self.assertAlmostEqual(lat_lon3.distance(lat_lon2), 0, places=10)
        self.assertAlmostEqual(lat_lon2.distance(lat_lon3), 0, places=10)
예제 #11
0
    def test_lat_lon_from_deg_min_sec(self):
        lat_lon1 = LatLon.from_deg_min_sec(
            ('N37 36. 26.00.', 'W122 22. 49.59.'))

        self.assertTrue(lat_lon1 is not None)
        self.assertAlmostEqual(lat_lon1.get_lat(), 37.607222, places=5)
        self.assertAlmostEqual(lat_lon1.get_lon(),
                               -122.38044166666666,
                               places=10)

        self.assertEqual(lat_lon1.get_lat_in_radians(),
                         radians(lat_lon1.get_lat()))
        self.assertEqual(lat_lon1.get_lon_in_radians(),
                         radians(lat_lon1.get_lon()))
def pos_callback(data):
    lat_lon = LatLon.from_simconnect_data_latlonalt(data['STRUCT LATLONALT'])
    print('LatLon: %s' % lat_lon)
예제 #13
0
 def test_distance(self):
     lat_lon1 = LatLon.from_deg_min_sec(('N0 0. 0.00.', 'W121 22. 49.59.'))
     lat_lon2 = LatLon.from_deg_min_sec(('N1 0. 0.00.', 'W122 22. 49.59.'))
      
     self.assertAlmostEqual(lat_lon1.distance(lat_lon2), 157158.34911586, places=7)
예제 #14
0
 def test_lat_lon_eq(self):
     lat_lon1 = LatLon.from_deg_min_sec(('N37 36. 26.00.', 'W122 22. 49.59.'))
     lat_lon2 = LatLon.from_deg_min_sec(('N37 36. 26.00.', 'E122 22. 49.59.'))
       
     self.assertEqual(lat_lon1, lat_lon1)
     self.assertNotEqual(lat_lon1, lat_lon2)
예제 #15
0
def pos_callback(data):
    lat_lon = LatLon.from_simconnect_data_latlonalt(data['STRUCT LATLONALT'])
    print('LatLon: %s' % lat_lon)