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

Remove configurable car speed and determine it in graph build #5657

Merged
merged 16 commits into from Feb 29, 2024

Conversation

optionsome
Copy link
Member

@optionsome optionsome commented Feb 2, 2024

Summary

This removes car.speed from router-config.json. The graph wide max car speed is determined during the graph build. Maximum possible car speed can be set in a OSM mapper and that is used as the upper limit for car speeds when reading in OSM ways (previously there was no upper limit during graph build).

Issue

Closes #5656

Unit tests

Added

Documentation

Updated

Changelog

From title

@optionsome optionsome added improvement bump serialization id Add this label if you want the serialization id automatically bumped after merging the PR config change labels Feb 2, 2024
@optionsome optionsome requested a review from a team as a code owner February 2, 2024 18:10
Copy link

codecov bot commented Feb 2, 2024

Codecov Report

Attention: 19 lines in your changes are missing coverage. Please review.

Comparison is base (c893a8b) 67.68% compared to head (65cbff9) 67.69%.
Report is 27 commits behind head on dev-2.x.

Files Patch % Lines
...ner/standalone/configure/ConstructApplication.java 0.00% 3 Missing ⚠️
...ner/graph_builder/module/osm/OsmModuleBuilder.java 33.33% 2 Missing ⚠️
.../openstreetmap/tagmapping/ConstantSpeedMapper.java 0.00% 2 Missing ⚠️
...n/java/org/opentripplanner/standalone/OTPMain.java 0.00% 2 Missing ⚠️
...pplanner/standalone/configure/LoadApplication.java 0.00% 2 Missing ⚠️
...rvice/StreetLimitationParametersServiceModule.java 0.00% 2 Missing ⚠️
...rg/opentripplanner/graph_builder/GraphBuilder.java 0.00% 1 Missing ⚠️
..._builder/module/configure/GraphBuilderModules.java 0.00% 1 Missing ⚠️
...tripplanner/openstreetmap/tagmapping/UKMapper.java 0.00% 1 Missing ⚠️
...nner/openstreetmap/wayproperty/WayPropertySet.java 96.42% 0 Missing and 1 partial ⚠️
... and 2 more
Additional details and impacted files
@@              Coverage Diff              @@
##             dev-2.x    #5657      +/-   ##
=============================================
+ Coverage      67.68%   67.69%   +0.01%     
- Complexity     16361    16381      +20     
=============================================
  Files           1889     1893       +4     
  Lines          71785    71862      +77     
  Branches        7404     7410       +6     
=============================================
+ Hits           48586    48646      +60     
- Misses         20690    20708      +18     
+ Partials        2509     2508       -1     

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

@optionsome optionsome marked this pull request as ready for review February 8, 2024 13:28
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.

Other than the nullability issue I think this looks good.

Copy link
Member

@t2gran t2gran left a comment

Choose a reason for hiding this comment

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

There is a major problem with the solution to remove the car speed from here and creating a separate service/repository for this popperty just because the source is not the request or the configuration. The root of the problem is lack of separation "use of parameters" and "source of parameters". This PR illustrate some of the problems we get because the lack of separation of these two things.

Choosing between two evals I think letting the parameter stay where it is is the least confusing, I am sorry for the extra work. If you want @optionsome we can look at these together.

For the future we need to solve this issue, but doing the DI first will help. Example:

If the EuclideanRemainingWeightHeuristic was injected, and not created inside the GraphPathFinder, then the maxCarSpeed would not need to be passed into the GrpahPathFinder.

Comment on lines 30 to 32
props.setCarSpeed("highway=motorway", 33.33f); // = 120kph. Varies between 80 - 120 kph depending on road and season.
props.setCarSpeed("highway=motorway_link", 15); // = 54kph
props.setCarSpeed("highway=trunk", 27.27f); // 100kph
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 lot trailing comments on magic numbers in these files.

  • Our code conventions say comments should be ABOVE the line it comments on, trailing comments are not allowed.
  • Magic number should be replaced by constants. In this case I would create two classes: OsmMetricConstants and OsmImperialConstants with e.g. public static final float SPEED_80_KPH = 22.22f.

Is is NOT required to fix this in this PR since it existed in the code from before.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes I'm aware of this code style practice but didn't want to edit these files too much within this pr.

Comment on lines +55 to +65
public Float defaultCarSpeed;
/**
* The maximum automobile speed that can be defined through OSM speed limit tagging. Car speed
* defaults for different way types can be higher than this.
*/
public Float maxPossibleCarSpeed;
/**
* The maximum automobile speed that has been used. This can be used in heuristics later on to
* determine the minimum travel time.
*/
public float maxUsedCarSpeed = 0f;
Copy link
Member

Choose a reason for hiding this comment

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

public -> private

Copy link
Member Author

Choose a reason for hiding this comment

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

This whole class is a mess. I wasn't sure if the solution would have been to add getters/setters for all of these fields or continue on the bad path. I guess I could add the getters and setters.

Comment on lines +216 to +218
if (way.hasTag("maxspeed:motorcar")) {
speed = getMetersSecondFromSpeed(way.getTag("maxspeed:motorcar"));
}
Copy link
Member

Choose a reason for hiding this comment

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

Nice!

Comment on lines +611 to +612
props.setCarSpeed("highway=residential", 13.89f); // 50 km/h
props.setCarSpeed("highway=service", 13.89f); // 50 km/h
Copy link
Member

Choose a reason for hiding this comment

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

Thank you for fixing this. In Norwegian t = timen (hour)

public GraphPathFinder(@Nullable TraverseVisitor<State, Edge> traverseVisitor) {
this(traverseVisitor, null);
this(traverseVisitor, null, 40f);
Copy link
Member

Choose a reason for hiding this comment

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

40 is a magic number

Copy link
Member Author

Choose a reason for hiding this comment

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

This is used in a couple of places, I'm not sure where to put this default.

Comment on lines 12 to 13
@Singleton
public class StreetLimitationParameters implements Serializable {
Copy link
Member

Choose a reason for hiding this comment

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

@singleton on a Parameters class look a bit strange.

@optionsome
Copy link
Member Author

We went through the remaining concerts with @t2gran today. We decided to keep the existing data model/service structure and expand it in the future to include more stuff from the Graph class.

t2gran
t2gran previously approved these changes Feb 21, 2024
@optionsome
Copy link
Member Author

I forgot to test that the constant speed mapper works earlier and noticed a couple of issues that I have now fixed.

@optionsome optionsome merged commit 77d0c15 into opentripplanner:dev-2.x Feb 29, 2024
5 checks passed
@optionsome optionsome deleted the max-car-speed branch February 29, 2024 13:22
t2gran pushed a commit that referenced this pull request Feb 29, 2024
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 config change improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Graph wide max car speed should be determined during graph build
3 participants