Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(WIP) Add AbstractOpenTripPlannerProvider #211

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

hbruch
Copy link

@hbruch hbruch commented Jul 29, 2018

The AbstractOpenTripPlannerProvider enables the integration of OTP based journey planners like e.g. Mitfahren-BW, plannerstack, TriMet…

There'll still be some issues but I'd be glad to already get some feedback.
@schildbach could you have a look into it? Thx.

Copy link
Contributor

@grote grote left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for your PR! Great to get OpenTripPlanner support in PTE :)

I just gave this a very quick reading and left a few comments.

productsToModeMap.put(Product.SUBURBAN_TRAIN, OTPMode.RAIL.toString());
productsToModeMap.put(Product.SUBWAY, OTPMode.SUBWAY.toString());
productsToModeMap.put(Product.TRAM, OTPMode.TRAM.toString());
// GONDOLA and FUNICULAR are no PTE Products, but OTP modes. Associate them with TRAM (?)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the difference to Product.CABLECAR?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I agree, FUNICULAR might be seen as a specialization of cable car. But for gondolas PTE has no corresponding product. For OTP, gondolas correspond to telecabin services, for which PTE has currently no product.
For lines, the product is not mandatory and may be null when parsing an OTP response in such a case. I guess I should really set it to null for gondolas.
For requests, I think it should be subsumed under a more or less resembling code, so it can be (de)selected when filtering products.

@@ -101,7 +101,7 @@ public void log(final String message) {
OKHTTP_CLIENT = builder.build();
}

private static final String SCRAPE_ACCEPT = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
private static final String DEFAULT_ACCEPT = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you rename this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment below, it‘s now a default that can be overridden

@@ -173,10 +173,10 @@ public void getInputStream(final Callback callback, final HttpUrl url, final Str
while (true) {
final Request.Builder request = new Request.Builder();
request.url(url);
request.header("Accept", DEFAULT_ACCEPT);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why moving this here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OTP‘s responds with xml or json, depending on The accept header. To have it return json, I need to set it to json, which was always overridden by the SCRAPE_ACCEPT header. Hope just using this as default but not mandatory will not break anything for other providers. Or was there an explicit reason why it was necessary to override it?

import de.schildbach.pte.dto.Trip.Public;
import okhttp3.HttpUrl;

@RunWith(MockitoJUnitRunner.class)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure that you really need Mockito. Any reason you can not use assertEquals() or assertNotNull()?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I introduced mockito to stub out the AOTPP.request() method to do some unit testing. Current provider tests seemed to be all live provider tests, which mostly print the results and do only a few plausibility checks. I‘m still not happy having large json snippets in the test class. Still thinking about this... I‘ll rewrite the asserts to match the current pte style, but still think mockito would be useful

print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this testing "onlyBike"?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Misnamer. Will fix it, thx.

@hbruch
Copy link
Author

hbruch commented Jul 31, 2018

Just saw that opentransitmap has an incubation repository. Should I request a pull there first?

@grote
Copy link
Contributor

grote commented Jul 31, 2018

That's up to you. Shouldn't be necessary. Ideally, things get merged here. I don't think they do much code review there. If your PR gets ignored for too long, I'd consider it.

@ruzko
Copy link

ruzko commented Dec 14, 2021

Is there any progress on this issue? I'd really like to use transportr in Norway

@ruzko
Copy link

ruzko commented Nov 14, 2022

I see no progress the past few years. Can I post a 20 Euro feature bounty?
*edit: I see Norway on Navitia. But it's touted as french territory... Is it the same country or some other place?
https://navitia.opendatasoft.com/explore/dataset/norway/information/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants