As title says, I would like to allow to create a route which will follow ways under construction.
I saw some PR’s that added ability to disable some restrictions but not really sure how to do it with constructions.
Do you mean conditional restrictions? By default they are now disabled for car:
Yes, I think construction
is part of those conditional restrictions, right?
I would like to disable it for bike profile, ideally only for map matching API.
It should be disabled by default for bike too. If you want construction (and seasonal) restrictions for the normal routing API you can use a second profile like bike_restricted
and for the map matching api you use the normal bike
profile:
- profiles:
- name: bike
custom_model_files: [bike.json]
- name: bike_restricted
custom_model_files: [bike_temporal.json, bike.json]
where bike_temporal.json is:
{
"priority": [
{ "if": "bike_temporal_access == NO", "multiply_by": "0" }
]
}
and you add bike_temporal_access
to the graph.encoded_values
in the config and also specify the path where to find the bike_temporal.json in the config file:
custom_models.directory: your/custom_models
Are you sure construction is disabled by default? It doesn’t route through way under construction in my case. Red circle marks road under construction in the below screenshot.
Maybe I’m confusing something. I’m pretty new to the routing topic.
And here is example with map matching. Red is original GPX track and blue is map matched. I’ve used bike profile but it routed using footways then it goes off the original track and then back to the footway.
I suspect it’s because that road construction.
This is a highway=construction which is not accessible: Way: Ogarna (240087697) | OpenStreetMap
To make something like this accessible you’d have to fork GH and add CONSTRUCTION to the list of possible values of RoadClass and then add it in a custom model as first statement that you explicitly allow this:
"priority": [
{ "if":"road_class == CONSTRUCTION", "multiply_by": "1" }
{ "else": ... }
]
Do you think this could go into the main branch? I guess I’m not the only one with this need. Also, Valhalla allows for it
Why should we allow routing through highway=construction ? What is your use case?
Also, Valhalla allows for it
it does not seem to allow it: OpenStreetMap
It’s not enabled by default https://github.com/valhalla/valhalla/pull/3455
I’m working on a website which presents cycling routes - Trasy i szlaki rowerowe | Velomapa (it’s Polish only).
I would like to match my tracks to match OSM routes, get surface attributes and elevations.
This is more or less static content meant just for presenting the cycling routes.
So if road is under construction, I would still like to match and follow it to maintain original track geometry.
Thanks! Makes sense.
We do not reject construction initially, but we reject it in all access parsers. So if you add CONSTRUCTION to RoadClass.java and use a custom model like:
{
"priority": [
{ "if": "road_class == CONSTRUCTION", "multiply_by": "1" },
{ "else_if": "car_access", "multiply_by": "1" },
{ "else": "", "multiply_by": "0" }
],
"speed": [
{ "if": "true", "limit_to": "car_average_speed" }
]
}
it will work. I just tried it:
You can create an issue about this and if there are more people in the need of this we’ll consider adding it.
But oneway restrictions will be ignored.
Also note that access restrictions will be still considered! So if there is a tagging like this: Way: A 100 (1199454112) | OpenStreetMap for construction it still won’t work.
Awesome. I’ll open issue then.
Would it be possible to also ignore access tag in similar manner as construction?
Not yet so simple as e.g. car_access
it is currently still an “aggregated” encoded value, i.e. multiple OSM tags influence its boolean value (oneway, roundabout, access, motorcar, vehicle, …).
Thanks for the clarification.
I was trying to add CONSTRUCTION locally but probably I missed something.
I’ve added it to the RoadClass, updated bike.json profile and config-example.yml (COMMIT)
Then I removed graph-cache
and started server again.
(maps/?point=54.348697%2C18.64852&point=54.347606%2C18.652315&profile=bike&layer=OpenStreetMap)
Okey, now it works
I added "construction"
to allowed highways in BikeCommonAccessParser.java
and road_class
to graph.encoded_values:
{ “if”: “road_class == CONSTRUCTION”, “multiply_by”: “1” },
Ah, I see. The problem is that the other statements that follow will modify the priority even in case of road_class==CONSTRUCTION. But the problem is that you would need to nest the condition (will be possible soonish):
{
"priority":[
{ "if": "road_class == CONSTRUCTION", "multiply_by": "1" },
{ "else": "", "do": [
{ "if": "true", "multiply_by": "bike_priority" },
{ "if": "!bike_access && (!backward_bike_access || roundabout)", "multiply_by": "0" },
{ "else_if": "!bike_access && backward_bike_access", "multiply_by": "0.2" }
]
}
]
}
At the moment it would be a bit uglier (note the else_if in the 3rd statement):
{
"priority":[
{ "if": "road_class != CONSTRUCTION", "multiply_by": "bike_priority" },
{ "if": "road_class == CONSTRUCTION", "multiply_by": "1" },
{ "else_if": "!bike_access && (!backward_bike_access || roundabout)", "multiply_by": "0" },
{ "else_if": "!bike_access && backward_bike_access", "multiply_by": "0.2" }
]
}
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.