def fi_parse_tma(): p = parse.Parser(r"/ais/eaip/pdf/enr/EF_ENR_2_1_EN.pdf", fixuphref, country='fi') res = [] atsres = [] for pagenr in xrange(4, p.get_num_pages()): parsed, atsparsed = parse_page(p, pagenr) #pagenr) res.extend(parsed) atsres.extend(atsparsed) #break print "Len ouf out ", len(res) atsout = [] for space in atsres: #print "bef cut:",space['points'] mypolys = [makepoly.poly(space['points'])] for tmaitem in res: if tmaitem['type'] != 'TMA': continue outmypolys = [] assert len(mypolys) >= 1 for mypoly in list(mypolys): tmapoly = makepoly.poly(tmaitem['points']) #print mypoly #print tmapoly shape = mypoly.subtract(tmapoly) newpolys = shape.get_polys() if len(newpolys) > 1: print "Length is:", len(newpolys) #print "Cutting" outmypolys.extend( [shapemerge2d.Polygon(x) for x in list(newpolys)]) #assert len(newpolys)==1 if len(outmypolys) > 1: print "outmypolys:", outmypolys #print "Cut to:",mypoly mypolys = outmypolys for mypoly in mypolys: t = [] for mx, my in [(v.get_x(), v.get_y()) for v in mypoly.get_vertices()]: t.append(mapper.to_str(mapper.merc2latlon((mx, my), 13))) #print "Aft cut:",t newspace = dict(space) newspace['points'] = t atsout.append(newspace) if len(mypolys) > 1: print "Space was split into ", len(mypolys), "parts" res.extend(atsout) res.append( dict(name="FINLAND FIR", icao="EFIN", floor='GND', ceiling='-', freqs=[], type='FIR', date=datetime(2011, 4, 9), points=mapper.parse_coord_str( """ 601130N 0190512E - 601803N 0190756E - 610000N 0191905E - 614000N 0193000E - 631000N 0201000E - 632830N 0204000E - 633700N 0213000E - 644100N 0225500E - 653148N 0240824E - Along the common X/Y state boundary to 690336N 0203255E - Along the common X/Y state boundary to 690307N 0285545E - Along the common X/Y state boundary to 601201N 0271735E - 600800N 0263300E - 595830N 0260642E - 595300N 0255200E - 595430N 0252000E - 595300N 0245100E - 590000N 0210000E - 591524N 0203239E - 593346N 0195859E - 601130N 0190512E """, context="finland"))) #for pa in res: # pretty(pa) return res
def fi_parse_tma(): p=parse.Parser(r"/ais/eaip/pdf/enr/EF_ENR_2_1_EN.pdf",fixuphref,country='fi') res=[] atsres=[] for pagenr in xrange(4,p.get_num_pages()): parsed,atsparsed=parse_page(p,pagenr)#pagenr) res.extend(parsed) atsres.extend(atsparsed) #break print "Len ouf out ",len(res) atsout=[] for space in atsres: #print "bef cut:",space['points'] mypolys=[makepoly.poly(space['points'])] for tmaitem in res: if tmaitem['type']!='TMA': continue outmypolys=[] assert len(mypolys)>=1 for mypoly in list(mypolys): tmapoly=makepoly.poly(tmaitem['points']) #print mypoly #print tmapoly shape=mypoly.subtract(tmapoly) newpolys=shape.get_polys() if len(newpolys)>1: print "Length is:", len(newpolys) #print "Cutting" outmypolys.extend([shapemerge2d.Polygon(x) for x in list(newpolys)]) #assert len(newpolys)==1 if len(outmypolys)>1: print "outmypolys:",outmypolys #print "Cut to:",mypoly mypolys=outmypolys for mypoly in mypolys: t=[] for mx,my in [(v.get_x(),v.get_y()) for v in mypoly.get_vertices()]: t.append(mapper.to_str(mapper.merc2latlon((mx,my),13))) #print "Aft cut:",t newspace=dict(space) newspace['points']=t atsout.append(newspace) if len(mypolys)>1: print "Space was split into ",len(mypolys),"parts" res.extend(atsout) res.append(dict( name="FINLAND FIR", icao="EFIN", floor='GND', ceiling='-', freqs=[], type='FIR', date=datetime(2011,4,9), points=mapper.parse_coord_str(""" 601130N 0190512E - 601803N 0190756E - 610000N 0191905E - 614000N 0193000E - 631000N 0201000E - 632830N 0204000E - 633700N 0213000E - 644100N 0225500E - 653148N 0240824E - Along the common X/Y state boundary to 690336N 0203255E - Along the common X/Y state boundary to 690307N 0285545E - Along the common X/Y state boundary to 601201N 0271735E - 600800N 0263300E - 595830N 0260642E - 595300N 0255200E - 595430N 0252000E - 595300N 0245100E - 590000N 0210000E - 591524N 0203239E - 593346N 0195859E - 601130N 0190512E """,context="finland"))) #for pa in res: # pretty(pa) return res
uprint( "Need to have predefine for route %s, with md5: %s" % (routename, sig)) uprint("Altitude, and points") raise Exception( 'Missing predef for route. Use: ("%s","%s") : ( 10,"FL 65","FL 95","""\n\n """),' % (routename, sig)) i1 = isol_routes() low1 = low_routes(i1) out.extend(list(get_airspaces(low1))) out2 = [] for space in out: mypoly = makepoly.poly[space['points']] for tmapoly in tmapolys: mypoly = shapemerge2d.shape_difference(mypoly, tmapoly) t = [] for mx, my in [(v.get_x(), v.get_y()) for v in mypoly.get_vertices()]: t.append(mapper.to_str(mapper.merc2latlon((mx, my), 13))) space['points'] = t return out2 if __name__ == '__main__': import fi_parse_tma for space in fi_parse_ats_rte( [makepoly.poly(x['points']) for x in fi_parse_tma.fi_parse_tma()]): uprint(space)
type="RNAV", points=[mapper.to_str(mapper.merc2latlon(x,13)) for x in outline]) else: uprint("Need to have predefine for route %s, with md5: %s"%(routename,sig)) uprint("Altitude, and points") raise Exception('Missing predef for route. Use: ("%s","%s") : ( 10,"FL 65","FL 95","""\n\n """),'%(routename,sig)) i1=isol_routes() low1=low_routes(i1) out.extend(list(get_airspaces(low1))) out2=[] for space in out: mypoly=makepoly.poly[space['points']] for tmapoly in tmapolys: mypoly=shapemerge2d.shape_difference(mypoly,tmapoly) t=[] for mx,my in [(v.get_x(),v.get_y()) for v in mypoly.get_vertices()]: t.append(mapper.to_str(mapper.merc2latlon((mx,my),13))) space['points']=t return out2 if __name__=='__main__': import fi_parse_tma for space in fi_parse_ats_rte([makepoly.poly(x['points']) for x in fi_parse_tma.fi_parse_tma()]): uprint(space)