Пример #1
0
def parse_apt_line(line):
    "Parse a single line in the APT file"
    record_type = line[:3]
    r = parse_line(line, APT_RECORD_MAP[record_type])
    # Parse out useful coordinates
    if (record_type == 'APT'):
        r['lat'] = convert_dashed_dms_to_float(r['point_latitude_formatted'])
        r['lon'] = convert_dashed_dms_to_float(r['point_longitude_formatted'])
        r['control_tower'] = convert_boolean(r['control_tower'])
    if (record_type == 'RWY'):
        if r.get('base_end_latitude_physical_runway_end_formatted', False):
            r['base_end_lat'] = convert_dashed_dms_to_float(r['base_end_latitude_physical_runway_end_formatted'])
        if r.get('base_end_longitude_physical_runway_end_formatted', False):
            r['base_end_lon'] = convert_dashed_dms_to_float(r['base_end_longitude_physical_runway_end_formatted'])
        if r.get('base_end_latitude_displaced_threshold_formatted', False):
            r['base_end_displaced_threshold_lat'] = convert_dashed_dms_to_float(r['base_end_latitude_displaced_threshold_formatted'])
        if r.get('base_end_longitude_displaced_threshold_formatted', False):
            r['base_end_displaced_threshold_lon'] = convert_dashed_dms_to_float(r['base_end_longitude_displaced_threshold_formatted'])
        if r.get('reciprocal_end_latitude_physical_runway_end_formatted', False):
            r['reciprocal_end_lat'] = convert_dashed_dms_to_float(r['reciprocal_end_latitude_physical_runway_end_formatted'])
        if r.get('reciprocal_end_longitude_physical_runway_end_formatted', False):
            r['reciprocal_end_lon'] = convert_dashed_dms_to_float(r['reciprocal_end_longitude_physical_runway_end_formatted'])
        if r.get('reciprocal_end_latitude_physical_runway_end_formatted', False):
            r['reciprocal_end_displaced_threshold_lat'] = convert_dashed_dms_to_float(r['reciprocal_end_latitude_physical_runway_end_formatted'])
        if r.get('reciprocal_end_longitude_physical_runway_end_formatted', False):
            r['reciprocal_end_displaced_threshold_lon'] = convert_dashed_dms_to_float(r['reciprocal_end_longitude_physical_runway_end_formatted'])
    return r
Пример #2
0
def parse_awos_line(line):
    "Parse a single line in the AWOS file"
    r = parse_line(line, AWOS_RECORDS)
    # Parse out useful coordinates
    if r['record_type'] == 'AWOS1':  # only if it's a record type 1
        if r['latitude']:
            r['lat'] = convert_dashed_dms_to_float(r['latitude'])
        if r['longitude']:
            r['lon'] = convert_dashed_dms_to_float(r['longitude'])
    return r