schildbach / public-transport-enabler

Unleash public transport data in your Java project.
https://groups.google.com/forum/#!forum/public-transport-enabler-discuss
GNU General Public License v3.0
382 stars 133 forks source link

Add Flixbus provider #113

Open dotlambda opened 7 years ago

dotlambda commented 7 years ago

I'm currently working on adding a provider for Flixbus, a german/european provider of long distance buses, but I'm having some issues that I'd like to discuss before putting any larger effort into it:

I'd be happy if @schildbach and @grote could comment on this :-)

schildbach commented 7 years ago

Hey, that's great!

Almost all of the providers started with reverse engineering, and still do (even though in some cases there is some incomplete but official documentation). Yes, maintaining the provider will continue to take effort.

I am not a lawyer, but my understanding is if the data is published by the public transit authority you (an app) can forward it to the user as long as it doesn't take ownership of the data. Otherwise, web browsers or terminal clients would not be legal.

I take it the number of stops FlixBus serves is tiny, compared to the typical number of train or bus stops. So I think downloading the entire list of stops is a valid approach for now. We currently do not use caching with okhttp, but it would be easy to do I guess.

dotlambda commented 7 years ago

The API doesn't seem to provide line numbers (not even the website does), so would it be ok to make the line argument of the Public constructor nullable? I'm not very proficient in Java, so I don't know what @Nullable does when put in front of an argument or a variable declaration. Is the checkNotNull() function the old way of doing it?

dotlambda commented 7 years ago

If anyone is interested in what I've done so far, you can have a look here.

schildbach commented 7 years ago

For now, just remove the checkNotNull() if its easier for you. @Nullable is just a hint for your IDE to show an error if you potentially pass a null as a not-nullable argument.

We'll will have to decide if we keep it like that or if we just provide dummy line numbers. If we allow null in this field the various apps will need to provide dummy appearances of lines without any number.

grote commented 7 years ago

How about using "FLIX" as a line number for all lines with the flix colors?

dotlambda commented 7 years ago

Flixbus also only supports searching by day, not by time and doesn't support searching by arrival date. Should we add new capabilities for that?

grote commented 7 years ago

How about just ignoring the time and arrival/departure value for now?

grote commented 7 years ago

You could also remove all trips before the specified time manually after receiving the result and only show what is after the time to the user.

schildbach commented 7 years ago

Yeah, just ignore the time for now. For now, I'd also not remove trips from the result. Let's see how it works out, we can optimize later.

dotlambda commented 7 years ago

Since Flixbus operates in multiple countries, a station can have different names depending on which language version you request. The language is choosen via the Accept-Language header. Is there already a provider that is available in multiple languages? Else, what would be the proper way to deal with that? I think since a supplemental header shouldn't hurt any of the other API endpoints, we could simply add an optional argument to the AbstractNetworkProvider that sets the appropriate (standardized) header via httpClient.setHeader(). I'm however not sure what the should be passed to the constructor: something like en-US or more like English (United States).