Exemplo n.º 1
0
def parse_seeyou_waypoints(lines):
    waypoint_list = WaypointList()

    first = True
    for line in lines:
        if first:
            first = False
            continue

        line = line.strip()
        if line == '' or line.startswith('*'):
            continue

        if line == '-----Related Tasks-----':
            break

        fields = []
        line = __CSVLine(line)
        while line.has_next():
            fields.append(line.next())

        if len(fields) < 6:
            continue

        wp = Waypoint()
        wp.lat = __parse_coordinate(fields[3])
        wp.lon = __parse_coordinate(fields[4])
        wp.altitude = __parse_altitude(fields[5])
        wp.name = fields[0].strip()

        waypoint_list.append(wp)

    return waypoint_list
Exemplo n.º 2
0
def create_seeyou_task(task, taskname = ''):

  taskline = []
  turnpoints = []
 
  if taskname == '':
    taskline.append('')
  else:
    taskline.append('"'+taskname+'"')

  taskline.append(set_task_options(task));
  
  for key, turnpoint in enumerate(task):
    if turnpoint.name == 'Free turnpoint':
      turnpoint.name = '{0:0=2d} '.format(key+1) + turnpoint.name
    
    if key == 0:
      point_type = 'start'
      taskline[0] += ',"'+turnpoint.name+'"'

    elif key == len(task)-1:
      point_type = 'finish'
      taskline[0] += ',"'+turnpoint.name+'"'

    else:
      if task.type == 'aat':
        point_type = 'area'
      else:
        point_type = 'turn'

    tp = Waypoint()
    tp.lon = float(turnpoint.lon)
    tp.lat = float(turnpoint.lat)
    #turnpoint.comment
    tp.altitude = float(turnpoint.altitude)
    
    
    tp.name = turnpoint.name
    
    taskline[0] += ',"'+turnpoint.name+'"'

    taskline.append(create_obsZone(turnpoint, key, point_type))
    turnpoints.append(__compose_line(tp))

  return 'name,code,country,lat,lon,elev,style,rwdir,rwlen,freq,desc\n' + \
         '\n'.join(turnpoints) + '\n' \
         '-----Related Tasks-----\n' + '\n'.join(taskline)
Exemplo n.º 3
0
def create_seeyou_task(task, taskname=''):

    taskline = []
    turnpoints = []

    if taskname == '':
        taskline.append('')
    else:
        taskline.append('"' + taskname + '"')

    taskline.append(set_task_options(task))

    for key, turnpoint in enumerate(task):
        if turnpoint.name == 'Free turnpoint':
            turnpoint.name = '{0:0=2d} '.format(key + 1) + turnpoint.name

        if key == 0:
            point_type = 'start'
            taskline[0] += ',"' + turnpoint.name + '"'

        elif key == len(task) - 1:
            point_type = 'finish'
            taskline[0] += ',"' + turnpoint.name + '"'

        else:
            if task.type == 'aat':
                point_type = 'area'
            else:
                point_type = 'turn'

        tp = Waypoint()
        tp.lon = float(turnpoint.lon)
        tp.lat = float(turnpoint.lat)
        # turnpoint.comment
        tp.altitude = float(turnpoint.altitude)

        tp.name = turnpoint.name

        taskline[0] += ',"' + turnpoint.name + '"'

        taskline.append(create_obsZone(turnpoint, key, point_type))
        turnpoints.append(__compose_line(tp))

    return 'name,code,country,lat,lon,elev,style,rwdir,rwlen,freq,desc\n' + \
           '\n'.join(turnpoints) + '\n' \
           '-----Related Tasks-----\n' + '\n'.join(taskline)
Exemplo n.º 4
0
def parse_winpilot_waypoints(lines):
    waypoint_list = WaypointList()

    for line in lines:
        line = line.strip()
        if line == '' or line.startswith('*'):
            continue

        fields = line.split(',')
        if len(fields) < 6:
            continue

        wp = Waypoint()
        wp.lat = __parse_coordinate(fields[1])
        wp.lon = __parse_coordinate(fields[2])
        wp.altitude = __parse_altitude(fields[3])
        wp.name = fields[5].strip()

        waypoint_list.append(wp)

    return waypoint_list
Exemplo n.º 5
0
def __parse_line(line, bounds = None):
    if line.startswith('$'): return None
    
    lat = line[45:52]
    lat_neg = lat.startswith('S')  
    lat = float(lat[1:3]) + float(lat[3:5]) / 60. + float(lat[5:7]) / 3600.
    if lat_neg: lat = -lat
    
    if bounds and (lat > bounds.top or lat < bounds.bottom): return None

    lon = line[52:60]
    lon_neg = lon.startswith('W')  
    lon = float(lon[1:4]) + float(lon[4:6]) / 60. + float(lon[6:8]) / 3600.
    if lon_neg: lon = -lon
    
    if bounds and (lon > bounds.right or lon < bounds.left): return None
    
    wp = Waypoint()
    wp.lat = lat
    wp.lon = lon

    elev = line[41:45].strip()
    if elev != '': wp.altitude = float(elev)
    else: wp.altitude = 0.0

    wp.short_name = line[:6]
    if wp.short_name.endswith('1'): wp.type = 'airport'
    elif wp.short_name.endswith('2'): wp.type = 'outlanding'
    
    wp.short_name = wp.short_name.strip()
    
    wp.name = line[7:41].strip()
    
    if 'GLD' in wp.name: wp.type = 'glider_site'
    if 'ULM' in wp.name: wp.type = 'ulm'
    
    pos = -1
    if '#' in wp.name: pos = wp.name.find('#')
    if '*' in wp.name: pos = wp.name.find('*')
        
    if pos > -1:        
        data = wp.name[pos + 1:]
        wp.name = wp.name[:pos].strip()
        
        icao = data[:4]
        if not icao.startswith('GLD') and not icao.startswith('ULM'): wp.icao = icao
        
        if data[4:5] == 'A': wp.surface = 'asphalt'
        elif data[4:5] == 'C': wp.surface = 'concrete'
        elif data[4:5] == 'L': wp.surface = 'loam'
        elif data[4:5] == 'S': wp.surface = 'sand'
        elif data[4:5] == 'Y': wp.surface = 'clay'
        elif data[4:5] == 'G': wp.surface = 'gras'
        elif data[4:5] == 'V': wp.surface = 'gravel'
        elif data[4:5] == 'D': wp.surface = 'dirt'

        runway_len = data[5:8].strip()
        if runway_len != '':
            wp.runway_len = int(runway_len) * 10
        
        runway_dir = data[8:10].strip()
        if runway_dir != '':
            wp.runway_dir = int(runway_dir) * 10
        
        freq = data[12:17].strip()
        if len(freq) == 5:
            if freq.endswith('2') or freq.endswith('7'): freq += '5'
            else: freq += '0'
            wp.freq = float(freq) / 1000.
    
    if wp.name.endswith('GLD'):
        wp.name = wp.name[:-3].strip()
    else:
        wp.name = wp.name.rstrip('!?1 ')
    
    if re.search('(^|\s)BERG($|\s)', wp.name): wp.type = 'mountain top'
    if re.search('(^|\s)COL($|\s)', wp.name): wp.type = 'mountain pass'
    if re.search('(^|\s)PASS($|\s)', wp.name): wp.type = 'mountain pass'
    if re.search('(^|\s)TOP($|\s)', wp.name): wp.type = 'mountain top'
    if re.search('(\s)A(\d){0,3}($|\s)', wp.name): wp.type = 'highway exit'
    if re.search('(\s)AB(\d){0,3}($|\s)', wp.name): wp.type = 'highway exit'
    if re.search('(\s)BAB(\d){0,3}($|\s)', wp.name): wp.type = 'highway exit'
    if re.search('(\s)(\w){0,3}XA(\d){0,3}($|\s)', wp.name): wp.type = 'highway cross'
    if re.search('(\s)(\w){0,3}YA(\d){0,3}($|\s)', wp.name): wp.type = 'highway junction'
    if re.search('(\s)STR($|\s)', wp.name): wp.type = 'road'
    if re.search('(\s)SX($|\s)', wp.name): wp.type = 'road cross'
    if re.search('(\s)SY($|\s)', wp.name): wp.type = 'road junction'
    if re.search('(\s)EX($|\s)', wp.name): wp.type = 'railway cross'
    if re.search('(\s)EY($|\s)', wp.name): wp.type = 'railway junction'
    if re.search('(\s)TR($|\s)', wp.name): wp.type = 'gas station'
    if re.search('(\s)BF($|\s)', wp.name): wp.type = 'railway station'
    if re.search('(\s)RS($|\s)', wp.name): wp.type = 'railway station'
    if re.search('(\s)BR($|\s)', wp.name): wp.type = 'bridge'
    if re.search('(\s)TV($|\s)', wp.name): wp.type = 'tower'
    if re.search('(\s)KW($|\s)', wp.name): wp.type = 'powerplant'
        
    wp.name = wp.name.title()
    
    while '  ' in wp.name:
        wp.name = wp.name.replace('  ', ' ')
        
    wp.country_code = line[60:62].strip();
    
    return wp
Exemplo n.º 6
0
def __parse_line(line, bounds=None):
    if line.startswith('$'):
        return None

    lat = line[45:52]
    lat_neg = lat.startswith('S')
    lat = float(lat[1:3]) + float(lat[3:5]) / 60. + float(lat[5:7]) / 3600.
    if lat_neg:
        lat = -lat

    if bounds and (lat > bounds.top or lat < bounds.bottom):
        return None

    lon = line[52:60]
    lon_neg = lon.startswith('W')
    lon = float(lon[1:4]) + float(lon[4:6]) / 60. + float(lon[6:8]) / 3600.
    if lon_neg:
        lon = -lon

    if bounds and (lon > bounds.right or lon < bounds.left):
        return None

    wp = Waypoint()
    wp.lat = lat
    wp.lon = lon

    elev = line[41:45].strip()
    if elev != '':
        wp.altitude = float(elev)
    else:
        wp.altitude = 0.0

    wp.short_name = line[:6]
    if wp.short_name.endswith('1'):
        wp.type = 'airport'
    elif wp.short_name.endswith('2'):
        wp.type = 'outlanding'

    wp.short_name = wp.short_name.strip()

    wp.name = line[7:41].strip()

    if 'GLD' in wp.name:
        wp.type = 'glider_site'
    if 'ULM' in wp.name:
        wp.type = 'ulm'

    pos = -1
    if '#' in wp.name:
        pos = wp.name.find('#')
    if '*' in wp.name:
        pos = wp.name.find('*')

    if pos > -1:
        data = wp.name[pos + 1:]
        wp.name = wp.name[:pos].strip()

        icao = data[:4]
        if not icao.startswith('GLD') and not icao.startswith('ULM'):
            wp.icao = icao

        if data[4:5] == 'A':
            wp.surface = 'asphalt'
        elif data[4:5] == 'C':
            wp.surface = 'concrete'
        elif data[4:5] == 'L':
            wp.surface = 'loam'
        elif data[4:5] == 'S':
            wp.surface = 'sand'
        elif data[4:5] == 'Y':
            wp.surface = 'clay'
        elif data[4:5] == 'G':
            wp.surface = 'gras'
        elif data[4:5] == 'V':
            wp.surface = 'gravel'
        elif data[4:5] == 'D':
            wp.surface = 'dirt'

        runway_len = data[5:8].strip()
        if runway_len != '':
            wp.runway_len = int(runway_len) * 10

        runway_dir = data[8:10].strip()
        if runway_dir != '':
            wp.runway_dir = int(runway_dir) * 10

        freq = data[12:17].strip()
        if len(freq) == 5:
            if freq.endswith('2') or freq.endswith('7'):
                freq += '5'
            else:
                freq += '0'
            wp.freq = float(freq) / 1000.

    if wp.name.endswith('GLD'):
        wp.name = wp.name[:-3].strip()
    else:
        wp.name = wp.name.rstrip('!?1 ')

    if re.search('(^|\s)BERG($|\s)', wp.name):
        wp.type = 'mountain top'
    if re.search('(^|\s)COL($|\s)', wp.name):
        wp.type = 'mountain pass'
    if re.search('(^|\s)PASS($|\s)', wp.name):
        wp.type = 'mountain pass'
    if re.search('(^|\s)TOP($|\s)', wp.name):
        wp.type = 'mountain top'
    if re.search('(\s)A(\d){0,3}($|\s)', wp.name):
        wp.type = 'highway exit'
    if re.search('(\s)AB(\d){0,3}($|\s)', wp.name):
        wp.type = 'highway exit'
    if re.search('(\s)BAB(\d){0,3}($|\s)', wp.name):
        wp.type = 'highway exit'
    if re.search('(\s)(\w){0,3}XA(\d){0,3}($|\s)', wp.name):
        wp.type = 'highway cross'
    if re.search('(\s)(\w){0,3}YA(\d){0,3}($|\s)', wp.name):
        wp.type = 'highway junction'
    if re.search('(\s)STR($|\s)', wp.name):
        wp.type = 'road'
    if re.search('(\s)SX($|\s)', wp.name):
        wp.type = 'road cross'
    if re.search('(\s)SY($|\s)', wp.name):
        wp.type = 'road junction'
    if re.search('(\s)EX($|\s)', wp.name):
        wp.type = 'railway cross'
    if re.search('(\s)EY($|\s)', wp.name):
        wp.type = 'railway junction'
    if re.search('(\s)TR($|\s)', wp.name):
        wp.type = 'gas station'
    if re.search('(\s)BF($|\s)', wp.name):
        wp.type = 'railway station'
    if re.search('(\s)RS($|\s)', wp.name):
        wp.type = 'railway station'
    if re.search('(\s)BR($|\s)', wp.name):
        wp.type = 'bridge'
    if re.search('(\s)TV($|\s)', wp.name):
        wp.type = 'tower'
    if re.search('(\s)KW($|\s)', wp.name):
        wp.type = 'powerplant'

    wp.name = wp.name.title()

    while '  ' in wp.name:
        wp.name = wp.name.replace('  ', ' ')

    wp.country_code = line[60:62].strip()

    return wp