pyopensky icon indicating copy to clipboard operation
pyopensky copied to clipboard

Enrich results with origin/destination

Open xoolive opened this issue 1 year ago • 3 comments

Feature request by email from Davide Falanga

We've noticed that queries like the one below do not return some important features for our work, such as 'origin', 'destination', and 'aircraft_type'. In the past, at least the first two features were returned when using queries with more parameters (e.g., including the parameter 'airport').

trajectories = opensky.history(
    start=date,
    stop=date + timedelta(hours=2),
    bounds=(west, south, east, north)
)

Is there a way to retrieve these features in a query like the one shown above?

xoolive avatar Jul 11 '24 14:07 xoolive

Few thoughts:

  • it is easy to get those columns when you build a query using the flight table (and usually, filter flights based on origin/destination), because you first get the flight list, then go with the join query to download the state vectors
  • it is easy to write an extra query in the flight table based on the results of the one written above, maybe suboptimal?
  • if we can write a proper query to merge the results of the query above with the flight table:
    • how to write it efficiently?
    • what kind of arguments should we add to opensky.history to trigger that behaviour?

xoolive avatar Jul 11 '24 14:07 xoolive

See comment on issue #87 for a solution to the request to retrieve the (estimated) aerodrome of departure and destination like in the old API.

A possible automatic inclusion of origin and destination is to insert FlightsData4.estdepartureairport and FlightsData4.estarrivalairport columns in the selected_columns whenever any of departure_airport, arrival_airport, airport is not None in history(), and rename the returned estdepartureairport and estarrivalairport respectively to origin and destination

espinielli avatar Jul 11 '24 21:07 espinielli

See comment on issue #87 for a solution to the request to retrieve the (estimated) aerodrome of departure and destination like in the old API.

This works in your example in #87 because you have airport="LSZH".

In the current use case the filter is on the bounding box, so there is no call to the ˋflights_data4ˋ table necessary and the extra columns have no reason to exist.

xoolive avatar Jul 11 '24 22:07 xoolive