Exemple #1
0
def verify_and_import_track(result: FlightResult, track, task, print=print):
    from airspace import AirspaceCheck
    from pilot.flightresult import save_track

    if task.airspace_check:
        airspace = AirspaceCheck.from_task(task)
    else:
        airspace = None
    '''check flight against task'''
    result.check_flight(track.flight, task, airspace_obj=airspace, print=print)
    '''create map file'''
    result.save_tracklog_map_file(task, track.flight)
    '''save to database'''
    save_track(result, task.id)
    if result.notifications:
        print(str(result.notifications))
    print('***************END****************')
    return result
Exemple #2
0
def dump_flight(track, task):
    # TODO check if file already exists otherwise create and save it
    from pilot.flightresult import FlightResult
    from mapUtils import get_bbox
    lib = task.formula.get_lib()
    task_result = FlightResult.check_flight(track.flight, task)  # check flight against task
    geojson_file = task_result.to_geojson_result(track, task)
    bbox = get_bbox(track.flight)
    return geojson_file, bbox
def test_track_flight_check():
    test_track = Track.read_file('/app/tests/data/test_igc_2.igc', par_id=1)
    test_result = FlightResult()
    test_result.check_flight(flight=test_track.flight, task=test_task)
    assert int(test_result.distance_flown) == 64360
    assert test_result.best_waypoint_achieved == 'Goal'
    assert len(test_result.waypoints_achieved) == test_result.waypoints_made
    assert test_result.SSS_time == 41400
    assert test_result.ESS_time == 50555
    assert test_result.ESS_altitude == 880.0
    assert test_result.real_start_time == 41428
    assert test_result.flight_time == 12183.0
    achieved = test_result.waypoints_achieved[1]
    assert achieved.name == 'TP01'
    assert achieved.rawtime == 43947
    assert achieved.altitude == 1445.0
    assert math.isclose(float(achieved.lat), 45.8145667,
                        abs_tol=0.0000001)  # ~0.01 meters
    assert math.isclose(float(achieved.lon), 9.7707167,
                        abs_tol=0.0000001)  # ~0.01 meters