Skip to content

Use the most common static GTFS shape for trip patterns and store differing shapes per trip - #8317

Open
VillePihlava wants to merge 9 commits into
opentripplanner:dev-2.xfrom
HSLdevcom:per-trip-static-shapes
Open

VillePihlava wants to merge 9 commits into
opentripplanner:dev-2.xfrom
HSLdevcom:per-trip-static-shapes

Conversation

@VillePihlava

Copy link
Copy Markdown
Contributor

Summary

This is the second phase of the shape service changes and a follow-up to #8149.

This PR calculates the trip pattern shape from static GTFS shapes based on the most used shape. Before the first found trip shape was used for a trip pattern shape.

Pattern-level fields keep the pattern shape. ScheduledTransitLeg.tripPatternShape is renamed to tripShape. Users of the trip shape:

  • itinerary legs, leg references and alternative legs;
  • Trip.geometry, Trip.tripGeometry and StopCall.geometryToNextCall (GTFS API);
  • ServiceJourney.pointsOnLink (Transmodel API).

HSL graph build comparison Two runs of dev-2.x (2ee585032c) vs this branch using the same data and config

dev-2.x this PR
Graph building 1m17s / 1m18s 1m20s / 1m21s
graph.obj size 289,004,674 / 288,915,468 B 288,937,007 / 288,916,082 B
  • 2,636 of 446,343 trips (0.6%), in 12 of 1,247 patterns, follow a different shape than their pattern.
  • 1,332 distinct trip shapes were computed.

Issue

Ref #7939

Unit tests

  • AlternativeLegsTest
  • DefaultShapeServiceTest
  • RaptorPathToItineraryMapperTest
  • ScheduledTransitLegReferenceTest
  • ShapeDataImportTest
  • StopCallImplTest
  • TripShapeFactoryTest
  • new TripShapeCollectorTest

Documentation

service/shape/package.md describes trip shapes, how the pattern shape is chosen and the real-time
limitation.

@VillePihlava
VillePihlava requested a review from a team as a code owner December 4, 2026 12:45
@codecov

codecov Bot commented Dec 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.93289% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.18%. Comparing base (2ee5850) to head (c9f371b).

Files with missing lines Patch % Lines
...entripplanner/apis/gtfs/datafetchers/TripImpl.java 0.00% 5 Missing ⚠️
...algorithm/mapping/RaptorPathToItineraryMapper.java 50.00% 4 Missing ⚠️
...transmodel/model/timetable/ServiceJourneyType.java 0.00% 3 Missing ⚠️
...service/shape/model/CompactLineStringSequence.java 71.42% 0 Missing and 2 partials ⚠️
...opentripplanner/gtfs/shape/TripShapeCollector.java 98.11% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             dev-2.x    #8317    +/-   ##
===========================================
  Coverage      76.17%   76.18%            
- Complexity     24900    24930    +30     
===========================================
  Files           2671     2672     +1     
  Lines          93270    93380   +110     
  Branches        9293     9304    +11     
===========================================
+ Hits           71049    71142    +93     
- Misses         19082    19093    +11     
- Partials        3139     3145     +6     

☔ View full report in Codecov by Harness.
📢 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.

@VillePihlava VillePihlava added this to the 2.11 (next release) milestone Dec 4, 2026
@VillePihlava VillePihlava added !Improvement A functional improvement or micro feature +GTFS Related to import of GTFS data +Bump Serialization Id Add this label if you want the serialization id automatically bumped after merging the PR HSL Helsinki Regional Transport Authority labels Dec 4, 2026
@optionsome optionsome self-assigned this Dec 4, 2026
@optionsome
optionsome self-requested a review December 4, 2026 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

+Bump Serialization Id Add this label if you want the serialization id automatically bumped after merging the PR +GTFS Related to import of GTFS data HSL Helsinki Regional Transport Authority !Improvement A functional improvement or micro feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants