-
Notifications
You must be signed in to change notification settings - Fork 661
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
Fixes bug with inverted time-restriction parsing #2167
Conversation
9a4ad47
to
54641da
Compare
@@ -145,7 +145,8 @@ class ComplexRestrictionBuilder : public baldr::ComplexRestriction { | |||
|
|||
/** | |||
* Set the dow mask. indicates days of week to apply the restriction | |||
* @param dow day of week - This is a mask (e.g., Mo-Fr = 62). | |||
* @param dow day of week - This is a mask with first day of week being sunday e.g., Mo-Fr = 62 | |||
* (111110). |
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 think showing 1 bit for each day of week here will be a tad more helpful (0111110
). Its easy to correlate days to bits then. Also, can we state which bit is Sunday, the MSB or LSB?
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 Updated
54641da
to
edd1398
Compare
Ah it's not testing the |
👍 Would love to get this merged so that I can pull into my branch! Thanks @purew |
(test) Logic still broken, working on fix
edd1398
to
f5a851a
Compare
const uint8_t end_day_dow, | ||
const uint64_t current_time, | ||
const date::time_zone* time_zone) { | ||
bool is_conditional_active(const bool type, |
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 renamed this function to better portray what it is actually doing.
test/CMakeLists.txt
Outdated
@@ -78,8 +78,9 @@ add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/test/data/whitelion_tiles_reverse/ | |||
add_custom_target(reversed_whitelion_tiles DEPENDS ${CMAKE_BINARY_DIR}/test/data/whitelion_tiles_reverse/2/000/814/309.gph) | |||
|
|||
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/test/data/roma_tiles/1/047/352.gph | |||
COMMAND ${VALHALLA_SOURCE_DIR}/scripts/valhalla_build_timezones 2>/dev/null > test/data/roma_tiles/tz.sqlite |
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.
Ensure we add timezone information to the Roma tiles
// <tag k="auto" v="yes"/> | ||
// <tag k="motor_vehicle:conditional" v="no @ (Mo-Sa 07:00-16:00)"/> | ||
// <tag k="pedestrian" v="no"/> | ||
// <tag k="pedestrian:conditional" v="yes @ (Mo-Sa 08:00-15: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.
I had to tweak the tags manually in the osm-file in order to get the permutations of test-cases I needed.
Conditionals dropped here for clarity.
cr->end_day_dow(), current_time, | ||
baldr::DateTime::get_tz_db().from_index(tz_index))) { | ||
LOGLN_WARN("Restricted: " + std::to_string(cr->begin_hrs())); | ||
// TODO Possibly a bug here. Shouldn't both kTimedDenied and kTimedAllowed |
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 may be a latent bug here. I haven't dug too closely but I would assume we should be handling both cases as is done in IsRestricted
here.
valhalla/sif/dynamiccost.h
Outdated
cr->begin_day_dow(), cr->end_week(), cr->end_month(), | ||
cr->end_day_dow(), current_time, | ||
baldr::DateTime::get_tz_db().from_index(tz_index))) { | ||
LOGLN_WARN("Restricted: " + std::to_string(cr->begin_hrs())); |
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.
TODO Remove stray debug log line.
f5a851a
to
f01cd63
Compare
Hmm there is some race condition in the tile building stage that occurs in CI but almost never locally... |
@@ -148,8 +148,6 @@ inline bool TimeDepForward::ExpandForwardInner(GraphReader& graphreader, | |||
const valhalla::Location& destination, | |||
std::pair<int32_t, float>& best_path) { | |||
|
|||
LOG_WARN(std::string("Expanding edge_id ") + std::to_string(meta.edge_id.id()) + " from node " + | |||
std::to_string(pred.endnode().id())); |
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.
oh man! that was unfortunate!
bdeb106
to
1c42234
Compare
I removed the changes to the |
${VALHALLA_SOURCE_DIR}/test/data/utrecht_netherlands.osm.pbf | ||
COMMAND ${CMAKE_BINARY_DIR}/valhalla_add_predicted_traffic | ||
--inline-config '{"mjolnir":{"tile_dir":"test/data/utrecht_tiles","concurrency":4,"logging":{"type":""}}}' | ||
--inline-config '{"mjolnir":{"tile_dir":"test/data/utrecht_tiles","concurrency":1,"logging":{"type":""}}}' |
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.
Was setting the concurrency to 1 needed to get the tests to build?
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.
Hmm This was a leftover from trying out all the various things.
That said, we are now building 5 different tile-sets on a full test-run and there are more pbf's being added in a different PR. 5 tilesets with 4 threads each results in 20 running threads.
It may just be best to do this single threaded.
|
||
void test_route_allowed(std::string costing_str, int16_t hour) { | ||
auto response = route_on_timerestricted(costing_str, hour); | ||
const auto& legs = response.trip().routes(0).legs(); |
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.
Looks like legs is unused here. Did you plan to add an assertion here like legs.size() == 1 ?
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.
Isn't this throwing a warning for unused variable? Or maybe it is and its getting lost in the noise?
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.
Good catch! 👍
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.
Pushed new code to test for legs.size() == 1
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.
Isn't this throwing a warning for unused variable? Or maybe it is and its getting lost in the noise?
We're not yet treating all warnings as errors unfortunately.
The time-restriction parsing had a logic bug that meant permission was allowed at restricted times and vice versa. This commit also adds a unit-test to verify this functionality.
to only do the generation work once
1c42234
to
353e82d
Compare
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.
👍
The time-restriction parsing had a logic bug that meant permission
was allowed at restricted times and vice versa.
This commit also adds a unit-test to verify this functionality.