コード例 #1
0
 def test_get_waypoint_travel_time(self):
     """Tests travel time calc."""
     test_spds = [1, 10, 100, 500]
     for (lon2, lat2, lon1, lat1, dist_km) in TESTDATA_COMPETITION_DIST:
         dist_ft = units.kilometers_to_feet(dist_km)
         for speed in test_spds:
             speed_fps = units.knots_to_feet_per_second(speed)
             time = dist_ft / speed_fps
             gpos1 = GpsPosition()
             gpos1.latitude = lat1
             gpos1.longitude = lon1
             gpos1.save()
             apos1 = AerialPosition()
             apos1.gps_position = gpos1
             apos1.altitude_msl = 0
             apos1.save()
             wpt1 = Waypoint()
             wpt1.position = apos1
             gpos2 = GpsPosition()
             gpos2.latitude = lat2
             gpos2.longitude = lon2
             gpos2.save()
             apos2 = AerialPosition()
             apos2.gps_position = gpos2
             apos2.altitude_msl = 0
             apos2.save()
             wpt2 = Waypoint()
             wpt2.position = apos2
             waypoints = [wpt1, wpt2]
             obstacle = MovingObstacle()
             obstacle.speed_avg = speed
             self.assertTrue(self.eval_travel_time(
                 obstacle.get_waypoint_travel_time(waypoints, 0, 1), time))
コード例 #2
0
 def test_get_waypoint_travel_time(self):
     """Tests travel time calc."""
     test_spds = [1, 10, 100, 500]
     for (lon2, lat2, lon1, lat1, dist_km) in TESTDATA_COMPETITION_DIST:
         dist_ft = units.kilometers_to_feet(dist_km)
         for speed in test_spds:
             speed_fps = units.knots_to_feet_per_second(speed)
             time = dist_ft / speed_fps
             gpos1 = GpsPosition()
             gpos1.latitude = lat1
             gpos1.longitude = lon1
             gpos1.save()
             apos1 = AerialPosition()
             apos1.gps_position = gpos1
             apos1.altitude_msl = 0
             apos1.save()
             wpt1 = Waypoint()
             wpt1.position = apos1
             gpos2 = GpsPosition()
             gpos2.latitude = lat2
             gpos2.longitude = lon2
             gpos2.save()
             apos2 = AerialPosition()
             apos2.gps_position = gpos2
             apos2.altitude_msl = 0
             apos2.save()
             wpt2 = Waypoint()
             wpt2.position = apos2
             waypoints = [wpt1, wpt2]
             obstacle = MovingObstacle()
             obstacle.speed_avg = speed
             self.assertTrue(
                 self.eval_travel_time(
                     obstacle.get_waypoint_travel_time(waypoints, 0, 1),
                     time))
コード例 #3
0
ファイル: units_test.py プロジェクト: RAER1/interop
 def test_km_to_ft(self):
     """Performs a data-driven test of the conversion."""
     cases = [
         # (km, ft_actual)
         (  0,        0),
         (  1,     3280.84),
         (  1.5,   4921.26),
         (100,   328084),
     ]  # yapf: disable
     for (km, ft_actual) in cases:
         self.assertAlmostEqual(ft_actual,
                                units.kilometers_to_feet(km),
                                delta=5)
コード例 #4
0
ファイル: units_test.py プロジェクト: APTRG/interop
 def test_km_to_ft(self):
     """Performs a data-driven test of the conversion."""
     cases = [
         # (km, ft_actual)
         (  0,        0),
         (  1,     3280.84),
         (  1.5,   4921.26),
         (100,   328084),
     ]  # yapf: disable
     for (km, ft_actual) in cases:
         self.assertAlmostEqual(ft_actual,
                                units.kilometers_to_feet(km),
                                delta=5)
コード例 #5
0
    def test_km_to_ft(self):
        """Performs a data-driven test of the conversion."""
        threshold = 5  # ft

        cases = [
            # (km, ft_actual)
            (0,    0),
            (1,    3280.84),
            (1.5,  4921.26),
            (100,  328084),
        ]  # yapf: disable

        for (km, ft_actual) in cases:
            self.assertLess(
                abs(units.kilometers_to_feet(km) - ft_actual), threshold)
コード例 #6
0
ファイル: distance.py プロジェクト: sedflix/interop
def distance_to(latitude_1, longitude_1, altitude_1, latitude_2, longitude_2,
                altitude_2):
    """Get the distance in feet between the two positions.

    Args:
        latitude_1: The latitude of the first position.
        longitude_1: The longitude of the first position.
        altitude_1: The altitude in feet of the first position.
        latitude_2: The latitude of the second position.
        longitude_2: The longitude of the second position.
        altitude_2: The altitude in feet of the second position.
    """
    gps_dist_km = haversine(longitude_1, latitude_1, longitude_2, latitude_2)
    gps_dist_ft = units.kilometers_to_feet(gps_dist_km)
    alt_dist_ft = abs(altitude_1 - altitude_2)
    return math.hypot(gps_dist_ft, alt_dist_ft)
コード例 #7
0
ファイル: distance.py プロジェクト: APTRG/interop
def distance_to(latitude_1, longitude_1, altitude_1, latitude_2, longitude_2,
                altitude_2):
    """Get the distance in feet between the two positions.

    Args:
        latitude_1: The latitude of the first position.
        longitude_1: The longitude of the first position.
        altitude_1: The altitude in feet of the first position.
        latitude_2: The latitude of the second position.
        longitude_2: The longitude of the second position.
        altitude_2: The altitude in feet of the second position.
    """
    gps_dist_km = haversine(longitude_1, latitude_1, longitude_2, latitude_2)
    gps_dist_ft = units.kilometers_to_feet(gps_dist_km)
    alt_dist_ft = abs(altitude_1 - altitude_2)
    return math.hypot(gps_dist_ft, alt_dist_ft)