-
Notifications
You must be signed in to change notification settings - Fork 695
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
handling time dependent restrictions #3029
handling time dependent restrictions #3029
Conversation
7deec93
to
771669a
Compare
TEST_F(TimeDependentRestrictions, ActiveHourRestriction) { | ||
auto result = | ||
gurka::do_action(valhalla::Options::route, map, {"A", "F"}, "auto", | ||
{{"/date_time/type", "1"}, {"/date_time/value", "2021-04-02T14:00"}}); |
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.
Can we test it for other date_time
types (0,2 & 3)? These types invoke different routing algorithms so it'll be good to test the timed TRs here in case it breaks in one algo and not another.
You can use parametrized tests to pass each of the date_time
types.
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 any of them are failing, they can be flagged with a DISABLED_
prefix - at least then we'll get notice that they're not fixed yet, and we could add a CI step to try non-fatally running disabled tests :
https://google.github.io/googletest/advanced.html#temporarily-disabling-tests
@@ -401,6 +401,29 @@ TEST(TimeParsing, TestConditionalRestrictions) { | |||
TryConditionalRestrictions(conditions.at(x), 0, 1, 64, 3, 3, 0, 15, 0, 12, 1, 5, 17, 0); | |||
} | |||
} | |||
|
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.
Do we want to test wrongly formatted restriction...eg: end day is set without a corresponding start day (-Friday
or some such)?
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.
As for me it sounds as incorrect input. In case only day_on is specified, '-' is not added, day_on can be a sequence of days separated by a comma or a range with '-' inside. When only day_off is specified it is harder to understand what it means: working hours are from Monday/Sunday to X, or each day except X....?
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.
You're right, in that the input is incorrect. My point was that we should test that such inputs are ignored (looking at the code, we only set the condition when day_start is set, so just having a day_end should not enable the TR). So adding a test with incorrect input and showing that it does not take effect would be sufficient. Does that make sense?
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.
Yeah, added regular and gurka tests.
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.
@CuriOusQuOkka @mandeepsandhu if we have only the start day set then these restrictions should be tossed as the user entered the info incorrectly
771669a
to
310feb8
Compare
CHANGELOG.md
Outdated
@@ -52,6 +52,7 @@ | |||
* FIXED: Removed unexpected maneuvers at sharp bends [#2968](https://github.com/valhalla/valhalla/pull/2968) | |||
* FIXED: Remove large number formatting for non-US countries [#3015](https://github.com/valhalla/valhalla/pull/3015) | |||
* FIXED: Odin undefined behaviour: handle case when xedgeuse is not initialized [#3020](https://github.com/valhalla/valhalla/pull/3020) | |||
* FIXED: Fix time-dependent restrictions handling [#3029](https://github.com/valhalla/valhalla/pull/3029) |
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 too general description, I'd recommend to make it more specific
src/mjolnir/pbfgraphparser.cc
Outdated
if (!day_start.empty() && !day_end.empty()) { | ||
condition = day_start + '-' + day_end; | ||
} else if (!day_start.empty()) { | ||
condition = day_start; |
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.
so, just to clarify: if we have only day_start
it means that restriction applies only on this day ? or to the end of the week ?
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.
@genadz we can't only have just a day_start. if the restriction is only one day the day_start would be equal to the day_end.
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.
@gknisely from the code above it looks like just having day_start
is also a valid option. If both start & end are mandatory, then maybe we should just have if (!day_start.empty() && !day_end.empty()) { ...}
?
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.
@mandeepsandhu correct.
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.
We support start date that stays alone. It can be a sequence (like Monday,Wednesday,Thursday), a range (Monday-Friday), or just one day.
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.
}; | ||
gurka::map TimeDependentRestrictions::map = {}; | ||
|
||
// TODO: Does not work for date_time_type=2, returns additional AB edge. |
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.
it's because of this #2940 ; try to put start
and end
locations on the edges
D----B---1-A
| |
| |
E----C---2-F
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.
@genadz since date_time: 2
uses timedep-reverse, I wonder if the extra edge is being returned due to the bug @danpat found here.
@CuriOusQuOkka #2987 fixed a bug in timedep-reverse, which might fix the problem you're seeing. If so, you can re-enable date_time: 2
.
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.
Thanks @mandeepsandhu, it fixed the bug.
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.
85c6ad1
to
cc3af61
Compare
@CuriOusQuOkka do you want to remove the "Draft" tag from this PR (thats a signal to reviewers to start looking at the changes more closely)? |
0b9c86d
to
7a95f68
Compare
} | ||
|
||
TEST_F(TimeDependentTags, IgnoreDayOffOnlyRestriction) { | ||
tags day_off = { |
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 I understood correctly having only day_on
or hour_off/hour_on
also should be ignored. could you add all these cases ?
dd6690d
to
e0aec94
Compare
@CuriOusQuOkka I think we will be good after we test with https://github.com/valhalla/valhalla/blob/master/test_requests/timed_access_routes.txt and https://github.com/valhalla/valhalla/blob/master/test_requests/timed_conditional_routes.txt Let me know if there are any diffs. |
{"/date_time/value", "2021-04-02T23:00"}}); | ||
gurka::assert::raw::expect_path(result, {"AB", "BC", "CF"}); | ||
} | ||
|
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.
For completeness, should we also add a testcase with date_time before start of restriction?
5862a44
to
6a95605
Compare
Rad tests have passed |
6a95605
to
d435a0b
Compare
Issue
Valhalla missed conditional TR mapped according to previous tagging schema #441
Tasklist