当前位置: 首页>>代码示例>>Python>>正文


Python gps_position.GpsPosition类代码示例

本文整理汇总了Python中auvsi_suas.models.gps_position.GpsPosition的典型用法代码示例。如果您正苦于以下问题:Python GpsPosition类的具体用法?Python GpsPosition怎么用?Python GpsPosition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了GpsPosition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_put_one

    def test_put_one(self):
        """PUT update one field without affecting others."""
        l = GpsPosition(latitude=38, longitude=-76)
        l.save()

        t = Target(user=self.user,
                   target_type=TargetType.standard,
                   location=l,
                   orientation=Orientation.s,
                   shape=Shape.square,
                   background_color=Color.white,
                   alphanumeric='ABC',
                   alphanumeric_color=Color.black,
                   description='Test target')
        t.save()

        data = {'shape': 'circle'}

        response = self.client.put(
            targets_id_url(args=[t.pk]),
            data=json.dumps(data))
        self.assertEqual(200, response.status_code)

        t.refresh_from_db()
        t.location.refresh_from_db()
        self.assertEqual(self.user, t.user)
        self.assertEqual(TargetType.standard, t.target_type)
        self.assertEqual(38, t.location.latitude)
        self.assertEqual(-76, t.location.longitude)
        self.assertEqual(Orientation.s, t.orientation)
        self.assertEqual(Shape.circle, t.shape)
        self.assertEqual(Color.white, t.background_color)
        self.assertEqual('ABC', t.alphanumeric)
        self.assertEqual(Color.black, t.alphanumeric_color)
        self.assertEqual('Test target', t.description)
开发者ID:legonigel,项目名称:interop,代码行数:35,代码来源:targets_test.py

示例2: create_uas_logs

    def create_uas_logs(self, user, entries):
        """Create a list of uas telemetry logs.

        Args:
            user: User to create logs for.
            entries: List of (lat, lon, alt) tuples for each entry.

        Returns:
            List of UasTelemetry objects
        """
        ret = []

        for (lat, lon, alt) in entries:
            pos = GpsPosition()
            pos.latitude = lat
            pos.longitude = lon
            pos.save()
            apos = AerialPosition()
            apos.altitude_msl = alt
            apos.gps_position = pos
            apos.save()
            log = UasTelemetry()
            log.user = user
            log.uas_position = apos
            log.uas_heading = 0
            log.save()
            ret.append(log)

        return ret
开发者ID:Dronolab,项目名称:interop,代码行数:29,代码来源:mission_config_test.py

示例3: test_get_waypoint_travel_time

 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))
开发者ID:legonigel,项目名称:interop,代码行数:33,代码来源:moving_obstacle_test.py

示例4: create_logs

    def create_logs(self,
                    user,
                    num=10,
                    start=None,
                    delta=None,
                    altitude=100,
                    heading=90):
        if start is None:
            start = timezone.now()
        if delta is None:
            delta = datetime.timedelta(seconds=1)

        logs = []

        for i in xrange(num):
            gps = GpsPosition(latitude=38 + 0.001 * i,
                              longitude=-78 + 0.001 * i)
            gps.save()

            pos = AerialPosition(gps_position=gps, altitude_msl=altitude)
            pos.save()

            log = UasTelemetry(user=user,
                               uas_position=pos,
                               uas_heading=heading)
            log.save()
            log.timestamp = start + i * delta
            log.save()
            logs.append(log)

        return logs
开发者ID:auvsi-suas,项目名称:interop,代码行数:31,代码来源:telemetry_test.py

示例5: setUp

 def setUp(self):
     """Creates test data."""
     # Form test set for contains position
     self.testdata_containspos = []
     for test_data in TESTDATA_FLYZONE_CONTAINSPOS:
         # Create the FlyZone
         zone = FlyZone()
         zone.altitude_msl_min = test_data['min_alt']
         zone.altitude_msl_max = test_data['max_alt']
         zone.save()
         for waypoint_id in range(len(test_data['waypoints'])):
             (lat, lon) = test_data['waypoints'][waypoint_id]
             gpos = GpsPosition()
             gpos.latitude = lat
             gpos.longitude = lon
             gpos.save()
             apos = AerialPosition()
             apos.gps_position = gpos
             apos.altitude_msl = 0
             apos.save()
             wpt = Waypoint()
             wpt.order = waypoint_id
             wpt.position = apos
             wpt.save()
             zone.boundary_pts.add(wpt)
         # Form test set
         test_pos = []
         for pos in test_data['inside_pos']:
             test_pos.append((pos, True))
         for pos in test_data['outside_pos']:
             test_pos.append((pos, False))
         # Store
         self.testdata_containspos.append((zone, test_pos))
开发者ID:auvsi-suas,项目名称:interop,代码行数:33,代码来源:fly_zone_test.py

示例6: create_moving_obstacle

    def create_moving_obstacle(self, waypoints):
        """Create a new MovingObstacle model.

        Args:
            waypoints: List of (lat, lon, alt) tuples

        Returns:
            Saved MovingObstacle
        """
        obstacle = MovingObstacle(speed_avg=40, sphere_radius=100)
        obstacle.save()

        for num, waypoint in enumerate(waypoints):
            (lat, lon, alt) = waypoint

            gps = GpsPosition(latitude=lat, longitude=lon)
            gps.save()

            pos = AerialPosition(gps_position=gps, altitude_msl=alt)
            pos.save()

            waypoint = Waypoint(order=num, position=pos)
            waypoint.save()

            obstacle.waypoints.add(waypoint)

        obstacle.save()
        return obstacle
开发者ID:auvsi-suas,项目名称:interop,代码行数:28,代码来源:obstacles_test.py

示例7: setUp

    def setUp(self):
        """Populates an active mission to test a cached view."""
        pos = GpsPosition()
        pos.latitude = 10
        pos.longitude = 10
        pos.save()
        self.pos = pos

        obst = StationaryObstacle()
        obst.gps_position = pos
        obst.cylinder_radius = 10
        obst.cylinder_height = 10
        obst.save()
        self.obst = obst

        config = MissionConfig()
        config.is_active = True
        config.home_pos = pos
        config.emergent_last_known_pos = pos
        config.off_axis_target_pos = pos
        config.air_drop_pos = pos
        config.save()
        self.config = config
        config.stationary_obstacles.add(obst)
        config.save()

        self.login_url = reverse('auvsi_suas:login')
        self.obst_url = reverse('auvsi_suas:obstacles')
        self.clear_cache_url = reverse('auvsi_suas:clear_cache')
开发者ID:auvsi-suas,项目名称:interop,代码行数:29,代码来源:clear_cache_test.py

示例8: test_duplicate_unequal

    def test_duplicate_unequal(self):
        """Tests the duplicate function for nonequal positions."""
        gps1 = GpsPosition(latitude=0, longitude=0)
        gps2 = GpsPosition(latitude=1, longitude=0)
        gps3 = GpsPosition(latitude=0, longitude=1)

        self.assertFalse(gps1.duplicate(gps2))
        self.assertFalse(gps1.duplicate(gps3))
开发者ID:auvsi-suas,项目名称:interop,代码行数:8,代码来源:gps_position_test.py

示例9: setUp

    def setUp(self):
        self.user = User.objects.create_user('testuser', '[email protected]',
                                             'testpass')
        self.user.save()

        # Create an active mission.
        pos = GpsPosition()
        pos.latitude = 10
        pos.longitude = 10
        pos.save()
        config = MissionConfig()
        config.is_active = True
        config.home_pos = pos
        config.emergent_last_known_pos = pos
        config.off_axis_target_pos = pos
        config.air_drop_pos = pos
        config.save()

        # Add a couple of stationary obstacles
        obst = self.create_stationary_obstacle(lat=38.142233,
                                               lon=-76.434082,
                                               radius=300,
                                               height=500)
        config.stationary_obstacles.add(obst)

        obst = self.create_stationary_obstacle(lat=38.442233,
                                               lon=-76.834082,
                                               radius=100,
                                               height=750)
        config.stationary_obstacles.add(obst)

        # And a couple of moving obstacles
        obst = self.create_moving_obstacle([
            # (lat,     lon,        alt)
            (38.142233, -76.434082, 300),
            (38.141878, -76.425198, 700),
        ])
        config.moving_obstacles.add(obst)

        obst = self.create_moving_obstacle([
            # (lat,     lon,        alt)
            (38.145405, -76.428310, 100),
            (38.146582, -76.424099, 200),
            (38.144662, -76.427634, 300),
            (38.147729, -76.419185, 200),
            (38.147573, -76.420832, 100),
            (38.148522, -76.419507, 750),
        ])
        config.moving_obstacles.add(obst)

        config.save()

        # Login
        response = self.client.post(login_url, {
            'username': 'testuser',
            'password': 'testpass'
        })
        self.assertEqual(200, response.status_code)
开发者ID:auvsi-suas,项目名称:interop,代码行数:58,代码来源:obstacles_test.py

示例10: test_unicode

 def test_unicode(self):
     """Tests the unicode method executes."""
     pos = GpsPosition(latitude=100, longitude=200)
     pos.save()
     obst = StationaryObstacle(gps_position=pos,
                               cylinder_radius=10,
                               cylinder_height=100)
     obst.save()
     self.assertTrue(obst.__unicode__())
开发者ID:auvsi-suas,项目名称:interop,代码行数:9,代码来源:stationary_obstacle_test.py

示例11: test_unicode

    def test_unicode(self):
        """Tests the unicode method executes."""
        gps = GpsPosition(latitude=10, longitude=100)
        gps.save()

        pos = AerialPosition(gps_position=gps, altitude_msl=100)
        pos.save()

        pos.__unicode__()
开发者ID:auvsi-suas,项目名称:interop,代码行数:9,代码来源:aerial_position_test.py

示例12: setUp

    def setUp(self):
        """Create the obstacles for testing."""
        # Obstacle with no waypoints
        obst_no_wpt = MovingObstacle()
        obst_no_wpt.speed_avg = 1
        obst_no_wpt.sphere_radius = 1
        obst_no_wpt.save()
        self.obst_no_wpt = obst_no_wpt

        # Obstacle with single waypoint
        self.single_wpt_lat = 40
        self.single_wpt_lon = 76
        self.single_wpt_alt = 100
        obst_single_wpt = MovingObstacle()
        obst_single_wpt.speed_avg = 1
        obst_single_wpt.sphere_radius = 1
        obst_single_wpt.save()
        single_gpos = GpsPosition()
        single_gpos.latitude = self.single_wpt_lat
        single_gpos.longitude = self.single_wpt_lon
        single_gpos.save()
        single_apos = AerialPosition()
        single_apos.gps_position = single_gpos
        single_apos.altitude_msl = self.single_wpt_alt
        single_apos.save()
        single_wpt = Waypoint()
        single_wpt.position = single_apos
        single_wpt.order = 1
        single_wpt.save()
        obst_single_wpt.waypoints.add(single_wpt)
        self.obst_single_wpt = obst_single_wpt

        # Obstacles with predefined path
        self.obstacles = []
        for path in TESTDATA_MOVOBST_PATHS:
            cur_obst = MovingObstacle()
            cur_obst.speed_avg = 68
            cur_obst.sphere_radius = 10
            cur_obst.save()
            for pt_id in range(len(path)):
                (lat, lon, alt) = path[pt_id]
                cur_gpos = GpsPosition()
                cur_gpos.latitude = lat
                cur_gpos.longitude = lon
                cur_gpos.save()
                cur_apos = AerialPosition()
                cur_apos.gps_position = cur_gpos
                cur_apos.altitude_msl = alt
                cur_apos.save()
                cur_wpt = Waypoint()
                cur_wpt.position = cur_apos
                cur_wpt.order = pt_id
                cur_wpt.save()
                cur_obst.waypoints.add(cur_wpt)
            cur_obst.save()
            self.obstacles.append(cur_obst)
开发者ID:legonigel,项目名称:interop,代码行数:56,代码来源:moving_obstacle_test.py

示例13: test_similar_classifications

    def test_similar_classifications(self):
        """Tests similar classification counts are computed correctly."""
        # Test equal standard targets.
        l = GpsPosition(latitude=38, longitude=-76)
        l.save()
        t1 = Target(user=self.user,
                    target_type=TargetType.standard,
                    location=l,
                    orientation=Orientation.s,
                    shape=Shape.square,
                    background_color=Color.white,
                    alphanumeric='ABC',
                    alphanumeric_color=Color.black,
                    description='Test target',
                    autonomous=True)
        t1.save()
        t2 = Target(user=self.user,
                    target_type=TargetType.standard,
                    location=l,
                    orientation=Orientation.s,
                    shape=Shape.square,
                    background_color=Color.white,
                    alphanumeric='ABC',
                    alphanumeric_color=Color.black,
                    description='Test other target',
                    autonomous=True)
        t2.save()
        self.assertAlmostEqual(1.0, t1.similar_classifications(t2))

        # Test unequal standard targets.
        t1.alphanumeric = 'DEF'
        t1.alphanumeric_color = Color.blue
        t1.save()
        self.assertAlmostEqual(3.0 / 5.0, t1.similar_classifications(t2))
        t1.shape = Shape.circle
        t1.background_color = Color.orange
        t1.save()
        self.assertAlmostEqual(1.0 / 5.0, t1.similar_classifications(t2))

        # Test different types.
        t1.target_type = TargetType.off_axis
        t1.save()
        self.assertAlmostEqual(0, t1.similar_classifications(t2))

        # Test off_axis is same as standard.
        t2.target_type = TargetType.off_axis
        t2.alphanumeric = 'DEF'
        t2.save()
        self.assertAlmostEqual(2.0 / 5.0, t1.similar_classifications(t2))

        # Test emergent type is always 1.
        t1.target_type = TargetType.emergent
        t1.save()
        t2.target_type = TargetType.emergent
        t2.save()
        self.assertAlmostEqual(1.0, t1.similar_classifications(t2))
开发者ID:auvsi-suas,项目名称:interop,代码行数:56,代码来源:target_test.py

示例14: create_log_element

 def create_log_element(self, lat, lon, alt, user, log_time):
     pos = GpsPosition(latitude=lat, longitude=lon)
     pos.save()
     apos = AerialPosition(gps_position=pos, altitude_msl=alt)
     apos.save()
     log = UasTelemetry(user=user, uas_position=apos, uas_heading=100, )
     log.save()
     log.timestamp = log_time
     log.save()
     return log
开发者ID:legonigel,项目名称:interop,代码行数:10,代码来源:moving_obstacle_test.py

示例15: create_log_element

 def create_log_element(self, timestamp, user, lat, lon, alt, heading):
     pos = GpsPosition(latitude=lat, longitude=lon)
     pos.save()
     apos = AerialPosition(gps_position=pos, altitude_msl=alt)
     apos.save()
     log = UasTelemetry(timestamp=timezone.now(),
                        user=user,
                        uas_position=apos,
                        uas_heading=heading)
     log.save()
     return log
开发者ID:legonigel,项目名称:interop,代码行数:11,代码来源:uas_telemetry_test.py


注:本文中的auvsi_suas.models.gps_position.GpsPosition类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。