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

Fix ID generation hacks in GTFS mapping, improve FaresV2 spec conformance #6586

Open
wants to merge 17 commits into
base: dev-2.x
Choose a base branch
from

Conversation

leonardehrenfried
Copy link
Member

Summary

This PR has two parts:

  • Improves the conformance with GTFS FaresV2 in as much that a transfer without a fare product counts as free
  • Removes a few ugly hacks for generating feed-scoped IDs

ID generation

Previously OTP re-wrote the AgencyAndId and set the agency ID to the feed ID and then during mapping converted that to a feed scoped ID. This was pretty confusing, brittle and allowed you to only convert AgencyAndIds to FeedScopedIds not strings.

This has been replaced with a more robust approach where we inject a IdFactory into the mappers.

Unit tests

Lots updated and new ones for fares functionality added.

Bumping the serialization version id

Yes, graph entities are changed.

cc @miles-grant-ibigroup @fpurcell

@leonardehrenfried leonardehrenfried requested a review from a team as a code owner March 31, 2025 09:16
Copy link

codecov bot commented Mar 31, 2025

Codecov Report

Attention: Patch coverage is 93.08176% with 11 lines in your changes missing coverage. Please review.

Project coverage is 71.06%. Comparing base (3370f92) to head (119ac69).

Files with missing lines Patch % Lines
...va/org/opentripplanner/model/fare/FareProduct.java 79.16% 0 Missing and 5 partials ⚠️
...tripplanner/ext/fares/impl/GtfsFaresV2Service.java 83.33% 0 Missing and 1 partial ⚠️
...ntripplanner/ext/fares/model/FareTransferRule.java 80.00% 0 Missing and 1 partial ⚠️
...pentripplanner/gtfs/mapping/FareLegRuleMapper.java 83.33% 1 Missing ⚠️
...pentripplanner/gtfs/mapping/FareProductMapper.java 90.00% 1 Missing ⚠️
...pentripplanner/gtfs/mapping/PathwayModeMapper.java 0.00% 1 Missing ⚠️
...er/gtfs/mapping/WheelchairAccessibilityMapper.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             dev-2.x    #6586      +/-   ##
=============================================
+ Coverage      71.04%   71.06%   +0.01%     
- Complexity     18299    18312      +13     
=============================================
  Files           2005     2005              
  Lines          75849    75871      +22     
  Branches        7779     7773       -6     
=============================================
+ Hits           53885    53915      +30     
+ Misses         19221    19210      -11     
- Partials        2743     2746       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@leonardehrenfried leonardehrenfried changed the title Fix ID generation hacks in GTFS code, improve FaresV2 spec conformance Fix ID generation hacks in GTFS mapping, improve FaresV2 spec conformance Mar 31, 2025
@@ -360,51 +360,6 @@ private GtfsMutableRelationalDao loadBundle(GtfsBundle gtfsBundle) throws IOExce
}
}

for (ShapePoint shapePoint : store.getAllEntitiesForType(ShapePoint.class)) {
Copy link
Member Author

Choose a reason for hiding this comment

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

@binh-dam-ibigroup You asked about this in a previous PR and all of this ugly code is now going away completely.

optionsome
optionsome previously approved these changes Apr 8, 2025
@leonardehrenfried
Copy link
Member Author

@optionsome I'm sorry but I noticed another bug.

# Conflicts:
#	application/src/main/java/org/opentripplanner/gtfs/mapping/AgencyAndIdMapper.java
#	application/src/main/java/org/opentripplanner/gtfs/mapping/FareLegRuleMapper.java
#	application/src/main/java/org/opentripplanner/gtfs/mapping/FareProductMapper.java
#	application/src/main/java/org/opentripplanner/gtfs/mapping/FareTransferRuleMapper.java
#	application/src/main/java/org/opentripplanner/gtfs/mapping/GTFSToOtpTransitServiceMapper.java
#	application/src/test/java/org/opentripplanner/gtfs/mapping/FareTransferRuleMapperTest.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GTFS Related to import of GTFS data Technical Debt
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants