Example #1
0
def get_fir_crossing(latlon1,latlon2):
    """
    Returns tuple of: 
     * airspace-dict
     * latlon of crossing
    """
    px1,py1=mapper.latlon2merc(latlon1,13)
    px2,py2=mapper.latlon2merc(latlon2,13)
    bb0=BoundingBox(min(px1,px2),min(py1,py2),max(px1,px2),max(py1,py2))
    line=Line(Vertex(int(px1),int(py1)),Vertex(int(px2),int(py2)))
    for poly,space in cache.get_firs_in_bb(bb0):
        a=poly.is_inside(Vertex(int(px1),int(py1)))
        b=poly.is_inside(Vertex(int(px2),int(py2)))
        print "Considering space %s, starting: %s, ending: %s"%(
                space['name'],a,b)
        
        if b and not a: 
            cross=list(poly.first_entrance(line))
            if cross:
                outlatlon=(cross[0].get_x(),cross[0].get_y())
                return space,mapper.merc2latlon(outlatlon,13)
    return None
Example #2
0
def get_firs(latlon):
    px1,py1=mapper.latlon2merc(latlon,13)
    bb0=BoundingBox(px1,py1,px1,py1)
    for poly,space in cache.get_firs_in_bb(bb0):
        if poly.is_inside(Vertex(int(px1),int(py1))):
            yield space