PH-KDX / flightplandb-py

Python wrapper for the Flight Plan Database API
https://flightplandb-py.readthedocs.io/
GNU General Public License v3.0
17 stars 4 forks source link

Why can't I see the route of my flight plan? #13

Closed ElSabio97 closed 2 years ago

ElSabio97 commented 2 years ago

Hi!

I'm creating a flightplan using the following code:

import flightplandb as fpdb

# obviously, substitute your own token
api = fpdb.FlightPlanDB("I inserted my own token here")

query = fpdb.datatypes.GenerateQuery(fromICAO="LEMD",
                                 toICAO="LEBB",useNAT=False,usePACOT=False,useAWYHI=False)
flightplan = api.plan.generate(query,return_format="native")

When I try to retrieve the route of my flightplan using flightplan.route it says is a NoneType variable. That field is empty.

Why does this happen? When I see the created flight plan on the website, the route is visible.

PH-KDX commented 2 years ago

Hi, You're right, just tested it myself. If I look at the plan generation in the API docs, at https://flightplandatabase.com/dev/api#endpoint-generate, I see that a route is not returned. Unfortunately, since it's not my API or website, I can't change that. I'll send an email to the API maintainer about it, though. If he doesn't change it, I'll add a note to the library docs in the next release to indicate this. To work around this, I suggest you take the plan ID as returned by the generate function, and use that to fetch the plan route.

ElSabio97 commented 2 years ago

Thank you for answering so fast. The thing is that I just wanted to use this library because I was looking for a route generator in Python. It looks like there are not so many so this looked excellent for the job.

I just needed something that gives back the name of the fixes and navaids of the route with its coordinates that is all.

I will try to use the search function to try and retrieve the route of a previously created flight plan. Since the inputs are the origin and destination airports.

Also, do you think it could be done by setting return_format to csv? I have tried this but I do not know how that bytes thing works hehe.

PH-KDX commented 2 years ago

Unfortunately, the return_format feature is also currently broken on the API side; currently, it always returns a Plan object. I sent an email to the maintainer about it a week ago, but I still haven't gotten a response. The way it should work, when everything is working as usual, is that when return_format is set to, say, csv, the information is returned in CSV format inside a bytes object instead of as a Plan object, The reason a bytes object is used instead of a string is so that anything which happens to be an escape code in Python does not get escaped in the string conversion. However, the same information is returned in CSV format as in native format. If the route isn't returned in native format, switching to CSV wouldn't help you in any case.

ElSabio97 commented 2 years ago

Thanks for the help. I will try to retrieve routes from other sources then.

Have a nice day!

PH-KDX commented 2 years ago

I do suggest you just use the ID to fetch the route. It means 2 http calls instead of one, but it would probably be easier than completely switching API.