def get_info_from_comment_lines(parsed_igc_file: dict, start_time_buffer: int = 0): lscsd_lines = list() lscsr_lines = list() lscsc_lines = list() for comment_record in parsed_igc_file['comment_records'][1]: line = 'L{}{}'.format(comment_record['source'], comment_record['comment']) if line.startswith('LSCSD'): lscsd_lines.append(line) elif line.startswith('LSCSC'): lscsc_lines.append(line) elif line.startswith('LSCSR'): lscsr_lines.append(line) task_information, competitor_information = get_task_and_competitor_info( lscsd_lines, lscsr_lines) waypoints = get_waypoints(lscsc_lines, task_information) aat = task_information['aat'] t_min = task_information.get('time_window', None) start_opening = task_information.get('gate_open', None) timezone = None # unclear where to get timezone information from strepla igc file if aat: task = AAT(waypoints, t_min, timezone, start_opening, start_time_buffer) else: task = RaceTask(waypoints, timezone, start_opening, start_time_buffer) return task, task_information, competitor_information
def test_race_reduced_legs(self): """ Race task with reduced legs, should produce correct distance https://www.soaringspot.com/en_gb/pribina-cup-2018-nitra-2018/results/15-meter/task-1-on-2018-04-02/daily """ lcu_lines = [ 'LCU::C020418195435301299000202', 'LCU::C0000000N00000000E', 'LCU::C4819183N01759550E158LEHOTA', 'LCU::C4907167N01819400E235PUCHOV', 'LCU::C4748117N01842983E271STUROVO', 'LCU::C4816767N01807967E001NITRA', 'LCU::C0000000N00000000E', ] lseeyou_lines = [ 'LSEEYOU OZ=-1,Style=2,SpeedStyle=0,R1=5000m,A1=180,Line=1', 'LSEEYOU OZ=0,Style=1,SpeedStyle=3,R1=500m,A1=180,Reduce=1', 'LSEEYOU OZ=1,Style=1,SpeedStyle=3,R1=500m,A1=180,Reduce=1', 'LSEEYOU OZ=2,Style=3,SpeedStyle=2,R1=3000m,A1=180,Reduce=1', ] waypoints = get_waypoints(lcu_lines, lseeyou_lines) race_task = RaceTask(waypoints) self.assertAlmostEqual(race_task.total_distance / 1000, 305.21, places=2)
def test_race_moved_leg(self): """ Race task with moved waypoint, should not crash. somehow distances are not completely equal. https://www.soaringspot.com/en_gb/35th-world-gliding-championships-hosin-2018/results/18-meter/task-1-on-2018-07-29/daily """ lcu_lines = [ 'LCU::C290718193533301299000203', 'LCU::C0000000N00000000E', 'LCU::C4908600N01432867E011SP07RADONICE', 'LCU::C4936150N01352917E477ROZMITAL', 'LCU::C4940950N01240067E442PRIMDA', 'LCU::C4915633N01308733E385NYRSKO', 'LCU::C4902383N01429650E001SP01HOSIN', 'LCU::C0000000N00000000E', ] lseeyou_lines = [ 'LSEEYOU OZ=-1,Style=2,SpeedStyle=0,R1=5000m,A1=180,Line=1', 'LSEEYOU OZ=0,Style=1,SpeedStyle=3,R1=500m,A1=180', 'LSEEYOU OZ=1,Style=1,SpeedStyle=3,R1=500m,A1=180', 'LSEEYOU OZ=2,Style=1,SpeedStyle=3,R1=500m,A1=180', 'LSEEYOU OZ=3,Style=3,SpeedStyle=2,R1=5000m,A1=180,Move=1', ] waypoints = get_waypoints(lcu_lines, lseeyou_lines) try: race_task = RaceTask(waypoints) except Exception: self.fail()
def get_info_from_comment_lines( parsed_igc_file: dict, start_time_buffer: int = 0) -> Tuple[Task, dict, dict]: """ There is specific contest information stored in the comment lines of the IGC files. This function extracts this information """ lcu_lines = list() lseeyou_lines = list() contest_information = dict() competitor_information = dict() comment_lines = get_comment_lines_from_parsed_file(parsed_igc_file) timezone = None t_min = None start_opening = None multi_start = False for line in comment_lines: if line.startswith('LCU::C'): lcu_lines.append(line) elif line.startswith('LSEEYOU OZ'): lseeyou_lines.append(line) elif line.startswith('LCU::HPGTYGLIDERTYPE:'): competitor_information['plane_model'] = line.split(':')[3] elif line.startswith('LCU::HPPLTPILOT:'): competitor_information['pilot_name'] = line.split(':')[3] elif line.startswith('LCU::HPCIDCOMPETITIONID:'): competitor_information['competition_id'] = line.split(':')[3] elif line.startswith('LCU::HPCCLCOMPETITIONCLASS:'): contest_information['competition_class'] = line.split(':')[3] elif line.startswith('LSEEYOU TSK'): start_opening, t_min, multi_start = get_task_rules(line) elif line.startswith('LCU::HPTZNTIMEZONE:'): timezone = int(line.split(':')[3]) if start_opening is not None: # convert start opening to UTC time start_opening = subtract_times(start_opening, datetime.time(hour=timezone)) waypoints = get_waypoints(lcu_lines, lseeyou_lines) if t_min is None: task = RaceTask(waypoints, timezone, start_opening, start_time_buffer, multi_start) else: task = AAT(waypoints, t_min, timezone, start_opening, start_time_buffer, multi_start) return task, contest_information, competitor_information
def test_not_equal_tasks(self): waypoints = self.race_task.waypoints # test_unequal number_waypoints waypoints2 = deepcopy(waypoints) del waypoints2[2] race_task2 = RaceTask(waypoints2) self.assertNotEqual(self.race_task, race_task2) # test different waypoint waypoints3 = deepcopy(waypoints) waypoints3[2].r_max = 1000 race_task2 = RaceTask(waypoints3) self.assertNotEqual(self.race_task, race_task2) # test different start_time race_task2 = RaceTask(waypoints, start_opening=datetime.time(0, 0, 0)) self.assertNotEqual(race_task2, self.race_task) # test different start buffer race_task2 = RaceTask(waypoints, start_time_buffer=5) self.assertNotEqual(self.race_task, race_task2)