What’s the best way to ask the question “what flight was nearest this lat/lon at time tx that has its origin or destination KXXX?”
I’m trying to use the FlightXML methods to cobble this together. The best I’ve come up with so far is to query the Departed and Enroute endpoints for the subject airport to get a list of potential flights, then call the GetLastTrack endpoint to get the tracks for each flight and parse them for timestamps near the time of interest.
It sort of works (occasionally it doesn’t find traffic that I know exists, but that’s another post) but I figured there has to be an easier, more direct way to answer that question.
If anyone here can suggest a different approach I’d love to hear it.
Cheers,
Chris
I believe your current approach is the only way to get the data you are looking for currently. If you were not looking into the past then SearchBirdseyeInFlight would probably be the best option (just pass a lat/lon box around your area of interest).
I considered using the SearchBirdseyeInFlight endpoint but the way the docs describe using the lat/lon box approach didn’t give me confidence it would work.
Specifically, the docs say the coordinates to query on are the “latitude/longitude of last reported position”. I wasn’t sure how real-time that would be, but I guess it makes sense to give it a shot.
Thanks!
There is a little bit of lag in terms of the position, but you should be able to compensate for that by enlarging your lat/lon box a bit or try again for some period of time after you first expect that plane to be overhead.
You could use SearchBirdseyePositions with the latlon box and it will return matches for any recent flight that had crossed into that box, not just the most recent position.
Okay, getting closer to a solution here. I see that both SearchBirdseye endpoints take a “clock” key. Can that be used to limit the results to a certain time period, say a 2 minute range?
Yes, you can use the “{range clock XXX YYYY}” operator to further restrict it to a specific timespan as well.
Be sure to keep your latlon boxes and time ranges fairly lenient, since it will match only positions that were observed inside of that criteria (ie: not a theoretical position interpolated between two real positions that both exist outside of your criteria).
Awesome, thanks, I’ll give that a go.
Getting closer to the solution but still not quite there.
This is a SearchBirdseyeInFlight query:
Query: {true inAir} {airline 1} {orig_or_dest {KSAN}} {range lat 32.79488750844458 32.939619291555424} {range lon -117.32710573309947 -117.15479166690054} {< alt 100}
=> #<InFlightAircraftStruct:0x007fcbddd1c1c0 @altitude=92, @altitudeChange="", @altitudeStatus="-", @departureTime=1498692060, @destination="KSAN", @faFlightID="SWA3893-1498454794-airline-0042", @firstPositionTime=1498692097, @groundspeed=453, @heading=145, @highLatitude=37.43225, @highLongitude=-117.28062, @ident="SWA3893", @latitude=32.8946, @longitude=-117.28062, @lowLatitude=32.8946, @lowLongitude=-121.96992, @origin="KSJC", @prefix="", @suffix="", @timeout="0", @timestamp=1498695089, @type="B737", @updateType="A", @waypoints="37.36 -121.93 37.36 -121.93 37.29 -121.85 37.29 -121.84 37.25 -121.78 37.21 -121.72 37.09 -121.53 37.06 -121.49 36.97 -121.39 36.92 -121.34 36.88 -121.29 36.78 -121.19 36.77 -121.17 36.71 -121.11 36.64 -121.03 36.61 -121.01 36.6 -121 36.51 -120.9 36.46 -120.86 36.42 -120.81 36.38 -120.77 36.32 -120.71 36.14 -120.53 35.91 -120.3 35.87 -120.26 35.77 -120.13 35.75 -120.11 35.65 -119.98 34.41 -118.93 34.36 -118.88 34.29 -118.81 34.16 -118.67 33.93 -118.43 33.89 -118.38 33.86 -118.34 33.85 -118.32 33.78 -118.23 33.68 -118.11 33.65 -118.06 33.55 -117.93 33.51 -117.89 33.49 -117.86 33.48 -117.85 33.44 -117.81 33.42 -117.78 33.35 -117.7 33.32 -117.66 33.29 -117.62 33.26 -117.59 33.25 -117.58 33.23 -117.56 33.21 -117.55 33.17 -117.51 33.14 -117.48 33.05 -117.41 33.03 -117.4 32.98 -117.35 32.92 -117.3 32.91 -117.29 32.86 -117.25 32.81 -117.21 32.8 -117.15 32.78 -117.08 32.78 -117.06 32.77 -117.04 32.75 -116.99 32.75 -116.99 32.74 -117.09 32.73 -117.19">]
I used the @timestamp value for a time range of +/- 2 minutes, removed “inAir”, and ran it against the SearchBirdseyePositions query:
Query: {airline 1} {orig_or_dest {KSAN}} {range lat 32.79488750844458 32.939619291555424} {range lon -117.32710573309947 -117.15479166690054} {< alt 100} {range clock 1498694969 1498695209}
no results
I was expecting to get more or less the same data back from the InFlight query. Any thoughts on what I’m not doing right here?
Truly appreciate the help!
Chris
The SearchBirdseyePositions does not support the orig_or_dest and airline operators so you’d need to remove those to do the SearchBirdseyePositions query.
Doh! Well that would do it – thanks for the eagle-eyes on the query.