Ejemplo n.º 1
0
def notifications():
    di = Distance()
    lat = curr_df.loc[0]["Lat"]
    long = curr_df.loc[0]["Long"]
    spd = curr_df.loc[0]["Spd"]
    angle = curr_df.loc[0]["Angle"]
    alt = curr_df.loc[0]["Alt"]
    for i in range(0, len(alert_df)):
        alat = alert_df.loc[i]["Lat"]
        along = alert_df.loc[i]["Long"]
        aSpeed = alert_df.loc[i]["Spd"]
        aAngle = alert_df.loc[i]["Angle"]
        aAlt = alert_df.loc[i]["Alt"]
        d = di.getDistFeet(lat, long, alat, along)
        counter = 0
        prevMainPlane = [lat, long]
        prevAlertPlane = [alat, along]
        newMainPlane = []
        newAlertPlane = []
        prevDistance = d
        newDistance = 0
        altDiff = di.heightDist(alt, aAlt)
        c = Coordinates()
        diverging_flg = 0
        min_dist_flg = 0
        bad_alt_flg = 0
        msg = ''
        if (altDiff > 1000):
            msg = "Altitude difference (" + str(altDiff) + "ft) in safe zone, no current possibility of collision."
            bad_alt_flg = 1

        else:
            while (1):
                newMainPlane = c.get_next_point(spd, angle, prevMainPlane[0], prevMainPlane[1])
                newAlertPlane = c.get_next_point(aSpeed, aAngle, prevAlertPlane[0], prevAlertPlane[1])
                newDistance = di.getDistFeet(newMainPlane[0], newMainPlane[1], newAlertPlane[0], newAlertPlane[1])
                print(newDistance)
                counter += 1
                if (newDistance > prevDistance):
                    diverging_flg = 1
                    break;
                elif (newDistance < 9260):
                    min_dist_flg = 1
                    break;
                else:
                    prevMainPlane = newMainPlane
                    prevAlertPlane = newAlertPlane

            if (diverging_flg):
                msg = "Flight path not intersecting. No possibility of collision."
            elif (min_dist_flg):
                msg = "Altitude in bad zone (" + str(altDiff) + "ft),  flight paths intersect in " + str(counter) + "mins."
            elif(bad_alt_flg):
                msg="Altitude difference (" + str(altDiff) + "ft) in safe zone, no current possibility of collision."
        alert_df['Warning'] = msg
    current=curr_df.to_dict(orient='records')
    alerts=alert_df.to_dict(orient='records')
    global selected_Icao
    return render_template('notifications.html',current=current,alerts=alerts,selected_Icao=selected_Icao)
alt=curr_df.loc[0]["Alt"]
for i in range(0,len(alert_df)):
     alat = alert_df.loc[i]["Lat"]
     along = alert_df.loc[i]["Long"]
     aSpeed= alert_df.loc[i]["Spd"]
     aAngle=alert_df.loc[i]["Angle"]
     aAlt=alert_df.loc[i]["Alt"]
     d=di.getDistFeet(lat,long,alat,along)
     counter=0
     prevMainPlane=[lat,long]
     prevAlertPlane=[alat,along]
     newMainPlane=[]
     newAlertPlane=[]
     prevDistance=d
     newDistance=0
     altDiff=di.heightDist(alt, aAlt)
     c=Coordinates()
     diverging_flg = 0
     min_dist_flg = 0
     bad_alt_flg = 0
     msg=''
     if((altDiff)>1000):
          msg="Altitude difference ("+str(altDiff)+"ft) in safe zone, no current possibility of collision."
          bad_alt_flg=1
          continue
     else:
          while(1):
               newMainPlane = c.get_next_point(spd,angle,prevMainPlane[0],prevMainPlane[1])
               newAlertPlane= c.get_next_point(aSpeed,aAngle,prevAlertPlane[0],prevAlertPlane[1])
               newDistance = di.getDistFeet(newMainPlane[0],newMainPlane[1],newAlertPlane[0],newAlertPlane[1])
               print(newDistance)