Skip to content

Add support for NeTex DatedServiceJourneys - #3889

Merged
t2gran merged 6 commits into
opentripplanner:dev-2.xfrom
Skanetrafiken:12488_datedServiceJourneys
Mar 29, 2022
Merged

Add support for NeTex DatedServiceJourneys#3889
t2gran merged 6 commits into
opentripplanner:dev-2.xfrom
Skanetrafiken:12488_datedServiceJourneys

Conversation

@JonathanBrynhagen

@JonathanBrynhagen JonathanBrynhagen commented Feb 10, 2022

Copy link
Copy Markdown
Contributor

Summary

Created a new object TripOnServiceDate to represent a DatedServiceJourney and adds these to the graph index by creating two new maps.
One is indexed using datedServiceJourneyId and the other using a tuple of tripId and serviceDate. Both return a single TripOnServiceDate.
TripOnServiceDates are also indexed in TimetableSnapshots for when there are realtime updates.

A new GraphQL endpoint is added called datedServiceJourney with which you can retrieve a datedServiceJourney from the graph index (or TimetableSnapshot if there are realtime updates) using a datedServiceJourneyId.
Additionally a field is added to the LegType where you can now retrieve the datedServiceJourney used in that leg aswell following the same logic as above.

Unit tests

A new unit test was added asserting that TripOnServiceDate objects are correctly created during NeTEx mapping.

Code style

Followed the code style included in the repo

Related issue #3150

@JonathanBrynhagen
JonathanBrynhagen requested a review from a team as a code owner February 10, 2022 09:17
@MikaelJarfors MikaelJarfors added the Skanetrafiken On skanetrafikens roadmap label Feb 10, 2022
@t2gran t2gran added this to the 2.1 milestone Feb 10, 2022

@t2gran t2gran left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should probably test this, with a dataset with DSJ.

Comment thread src/ext/java/org/opentripplanner/ext/siri/SiriTimetableSnapshotSource.java Outdated
@t2gran t2gran modified the milestones: 2.1, 2.2 Feb 22, 2022
@JonathanBrynhagen
JonathanBrynhagen force-pushed the 12488_datedServiceJourneys branch from dcef10b to 0a08dbd Compare February 28, 2022 16:04
@hannesj
hannesj self-requested a review March 1, 2022 10:00
@JonathanBrynhagen JonathanBrynhagen changed the title Mapping and linking DatedServiceJourneys to TripTimes Adding DatedServiceJourneys to GraphIndex and exposing DSJ GraphQL Endpoint Mar 1, 2022
@t2gran
t2gran self-requested a review March 1, 2022 10:55
@MikaelJarfors MikaelJarfors added the !New Feature A functional feature targeting the end user. label Mar 2, 2022
Comment thread src/main/java/org/opentripplanner/model/TimetableSnapshot.java Outdated
Comment thread src/main/java/org/opentripplanner/routing/graph/Graph.java Outdated
Comment thread src/main/java/org/opentripplanner/routing/DatedServiceJourneyHelper.java Outdated
Comment thread src/main/java/org/opentripplanner/routing/DatedServiceJourneyHelper.java Outdated
Comment thread src/main/java/org/opentripplanner/netex/mapping/TripPatternMapper.java Outdated
Comment thread src/ext/java/org/opentripplanner/ext/transmodelapi/model/plan/LegType.java Outdated
Comment thread src/main/java/org/opentripplanner/model/TripOnServiceDate.java Outdated
@JonathanBrynhagen
JonathanBrynhagen force-pushed the 12488_datedServiceJourneys branch from e2c84c8 to 988b82f Compare March 8, 2022 14:50
Comment thread src/ext/java/org/opentripplanner/ext/transmodelapi/model/plan/LegType.java Outdated
Comment thread src/main/java/org/opentripplanner/netex/mapping/NetexMapper.java Outdated
Comment thread src/main/java/org/opentripplanner/netex/mapping/NetexMapper.java Outdated
Comment thread src/main/java/org/opentripplanner/netex/mapping/TripCalendarBuilder.java Outdated
Comment thread src/main/java/org/opentripplanner/netex/mapping/TripPatternMapper.java Outdated
Comment thread src/main/java/org/opentripplanner/netex/mapping/TripPatternMapper.java Outdated
t2gran
t2gran previously approved these changes Mar 11, 2022
Comment thread src/main/java/org/opentripplanner/routing/graph/GraphIndex.java
Comment thread src/main/java/org/opentripplanner/routing/graph/GraphIndex.java
Comment thread src/main/java/org/opentripplanner/netex/mapping/NetexMapper.java Outdated
Comment thread src/main/java/org/opentripplanner/netex/mapping/TripPatternMapper.java Outdated
Comment thread src/main/java/org/opentripplanner/netex/mapping/NetexMapper.java Outdated
@JonathanBrynhagen

Copy link
Copy Markdown
Contributor Author

I get the following error when building with the Norwegian dataset at https://storage.googleapis.com/marduk-dev/outbound/netex/rb_norway-aggregated-netex.zip

"An uncaught error occurred inside OTP: java.lang.NullPointerException: DatedServiceJourney operating-day not found. DSJ Id: GAN:DatedServiceJourney:3964_LE-BDN_21-11-09
java.lang.RuntimeException: java.lang.NullPointerException: DatedServiceJourney operating-day not found. DSJ Id: GAN:DatedServiceJourney:3964_LE-BDN_21-11-09
	at org.opentripplanner.netex.NetexModule.buildGraph(NetexModule.java:117)
	at org.opentripplanner.graph_builder.GraphBuilder.run(GraphBuilder.java:81)
	at org.opentripplanner.standalone.OTPMain.startOTPServer(OTPMain.java:136)
	at org.opentripplanner.standalone.OTPMain.main(OTPMain.java:52)
Caused by: java.lang.NullPointerException: DatedServiceJourney operating-day not found. DSJ Id: GAN:DatedServiceJourney:3964_LE-BDN_21-11-09
	at org.opentripplanner.netex.mapping.calendar.DatedServiceJourneyMapper.mapToServiceDates(DatedServiceJourneyMapper.java:58)
	at org.opentripplanner.netex.mapping.TripCalendarBuilder.addDatedServiceJourneys(TripCalendarBuilder.java:87)
	at org.opentripplanner.netex.mapping.NetexMapper.mapDatedServiceJourneys(NetexMapper.java:362)
	at org.opentripplanner.netex.mapping.NetexMapper.mapNetexToOtp(NetexMapper.java:185)
	at org.opentripplanner.netex.NetexBundle.loadFilesThenMapToOtpTransitModel(NetexBundle.java:165)
	at org.opentripplanner.netex.NetexBundle.lambda$loadFileEntries$1(NetexBundle.java:117)
	at org.opentripplanner.netex.NetexBundle.scopeInputData(NetexBundle.java:141)
	at org.opentripplanner.netex.NetexBundle.loadFileEntries(NetexBundle.java:115)
	at org.opentripplanner.netex.NetexBundle.loadBundle(NetexBundle.java:93)
	at org.opentripplanner.netex.NetexModule.buildGraph(NetexModule.java:78)
	... 3 common frames omitted

The data looks valid to me image

I tried reproducing this after @t2gran's PR and that seems to have fixed the issue. If it's still a problem let me know.

@t2gran

t2gran commented Mar 16, 2022

Copy link
Copy Markdown
Member

I tried reproducing this after @t2gran's PR and that seems to have fixed the issue. If it's still a problem let me know.

I did fix it, an operating-day (any entity) must be in the same file (group file) or one of its parents, shared group file or shared file.

t2gran
t2gran previously approved these changes Mar 16, 2022
@t2gran t2gran removed the Entur Test This is currently being tested at Entur label Mar 17, 2022
Comment thread src/ext/java/org/opentripplanner/ext/siri/SiriTimetableSnapshotSource.java Outdated
@t2gran

t2gran commented Mar 23, 2022

Copy link
Copy Markdown
Member

@JonathanBrynhagen For next time, I would prefer if you did not "force push" after we have gone fare into the review process😀. I makes it harder to review.

Jonathan Brynhagen added 5 commits March 25, 2022 15:11
	* Mapping DatedServiceJourney from NeTEx to a TripOnServiceDate object
	* Created GraphQL endpoint for fetching DatedServiceJourney
	* Added DatedServiceJourney field to leg in the GraphQL plan response
	* Added fields containing TripOnServiceDate in TimetableSnapshot when updating with SIRI-realtime
@JonathanBrynhagen
JonathanBrynhagen force-pushed the 12488_datedServiceJourneys branch from 72abcfb to 8a7ebd9 Compare March 25, 2022 14:12
@leonardehrenfried leonardehrenfried changed the title Adding DatedServiceJourneys to GraphIndex and exposing DSJ GraphQL Endpoint Add NeTex DatedServiceJourneys Mar 29, 2022
@leonardehrenfried leonardehrenfried changed the title Add NeTex DatedServiceJourneys Add support for NeTex DatedServiceJourneys Mar 29, 2022
@t2gran
t2gran merged commit 511b909 into opentripplanner:dev-2.x Mar 29, 2022
t2gran pushed a commit that referenced this pull request Mar 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

!New Feature A functional feature targeting the end user. Skanetrafiken On skanetrafikens roadmap

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants