Example #1
0
 def test_contains_pos(self):
     """Tests the inside obstacle method."""
     # Form the test obstacle
     obst = MovingObstacle()
     obst.sphere_radius = TESTDATA_MOVOBST_CONTAINSPOS_OBJ[2]
     # Run test points against obstacle
     test_data = [(TESTDATA_MOVOBST_CONTAINSPOS_INSIDE, True),
                  (TESTDATA_MOVOBST_CONTAINSPOS_OUTSIDE, False)]
     for (cur_data, cur_contains) in test_data:
         for (lat, lon, alt) in cur_data:
             gpos = GpsPosition()
             gpos.latitude = lat
             gpos.longitude = lon
             gpos.save()
             apos = AerialPosition()
             apos.gps_position = gpos
             apos.altitude_msl = alt
             self.assertEqual(
                 obst.contains_pos(TESTDATA_MOVOBST_CONTAINSPOS_OBJ[0],
                                   TESTDATA_MOVOBST_CONTAINSPOS_OBJ[1],
                                   TESTDATA_MOVOBST_CONTAINSPOS_OBJ[3],
                                   apos), cur_contains)
 def test_contains_pos(self):
     """Tests the inside obstacle method."""
     # Form the test obstacle
     obst = MovingObstacle()
     obst.sphere_radius = TESTDATA_MOVOBST_CONTAINSPOS_OBJ[2]
     # Run test points against obstacle
     test_data = [
         (TESTDATA_MOVOBST_CONTAINSPOS_INSIDE, True),
         (TESTDATA_MOVOBST_CONTAINSPOS_OUTSIDE, False)
     ]
     for (cur_data, cur_contains) in test_data:
         for (lat, lon, alt) in cur_data:
             gpos = GpsPosition()
             gpos.latitude = lat
             gpos.longitude = lon
             gpos.save()
             apos = AerialPosition()
             apos.gps_position = gpos
             apos.altitude_msl = alt
             self.assertEqual(
                 obst.contains_pos(TESTDATA_MOVOBST_CONTAINSPOS_OBJ[0],
                                   TESTDATA_MOVOBST_CONTAINSPOS_OBJ[1],
                                   TESTDATA_MOVOBST_CONTAINSPOS_OBJ[3],
                                   apos), cur_contains)