def importwp(db, csv_file, projection): reader = csv.reader(csv_file, delimiter='\t') header = reader.next() for fields in reader: wp = dict(zip(header, fields)) lat = math.radians(float(wp['Latitude [degrees]']) + float(wp['Latitude [decimal minutes]']) / 60) lon = math.radians(float(wp['Longitude [degrees]']) + float(wp['Longitude [decimal minutes]']) / 60) if wp['East/West'] == 'W': lon = -lon x, y = projection.forward(lat, lon) control_p = wp['Control P'] if set(control_p).intersection("ADHLYyZz"): landable_flag = 1 else: landable_flag = 0 db.insert_waypoint(wp['Name'], wp['ID'], int(x), int(y), lat, lon , int(int(wp['Elevation [Feet]']) * FT_TO_M), wp['Turnpoint'], wp['Comments'])
def import_turnpoints(db, csv_file, projection): reader = csv.reader(csv_file, delimiter='\t') header = reader.next() for fields in reader: wp = dict(zip(header, fields)) lat = float(wp['Latitude [degrees]']) +\ float(wp['Latitude [decimal minutes]']) / 60 lon = float(wp['Longitude [degrees]']) +\ float(wp['Longitude [decimal minutes]']) / 60 if wp['East/West'] == 'W': lon = -lon x, y = projection.forward(math.radians(lat), math.radians(lon)) control_p = wp['Control P'] if set(control_p).intersection("ADHLYyZz"): db.insert_landable(wp['Name'], wp['ID'], int(x), int(y), int(int(wp['Elevation [Feet]']) * FT_TO_M))
def import_landables(db, landouts_file, projection): for landout in yaml.load(landouts_file): lat_str = landout['latitude'] lon_str = landout['longitude'] if '.' in lat_str: lat = int(lat_str[:2]) + float(lat_str[3:]) / 60 else: lat = (int(lat_str[:2]) + int(lat_str[3:5]) / 60.0 + int(lat_str[5:7]) / 3600.0) if '.' in lon_str: lon = int(lon_str[:3]) + float(lon_str[4:]) / 60 else: lon = (int(lon_str[:3]) + int(lon_str[4:6]) / 60.0 + int(lon_str[6:8]) / 3600.0) if lon_str[3] == 'W': lon = -lon x, y = projection.forward(math.radians(lat), math.radians(lon)) db.insert_landable(landout['name'], landout['id'], int(x), int(y), int(landout['elevation'] * FT_TO_M))