Skip to content
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

Handle conditional access tags for date ranges #6984

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

ivarbrek
Copy link

@ivarbrek ivarbrek commented Jul 8, 2024

Issue

OSRM currently don't support conditional access tags. This is a very useful feature, especially in the context of roads being closed due to construction work or events.

Several people have requested this feature (#4231, #4300, #5801, #6706)

This PR takes a simple and lightweight approach to this problem, and handles it through the profile libs.

Note that we here only handle conditional time ranges, and require them to span for more than a week, using the format as described in the OSM wiki, e.g. motor_vehicle:conditional=no @ 2018 May 22-2018 Oct 7.

Tasklist

Requirements / Relations

Link any requirements here. Other pull requests this PR is based on?

@ivarbrek ivarbrek changed the title Handle conditional access tags for time ranges Handle conditional access tags for date ranges Jul 8, 2024
@SiarheiFedartsou
Copy link
Member

SiarheiFedartsou commented Jul 8, 2024

Thanks @ivarbrek! Could you please also extend tests? Feel free to ask for a help if it is not clear what to update…

@ivarbrek
Copy link
Author

ivarbrek commented Jul 9, 2024

I've tried to add a few test cases.

However, the tests seem to fail in the conan-linux-release step, and I'm struggling with proceeding from this point. I've downloaded the test logs, but don't find any clear direction from the logs of car/access.feature/.../309_car_conditional_restrictions.log. It's shutting down with SIGINT, but that's similar to all other log files I checked.

How do I proceed?

@SiarheiFedartsou
Copy link
Member

@ivarbrek this test works locally, right? Try to bump cache key version here

key: v4-test-${{ matrix.name }}-${{ github.sha }}
Sometimes it helps (you need to change v4 to v5 in 2 places there)

@ivarbrek ivarbrek force-pushed the ivarbrek/conditional_access branch from 6f59642 to fe02369 Compare July 12, 2024 08:10
@ivarbrek ivarbrek force-pushed the ivarbrek/conditional_access branch from fe02369 to 323e584 Compare July 12, 2024 08:14
@ivarbrek
Copy link
Author

Finally got the tests running locally 😊 And think it should be good now! Who can I tag for review @SiarheiFedartsou?

@DennisOSRM
Copy link
Collaborator

Happy to help with the review

| primary | yes | no @ 2002 Jan 7 - 2002 Feb 8 | x |
| primary | yes | no @ 2002 Jan 07 - 2002 Feb 08 | x |
| primary | yes | no @ 2090 Jan 7 - 2100 Feb 8 | x |
| primary | yes | no @ 2020 Jan 7 - 2050 Feb 8 | |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this test break in 24 years? 😉

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep 😄 I can extend the ranges so they don't break that soon, but I don't see any simple way to get completely rid of this problem.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, this can be solved doing something similar to this. I'll try to do that.

profiles/lib/access_conditional.lua Outdated Show resolved Hide resolved
profiles/lib/way_handlers.lua Outdated Show resolved Hide resolved

local start_date = parse_date(start_date_str)
local end_date = parse_date(end_date_str)
local current_date = os.time()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably needs some explanation that the extraction result depends on the date the extraction is run. Also, the date is not checked once but for each case if I am not mistaken. A little of folks run data updates over night and this may lead to edge cases.

Consider pulling the date once at the start of extraction. Also, consider implementing an override, ie. supporting the use case of extracting data ahead of time.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good points 👍 Note that the current suggestion excludes date ranges that span less than a week, partly to avoid weird cases like this. But that choice can be discussed I think.

Anyways, I'll see if I manage to implement an overrride option in a reasonable way.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found a relevant example here, will try to implement something similar 👍

@ivarbrek
Copy link
Author

ivarbrek commented Jul 30, 2024

I've looked into this a bit more now, and here's my summary/understanding of the current situation:

Some background I found out:
Conditional turn restrictions are already implemented at C++ level in the contract step (see test here). A good thing about this implementation is that the osrm-contract command supports arguments to set a custom time for the parsing conditional turn restrictions.

Next steps
Ideally we'd like the conditional access feature to be easily configurable, and here are the options as I see them:

  • Make a date parameter in car.lua called date_used_for_conditional_access. If nil, we use the current date. This option is simple to implement, given that I've already started implementing this in Lua. But on the other hand, it does not provide the best interface for custom configuration.
  • Implement in Lua, but make the date configurable through the osrm extract command. Requires some C++ coding and understanding of the code, so I would like some help if we decide to do this.
  • Implement this in the same manner as conditional turn restrictions (see above). I think this would be the best solution, but I'm not very familiar with C++, so would need a great amount of help on that.

What I don't like about the two latter options is that we duplicate the date configuration we already have in the contract step. Would be interested to hear your take on that and your suggested next steps @DennisOSRM and @SiarheiFedartsou.

@SiarheiFedartsou
Copy link
Member

@ivarbrek having it in osrm-customize/osrm-contract is indeed more preferable. In practice you would need to re-run this logic many times per day for the same dataset and such kind of things are done with these tools in OSRM(e.g. live traffic or conditional turn restrictions you mentioned are implemented using it)

@ivarbrek
Copy link
Author

Allright, so we are maybe just closing this then?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants