def get(self, request): kml = Kml(name='AUVSI SUAS LIVE Flight Data') kml_mission = kml.newfolder(name='Missions') (mission, err) = active_mission() if err: return err MissionConfig.kml_all(kml_mission, [mission]) kml_flyzone = kml.newfolder(name='Fly Zones') FlyZone.kml_all(kml_flyzone) parameters = '?sessionid={}'.format(request.COOKIES['sessionid']) uri = request.build_absolute_uri( '/auvsi_admin/update.kml') + parameters netlink = kml.newnetworklink(name="Live Data") netlink.link.href = uri netlink.link.refreshmode = RefreshMode.oninterval netlink.link.refreshinterval = 0.5 response = HttpResponse(kml.kml()) response['Content-Type'] = 'application/vnd.google-earth.kml+xml' response['Content-Disposition'] = 'attachment; filename=live.kml' response['Content-Length'] = str(len(response.content)) return response
def test_toKML(self): """Test Generation of kml for all mission data""" kml = Kml() MissionConfig.kml_all(kml=kml) data = kml.kml() names = [ 'Off Axis', 'Home Position', 'Air Drop', 'Emergent LKP', 'Search Area', 'Waypoints', ] for name in names: tag = '<name>{}</name>'.format(name) err = 'tag "{}" not found in {}'.format(tag, data) self.assertIn(tag, data, err)
def get(self, request): kml = Kml(name='AUVSI SUAS Flight Data') kml_teams = kml.newfolder(name='Teams') kml_mission = kml.newfolder(name='Missions') users = User.objects.all() for user in users: # Ignore admins if user.is_superuser: continue UasTelemetry.kml(user=user, logs=UasTelemetry.by_user(user), kml=kml_teams, kml_doc=kml.document) MissionConfig.kml_all(kml_mission, kml.document) response = HttpResponse(kml.kml()) response['Content-Type'] = 'application/vnd.google-earth.kml+xml' response['Content-Disposition'] = 'attachment; filename=mission.kml' response['Content-Length'] = str(len(response.content)) return response
def get(self, request): kml = Kml(name='AUVSI SUAS Flight Data') kml_teams = kml.newfolder(name='Teams') kml_mission = kml.newfolder(name='Missions') users = User.objects.all() for user in users: # Ignore admins if user.is_superuser: continue UasTelemetry.kml(user=user, logs=UasTelemetry.by_user(user), kml=kml_teams, kml_doc=kml.document) MissionConfig.kml_all(kml_mission) kml_flyzone = kml.newfolder(name='Fly Zones') FlyZone.kml_all(kml_flyzone) response = HttpResponse(kml.kml()) response['Content-Type'] = 'application/vnd.google-earth.kml+xml' response['Content-Disposition'] = 'attachment; filename=mission.kml' response['Content-Length'] = str(len(response.content)) return response