Skip to content

Add replacement mode filter to the GTFS API's planConnection query#7437

Merged
tkalvas merged 14 commits intoopentripplanner:dev-2.xfrom
HSLdevcom:gtfs-planconnection-extendedtype-filter
Apr 14, 2026
Merged

Add replacement mode filter to the GTFS API's planConnection query#7437
tkalvas merged 14 commits intoopentripplanner:dev-2.xfrom
HSLdevcom:gtfs-planconnection-extendedtype-filter

Conversation

@tkalvas
Copy link
Copy Markdown
Contributor

@tkalvas tkalvas commented Mar 19, 2026

Summary

Implementation to address issue #7270

Add boolean "replacement" to PlanTransitModePreferenceInput which makes it possible to select (for example) just the buses which are not replacements, or just the buses which are replacements, when filtering possible transit modes for planConnection.

I'm not that sure about the naming of NarrowedTransitMode, but couldn't come up with a good name. (I also intended it to have the explicit gtfs extended type lists, but that idea was discarded by an OTP dev meeting).

Unit tests

Had to adjust a couple of tests.

Unit test for the added functionality still missing, necessary for approval.

Documentation

No changes.

Changelog

Yes.

Bumping the serialization version id

No.

@tkalvas tkalvas requested a review from a team as a code owner March 19, 2026 12:13
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 19, 2026

Codecov Report

❌ Patch coverage is 64.47368% with 54 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.29%. Comparing base (a8bc029) to head (e83c718).
⚠️ Report is 266 commits behind head on dev-2.x.

Files with missing lines Patch % Lines
...ntripplanner/apis/gtfs/generated/GraphQLTypes.java 25.00% 17 Missing and 1 partial ⚠️
...er/model/modes/AllowNarrowedTransitModeFilter.java 41.93% 17 Missing and 1 partial ⚠️
...fs/mapping/routerequest/ModePreferencesMapper.java 72.00% 5 Missing and 2 partials ⚠️
...anner/transit/model/basic/NarrowedTransitMode.java 72.00% 3 Missing and 4 partials ⚠️
...org/opentripplanner/model/modes/FilterFactory.java 60.00% 1 Missing and 1 partial ⚠️
.../opentripplanner/model/modes/FilterCollection.java 0.00% 1 Missing ⚠️
...ting/api/request/request/filter/SelectRequest.java 95.65% 1 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             dev-2.x    #7437      +/-   ##
=============================================
- Coverage      71.32%   71.29%   -0.04%     
- Complexity     21018    21171     +153     
=============================================
  Files           2339     2360      +21     
  Lines          86908    87670     +762     
  Branches        8605     8681      +76     
=============================================
+ Hits           61991    62507     +516     
- Misses         21919    22145     +226     
- Partials        2998     3018      +20     

☔ 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.

@tkalvas tkalvas marked this pull request as draft March 19, 2026 14:54
@miklcct
Copy link
Copy Markdown
Contributor

miklcct commented Mar 19, 2026

We hope to have a feature to filter by intercity train / suburban train. Will this have any effect in the design?

@tkalvas
Copy link
Copy Markdown
Contributor Author

tkalvas commented Mar 20, 2026

Jessica also wants filtering somewhat like that. I think these can be added easily, when we figure out how to map from netex submodes/extended gtfs types to the features we actually want to filter on, because the consensus was that we don't want to filter by them directly.

@tkalvas tkalvas marked this pull request as ready for review March 20, 2026 10:02
@optionsome optionsome changed the title Add GTFS planConnection replacement boolean filter by GTFS extended type Add GTFS planConnection replacement boolean filter Mar 24, 2026
@optionsome optionsome self-assigned this Mar 24, 2026
@optionsome optionsome self-requested a review March 24, 2026 09:08
Comment thread application/src/main/resources/org/opentripplanner/apis/gtfs/schema.graphqls Outdated
@tkalvas tkalvas requested a review from optionsome March 26, 2026 10:04
Copy link
Copy Markdown
Member

@optionsome optionsome left a comment

Choose a reason for hiding this comment

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

You could also update some existing GraphQL integration test. I've forgotten the reason why we do the replacement mapping on the API side instead of when we construct the routes/trips. The filtering would probably be a bit more efficient if we stored the information about a trip/route being a replacement in their data structures.


public MainAndSubMode toMainAndSubMode() {
if (this.replacement != null) {
throw new IllegalArgumentException("Not convertible to MainAndSubMode");
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.

Not sure what is the correct exception here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, me neither. But I think we should check invariants and throw exceptions more.

Comment thread application/src/main/resources/org/opentripplanner/apis/gtfs/schema.graphqls Outdated
@tkalvas tkalvas requested review from optionsome and t2gran April 7, 2026 11:18
Comment thread application/src/main/resources/org/opentripplanner/apis/gtfs/schema.graphqls Outdated
@tkalvas tkalvas requested a review from optionsome April 10, 2026 07:08
Comment thread application/src/main/resources/org/opentripplanner/apis/gtfs/schema.graphqls Outdated
@tkalvas tkalvas requested a review from optionsome April 10, 2026 09:21
Comment thread application/src/main/resources/org/opentripplanner/apis/gtfs/schema.graphqls Outdated
@tkalvas tkalvas requested a review from optionsome April 10, 2026 12:30
Comment thread application/src/main/resources/org/opentripplanner/apis/gtfs/schema.graphqls Outdated
@tkalvas tkalvas requested a review from optionsome April 13, 2026 07:35
@optionsome optionsome changed the title Add GTFS planConnection replacement boolean filter Add GTFS planConnection replacement mode filter Apr 13, 2026
@optionsome optionsome changed the title Add GTFS planConnection replacement mode filter Add replacement mode filter to the GTFS API's planConnection query Apr 13, 2026
@optionsome optionsome added the !New Feature A functional feature targeting the end user. label Apr 14, 2026
@optionsome optionsome added this to the 2.10 (next release) milestone Apr 14, 2026
@tkalvas tkalvas added this pull request to the merge queue Apr 14, 2026
Merged via the queue into opentripplanner:dev-2.x with commit e4b3734 Apr 14, 2026
9 checks passed
@tkalvas tkalvas deleted the gtfs-planconnection-extendedtype-filter branch April 14, 2026 08:41
t2gran pushed a commit that referenced this pull request Apr 14, 2026
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants