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
Conversation
src/main/java/org/opentripplanner/street/model/StreetLimitationParametersServiceModule.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opentripplanner/openstreetmap/tagmapping/FinlandMapper.java
Show resolved
Hide resolved
src/main/java/org/opentripplanner/graph_builder/module/osm/OsmModule.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opentripplanner/graph_builder/module/osm/OsmModuleBuilder.java
Outdated
Show resolved
Hide resolved
src/test/java/org/opentripplanner/graph_builder/module/osm/OsmModuleTest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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.
There was a problem hiding this 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
.
src/main/java/org/opentripplanner/graph_builder/module/osm/OsmModule.java
Show resolved
Hide resolved
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 |
There was a problem hiding this comment.
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
andOsmImperialConstants
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.
There was a problem hiding this comment.
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.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public
-> private
There was a problem hiding this comment.
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.
if (way.hasTag("maxspeed:motorcar")) { | ||
speed = getMetersSecondFromSpeed(way.getTag("maxspeed:motorcar")); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
props.setCarSpeed("highway=residential", 13.89f); // 50 km/h | ||
props.setCarSpeed("highway=service", 13.89f); // 50 km/h |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
@Singleton | ||
public class StreetLimitationParameters implements Serializable { |
There was a problem hiding this comment.
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.
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. |
65cbff9
I forgot to test that the constant speed mapper works earlier and noticed a couple of issues that I have now fixed. |
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