Skip to content

Commit

Permalink
Write each flight's start/end events when combining igcs
Browse files Browse the repository at this point in the history
  • Loading branch information
mrschick committed Dec 10, 2021
1 parent 0728073 commit d735026
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion combine-igcs/combine-igcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def buildAircraft(igcs, refTime): # builds the main data dict of aircraft, with
ac[1000+i] = {
"header": fnc.getFlightHeader(igcPath),
"firstfix": fixKeys[0],
"beflastfix": fixKeys[-2],
"lastfix": fixKeys[-1],
"fixes": fixes
}
Expand Down Expand Up @@ -154,10 +155,20 @@ def main():
rec = ""
for id in acs:
if i in acs[id]["fixes"]:
# if current time offset is first fix of aircraft, pass ACMI "flight start" event
if i == acs[id]["firstfix"]:
rec += "0,Event=Message|"+str(id)+"|flight started\n"

# pass aircraft's current position fix
fix = acs[id]["fixes"][i]
rec += str(id)+",T="+fix["lon"]+"|"+fix["lat"]+"|"+fix["alt"]+"\n"
if i == acs[id]["lastfix"]: # if current time offset is last fix of aircraft, pass ACMI object deletion line to record

# if current time offset is before-last / last fix of aircraft, pass "flight end" event and ACMI object deletion
if i == acs[id]["beflastfix"]:
rec += "0,Event=Message|"+str(id)+"|flight ended\n"
if i == acs[id]["lastfix"]:
rec += "-"+str(id)+"\n"

if rec != "":
acmi.write("#"+str(i)+"\n"+rec)
i += 1
Expand Down

0 comments on commit d735026

Please sign in to comment.