Remove configurable car speed and determine it in graph build - #5657
Conversation
leonardehrenfried
left a comment
There was a problem hiding this comment.
Other than the nullability issue I think this looks good.
t2gran
left a comment
There was a problem hiding this comment.
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.
| 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.
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:
OsmMetricConstantsandOsmImperialConstantswith 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.
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.
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")); | ||
| } |
| 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.
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.
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.
@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.speedfrom 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