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

Improve support for EPIP NeTex profile #4863

Conversation

bas-hbt
Copy link
Contributor

@bas-hbt bas-hbt commented Feb 22, 2023

Summary

This PR improves compatibility with NeTEx-dataset specified in the EU-profile.

  • replace the direct usage of JourneyPattern and OperatingPeriod with their abstract VersionStructure-representations.
  • add support for UicOperatingPeriods
  • retrieve authority-reference directly from line
  • ignore StopPointInJourneyPattern without alighting and boarding
  • add fallback for GroupOfStopPlaces to retrieve name from member
  • add null-checks to prevent NullPointerExceptions

Issue

#3640

Unit tests

Added test for parsing UicOperationPeriod in DateTypeAssignmentMapper

loj-hbt and others added 17 commits February 2, 2023 18:20
…etex-profile(opentripplanner#3640)

# Conflicts:
#	src/main/java/org/opentripplanner/datastore/file/ZipFileDataSource.java
#	src/main/resources/Message_de.properties
@bas-hbt bas-hbt requested a review from a team as a code owner February 22, 2023 14:48
@leonardehrenfried leonardehrenfried changed the title Improve support for european netex profile (opentripplanner#3640) Improve support for european netex profile Feb 22, 2023
@leonardehrenfried leonardehrenfried changed the title Improve support for european netex profile Improve support for european NeTex profile Feb 22, 2023
Copy link
Contributor

@hannesj hannesj left a comment

Choose a reason for hiding this comment

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

Looks good, a couple of questions.

Comment on lines +131 to +135
if (
stopPoint != null &&
(isFalse(stopPoint.isForAlighting()) && isFalse(stopPoint.isForBoarding()))
) {
continue;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason to skip these? They are already marked as for not for alighting/boarding in mapToStopTime

Copy link
Contributor

@sjthiessen sjthiessen Feb 23, 2023

Choose a reason for hiding this comment

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

Our dataset contains many of these stops as they're usually used to model tariff barriers. There are no PassengerStopAssignments for these stopPoints, so "lookUpStopLocation" yields null which results in the trip not being mapped at all.
The attempt was to ignore these for now, but I guess we should find a better solution

@leonardehrenfried
Copy link
Member

Can you run the autoformatter with mvn prettier:write? If you're on Windows you need to merge the latest dev-2.x for it to work.

hannesj
hannesj previously approved these changes Feb 23, 2023
@codecov
Copy link

codecov bot commented Feb 23, 2023

Codecov Report

Patch coverage: 69.04% and project coverage change: +0.08 🎉

Comparison is base (bc69337) 62.93% compared to head (646ce0c) 63.02%.

Additional details and impacted files
@@              Coverage Diff              @@
##             dev-2.x    #4863      +/-   ##
=============================================
+ Coverage      62.93%   63.02%   +0.08%     
- Complexity     13263    13301      +38     
=============================================
  Files           1662     1662              
  Lines          66330    66376      +46     
  Branches        7215     7227      +12     
=============================================
+ Hits           41748    41831      +83     
+ Misses         22200    22168      -32     
+ Partials        2382     2377       -5     
Impacted Files Coverage Δ
.../opentripplanner/netex/index/NetexEntityIndex.java 99.01% <ø> (ø)
...ipplanner/netex/mapping/GroupOfStationsMapper.java 15.38% <0.00%> (-2.80%) ⬇️
...entripplanner/netex/mapping/ServiceLinkMapper.java 51.66% <ø> (ø)
...tripplanner/netex/mapping/TripCalendarBuilder.java 89.58% <ø> (ø)
...entripplanner/netex/mapping/TripPatternMapper.java 70.80% <ø> (ø)
...g/opentripplanner/netex/mapping/StationMapper.java 61.81% <16.66%> (+8.87%) ⬆️
...opentripplanner/netex/mapping/StopTimesMapper.java 66.66% <33.33%> (+3.38%) ⬆️
...lanner/netex/loader/parser/ServiceFrameParser.java 73.97% <66.66%> (+2.05%) ⬆️
.../org/opentripplanner/netex/mapping/TripMapper.java 71.95% <66.66%> (+10.97%) ⬆️
...etex/mapping/calendar/DayTypeAssignmentMapper.java 86.95% <76.19%> (-4.12%) ⬇️
... and 21 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@leonardehrenfried leonardehrenfried changed the title Improve support for european NeTex profile Improve support for EPIP NeTex profile Feb 23, 2023
Copy link
Contributor

@vpaturet vpaturet left a comment

Choose a reason for hiding this comment

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

Looks good to me, I have only a few minor comments. Will you add NeTEx test data as part of this PR or in a separate one?


import org.opentripplanner.graph_builder.issue.api.DataImportIssue;

public class InvalidTimeZone implements DataImportIssue {
Copy link
Contributor

Choose a reason for hiding this comment

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

It is now recommended to use the generic Issue builder instead of creating a custom class. See

@@ -244,8 +244,8 @@ private void parseJourneyPatterns(JourneyPatternsInFrame_RelStructure journeyPat
if (journeyPatterns == null) return;

for (JAXBElement<?> pattern : journeyPatterns.getJourneyPattern_OrJourneyPatternView()) {
if (pattern.getValue() instanceof JourneyPattern) {
this.journeyPatterns.add((JourneyPattern) pattern.getValue());
if (pattern.getValue() instanceof JourneyPattern_VersionStructure) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Use pattern matching for instanceof (was missing in the original code but this is an opportunity to improve it)

boolean isAvailable = isDayTypeAvailableForAssigment(dayTypeAssignment);

String ref = dayTypeAssignment.getOperatingPeriodRef().getRef();
OperatingPeriod period = operatingPeriods.lookup(ref);
OperatingPeriod_VersionStructure period = operatingPeriods.lookup(ref);

if (period != null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You can remove the null check (instanceof is false with null)

@loj-hbt loj-hbt force-pushed the support-european-netex-profile(opentripplanner#3640) branch from 4270056 to 2751fff Compare February 28, 2023 10:18
@t2gran t2gran added this to the 2.3 milestone Feb 28, 2023
@hannesj hannesj merged commit 67f94aa into opentripplanner:dev-2.x Feb 28, 2023
t2gran pushed a commit that referenced this pull request Feb 28, 2023
sjthiessen added a commit to HBTGmbH/OpenTripPlanner that referenced this pull request Mar 2, 2023
loj-hbt pushed a commit to HBTGmbH/OpenTripPlanner that referenced this pull request Mar 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants