Skip to content

Conversation

@optionsome
Copy link
Member

@optionsome optionsome commented Jun 17, 2025

Summary

Temporary vertex creation is moved to routing worker so we don't do it separately for access/egress and direct searches. TemporaryVerticesContainer is now used for coordinate visit via locations as well.

Functional changes:

  • Names for unlabeled visit via location coordinate vertices have now translatable default name
  • visit via location coordinate locations are now validated similarly as origin and destination and if they cannot be connected to street network, a routing error will be returned

Issue

Relates to #6501

Unit tests

Will add new tests and there is one existing test failing (haven't had time yet to figure out why).

Documentation

Not needed

Changelog

Skipped

@optionsome optionsome added !Technical Debt Improve code quality, no functional changes. +Bump Serialization Id Add this label if you want the serialization id automatically bumped after merging the PR +Skip Changelog This is not a relevant change for a product owner since last release. labels Jun 17, 2025
@codecov
Copy link

codecov bot commented Jun 19, 2025

Codecov Report

❌ Patch coverage is 87.86280% with 46 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.21%. Comparing base (1ea783b) to head (e2e597b).
⚠️ Report is 220 commits behind head on dev-2.x.

Files with missing lines Patch % Lines
...entripplanner/routing/algorithm/RoutingWorker.java 75.51% 9 Missing and 3 partials ⚠️
...a/service/DefaultViaCoordinateTransferFactory.java 0.00% 12 Missing ⚠️
...reet/search/TemporaryVerticesContainerBuilder.java 96.24% 2 Missing and 6 partials ⚠️
...oradapter/transit/mappers/RaptorRequestMapper.java 64.70% 4 Missing and 2 partials ⚠️
...rg/opentripplanner/visualizer/GraphVisualizer.java 0.00% 5 Missing ⚠️
...va/org/opentripplanner/apis/gtfs/GraphQLUtils.java 0.00% 2 Missing ⚠️
...ntripplanner/apis/gtfs/generated/GraphQLTypes.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             dev-2.x    #6704      +/-   ##
=============================================
+ Coverage      72.08%   72.21%   +0.12%     
- Complexity     19512    19597      +85     
=============================================
  Files           2106     2108       +2     
  Lines          78936    79136     +200     
  Branches        8000     8012      +12     
=============================================
+ Hits           56902    57147     +245     
+ Misses         19220    19173      -47     
- Partials        2814     2816       +2     

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

@optionsome optionsome marked this pull request as ready for review July 1, 2025 07:26
@optionsome optionsome requested a review from a team as a code owner July 1, 2025 07:26
@optionsome optionsome changed the title Refactor how temporary vertices are created for a routing request Add validation for visit via locations with coordinates when attempting to link them to graph Jul 1, 2025
@optionsome optionsome removed the +Skip Changelog This is not a relevant change for a product owner since last release. label Jul 1, 2025

/**
* Utility class. If the from and to vertices are generated and lie along some of the same edges,
* Utility class. If the from, to or via vertices are generated and lie along some of the same edges,
Copy link
Member

Choose a reason for hiding this comment

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

This class is only used by TemporarVerticesContainerBuilder. We can move it into its package and make it package-private.

Copy link
Member

Choose a reason for hiding this comment

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

It is used by TestHalfEdges but that's a pretty old and very unfocussed test. I would be ok if you deleted the two test cases that use it.

Copy link
Member

Choose a reason for hiding this comment

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

However, I can also do it in one of my PRs.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm a bit hesitant on removing the TestHalfEdges test because there probably isn't a test anywhere else that tests this functionality. I think we should create unit tests for the adjuster itself and remove the TestHalfEdges test, but I think this pr is big enough already so I'm not going to do this refactoring at least in this pr.

public void locationNotFoundException() {
// Stops not found
try (
var container = TemporaryVerticesContainer.of(g)
Copy link
Member

Choose a reason for hiding this comment

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

I think assertThrows is more appropriate here.

Copy link
Member

Choose a reason for hiding this comment

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

There are a few more places in this class where this is the case.

Copy link
Member Author

Choose a reason for hiding this comment

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

assertThrows doesn't call the close() on the AutoCloseable by default, but there is a workaround junit-team/junit-framework#2189 (comment). I'm not sure which solution is prettier.

Copy link
Member Author

@optionsome optionsome Jul 2, 2025

Choose a reason for hiding this comment

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

While thinking about this, I realized there was memory leak when the builder threw an exception. I ended up using assertThrows as suggested.

Copy link
Member

@leonardehrenfried leonardehrenfried left a comment

Choose a reason for hiding this comment

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

I think this is a solid refactoring where lots of duplicate instantiation of the temp vertices container is removed. Nevertheless, I have a few requests.

@t2gran t2gran modified the milestones: 2.8, 2.9 (next release) Sep 10, 2025
@t2gran t2gran added the +Skip Changelog This is not a relevant change for a product owner since last release. label Oct 2, 2025
Comment on lines +48 to +52
* This class is responsible for linking the RouteRequest origin, destination and visit via
* locations that contain coordinates to the Graph used in the A-Star search. This builder also
* validates that it was possible to link the locations to the graph. The responsibility of cleaning
* up the temporary vertices and edges is on the {@link TemporaryVerticesContainer}.
*/
Copy link
Member

Choose a reason for hiding this comment

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

This is looks like the responsibilities of the domain class, not the builder. We only document if a builder needs to do something none standard stuff on builders. All domain documentatio should be on the domain class.

Copy link
Member

Choose a reason for hiding this comment

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

This class suddenly have to deal with a lot of detailed access/egress mode business logic. This does not belong in this class.

Creating and passing in a TemporaryVertexContainer is ok (there is not many better options), but the container should be clean - no routing/domain logic - pure framework. If we do that then the logic in createTemporaryVerticesContainer can be moved. Not sure where, but to a mapper or pushed down.

@optionsome
Copy link
Member Author

I'll close this and open another pr from upstream repo with these changes + more.

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 +Skip Changelog This is not a relevant change for a product owner since last release. !Technical Debt Improve code quality, no functional changes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants