-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Better escalator duration control: specific duration from OSM duration tag, default speed from build-config.json #6268
base: dev-2.x
Are you sure you want to change the base?
Conversation
Will be a draft until I have completed my full-program manual testing. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev-2.x #6268 +/- ##
=============================================
+ Coverage 69.71% 69.78% +0.06%
- Complexity 17697 17786 +89
=============================================
Files 2008 2017 +9
Lines 75836 76109 +273
Branches 7766 7792 +26
=============================================
+ Hits 52869 53111 +242
- Misses 20252 20287 +35
+ Partials 2715 2711 -4 ☔ View full report in Codecov by Sentry. |
application/src/main/java/org/opentripplanner/osm/model/OsmWay.java
Outdated
Show resolved
Hide resolved
application/src/main/java/org/opentripplanner/graph_builder/module/osm/EscalatorProcessor.java
Show resolved
Hide resolved
application/src/main/java/org/opentripplanner/osm/model/OsmWay.java
Outdated
Show resolved
Hide resolved
@@ -459,6 +460,16 @@ private static void mapStreetPreferences(NodeAdapter c, StreetPreferences.Builde | |||
.asInt(dftElevator.hopTime()) | |||
); | |||
}) | |||
.withEscalator(escalator -> { |
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.
If you add an example here: https://github.com/opentripplanner/OpenTripPlanner/blob/198ed907d1c5daf48349c205cdb443f0d0c7dfec/application/src/test/resources/standalone/config/router-config.json it will show up in the documentation.
application/src/main/java/org/opentripplanner/street/model/edge/EscalatorEdge.java
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.
This is a good PR but I've picked up on a few things.
...n/src/main/java/org/opentripplanner/routing/api/request/preference/EscalatorPreferences.java
Outdated
Show resolved
Hide resolved
...n/src/main/java/org/opentripplanner/routing/api/request/preference/EscalatorPreferences.java
Outdated
Show resolved
Hide resolved
...ion/src/main/java/org/opentripplanner/standalone/config/routerequest/RouteRequestConfig.java
Outdated
Show resolved
Hide resolved
utils/src/main/java/org/opentripplanner/utils/time/DurationUtils.java
Outdated
Show resolved
Hide resolved
* @return Duration | ||
* @throws DateTimeParseException on bad input | ||
*/ | ||
public static Duration parseClockDuration(String duration) { |
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.
I wonder if we need this or could we just use Duration.between(LocalTime.MIN, LocalTime.parse(duration))
? The parse
function probably accepts more formats that what is in theory allowed by OSM tagging.
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 also factories in the data API to create custom parsers - we do not need this.
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.
Joel also wanted to use Duration.between(LocalTime.MIN, LocalTime.parse(duration, DateTimeFormatter.ISO_LOCAL_TIME)), which I guess will probably work ok for durations smaller than 24 hours. But the format specified in https://wiki.openstreetmap.org/wiki/Key:duration does not limit the duration to under 24 hours, which is of course irrelevant for the escalator use case, but if we ever want to recycle the duration tag parsing code for other durations, it might become relevant. Let's go through this in today's meeting.
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.
But now I noticed that my implementation is against the spec anyway. It specifies that the duration is either mm, hh:mm or hh:mm:ss. Not hh, hh:mm or hh:mm:ss as I implemented it.
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.
Anyway, the fact that the supported formats are mm, hh:mm, and hh:mm:ss means that there has to be a place for the switch off the number of colons somewhere, even if the branches use some ready-made parser. I'll bring this up in the meeting as well.
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.
DateTimeFormatterBuilder will not work for this. It has the capability for expressing optional parts, so it could express hh(:mm(:ss)?)? but it cannot express (hh:)?mm(:ss)? where the existence of (:ss) implies the existence of (hh:). Even if it did, it would not be able to handle the cases where hours are greater than 23 or (if there is no hours part at all) minutes are greater than 59, which are both allowed by the spec and exist in OSM data. Durations are not LocalTimes after all, in parsing a LocalTime it makes sense and is correct that hours cannot be more than 23 or minutes more than 59, but in durations if you have capped the largest unit, it is reasonable for the amount of the largest unit to be as large as it needs to be.
I did rewrite the parsing to be quite explicit in what it accepts, so its correctness should be obvious.
While going through the comments, I noticed our ElevatorEdge implementation uses the OSM tag duration as an integer number of seconds, which is just wrong, compared to the duration tag spec. We couldn't even find an elevator tagged like this anywhere. |
case EscalatorEdge e -> List.of(kv("distance", e.getDistanceMeters())); | ||
case EscalatorEdge e -> List.of( | ||
kv("distance", e.getDistanceMeters()), | ||
kv("duration", e.getDuration()) |
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.
I don't think the underlying library works with Optional or Duration. You will have to convert to a string.
@@ -11,6 +11,7 @@ | |||
import java.util.Optional; | |||
import java.util.regex.Pattern; | |||
import java.util.stream.Collectors; | |||
import org.opentripplanner.utils.lang.StringUtils; |
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 can go.
Summary
Escalator durations tend too high. This PR makes it possible to use duration=hh:mm:ss tag in OSM data to set the duration accurately. It also makes it possible to set a configuration-wide speed in build-config.json at routingDefaults.escalatorSpeed.
Issue
None.
Unit tests
New case in EscalatorEdgeTest: if a duration is set for the edge, it takes precedence over a calculated duration.
Documentation
doc/user/RouteRequest.md has been autogenerated
Changelog
Definitely will be included in changelog.
Bumping the serialization version id
No