osrm-backend icon indicating copy to clipboard operation
osrm-backend copied to clipboard

How to get turn restriction conditionals working

Open mzervens opened this issue 8 years ago • 5 comments

Hi, I am having trouble getting the turn restrictions working that have time condition restrictions.

Im running these commands:

osrm-extract merge.osm -p car_bkp.lua --parse-conditional-restrictions
osrm-partition merge.osrm 
osrm-customize merge.osrm --parse-conditionals-from-now $(date +%s) --time-zone-file /home/london.geojson
osrm-datastore merge.osrm
osrm-routed merge.osrm

And heres an example of restriction in the osm file:

<relation id="162131" version="6" timestamp="2015-09-01T08:22:48Z" changeset="0">
		<member type="way" ref="36834407" role="from"/>
		<member type="node" ref="26609133" role="via"/>
		<member type="way" ref="36834404" role="to"/>
		<tag k="type" v="restriction"/>
		<tag k="hour_on" v="07:00"/>
		<tag k="hour_off" v="22:00"/>
		<tag k="restriction" v="no_left_turn"/>
		<tag k="restriction:conditional" v="none @ (19:00-17:00)"/>
	</relation>

Im not sure about the time zone file, I created my own based on the example here: https://github.com/Project-OSRM/osrm-backend/blob/master/test/data/tz/win/london.geojson

The data im working with are in https://wiki.openstreetmap.org/wiki/WikiProject_Latvia

so I created the time zone file like so (a rectangle like polygon over Latvia):


{
"type": "FeatureCollection",

"features": [
{ "type": "Feature", 
"properties": { "tzid": "GMT0BST" }, 
"geometry": { "type": "Polygon", 
				"coordinates": [ [ [ 19.6196212, 58.2725539 ], [ 30.3905072, 58.1131632 ], [ 29.0095676, 55.1953941 ], [ 20.2997764, 55.4583059 ], [ 19.6196212, 58.2725539 ] ] ] } }
]
}

As I understand when the routing server is running (currently using the demo server) it looks at the server time and checks from which region the routing request comes from to determine if the restrictions are valid?

mzervens avatar Jun 01 '18 14:06 mzervens

Using described commands results that the turn restrictions that have conditional time restrictions are not present, but regular turn restrictions still work.

Checked this by using osrm frontend debug map

mzervens avatar Jun 06 '18 09:06 mzervens

As I understand when the routing server is running (currently using the demo server) it looks at the server time and checks from which region the routing request comes from to determine if the restrictions are valid?

The osrm-customize ... --parse-conditionals-from-now $(date +%s) ... command creates a road network that is valid for the point in time given by --parse-conditionals-from-now parameter, which in this case is the time of running the command.

Once that road network is created, it does not matter when the routing request comes in - the road network built by osrm-customize command is used and that is valid for that particular point in time only. Similarly, --time-zone-file is only used when building the road network, not at routing request time.

See also #5339, where it is said that:

Note that this encodes the time condition in your entire dataset - OSRM does not support supplying a start_time or any other API parameter to adjust conditions on-the-fly.

asaveljevs avatar Oct 30 '19 16:10 asaveljevs

Using described commands results that the turn restrictions that have conditional time restrictions are not present, but regular turn restrictions still work.

If you are using the following XML, then it says that there should be no restriction from 19:00 to 17:00, which is the majority of the day:

<relation id="162131" version="6" timestamp="2015-09-01T08:22:48Z" changeset="0">
    <member type="way" ref="36834407" role="from"/>
    <member type="node" ref="26609133" role="via"/>
    <member type="way" ref="36834404" role="to"/>
    <tag k="type" v="restriction"/>
    <tag k="hour_on" v="07:00"/>
    <tag k="hour_off" v="22:00"/>
    <tag k="restriction" v="no_left_turn"/>
    <tag k="restriction:conditional" v="none @ (19:00-17:00)"/>
</relation>

That may or may not explain why you did not see the conditional turn restriction and the discrepancy between hour_on, hour_off and restriction:conditional is suspicious. Could you please check your XML again and provide an example with a particular --parse-conditionals-from-now that fails to work?

asaveljevs avatar Oct 30 '19 16:10 asaveljevs

Thanks for the info, as I remember I experimented by providing different Unix timestams without desired effects but I guess I could try it again at some time

mzervens avatar Oct 30 '19 18:10 mzervens

This issue seems to be stale. It will be closed in 30 days if no further activity occurs.

github-actions[bot] avatar Jul 08 '24 21:07 github-actions[bot]