Repository navigation
Description
4df82f5 added a dedicated parser for hgv values but in the current state it doesn't cover all cases.
As the transportation modes follow a hierarchical approach, an access restriction such as motor_vehicle=no would also block trucks unless explicitly overridden by an accompanying hgv tag. A custommodel based on the roads vehicle would therefore need to evaluate both hgv and road_access EVs to make an appropriate decision.
Based on this, a check for fully closed road sections with the roads vehicle would look like the following:
"if": "road_access == NO || hgv == NO", "multiply_by": "0"This would get more complex if other access types need to be blocked as well, but the main problem with this approach is that road_access is in fact encoding access for a car:
graphhopper/core/src/main/java/com/graphhopper/routing/util/parsers/DefaultTagParserFactory.java
Lines 36 to 37 in b8a010e
| else if (name.equals(RoadAccess.KEY)) | |
| return new OSMRoadAccessParser(lookup.getEnumEncodedValue(RoadAccess.KEY, RoadAccess.class), OSMRoadAccessParser.toOSMRestrictions(TransportationMode.CAR)); |
A road tagged with motorcar:false+hgv=yes would falsely block a HGV vehicle.
Wouldn't it be better to reuse the code from the OSMRoadAccessParser instead? e.g.
else if (name.equals(RoadAccess.KEY))
return new OSMRoadAccessParser(lookup.getEnumEncodedValue(RoadAccess.KEY, RoadAccess.class), TransportationMode.CAR);
else if (name.equals(Hgv.KEY))
return new OSMRoadAccessParser(lookup.getEnumEncodedValue(Hgv.KEY, RoadAccess.class), TransportationMode.HGV);The only real problem would be the mismatch between the values of RoadAccess and Hgv.
RoadAccess:
- CUSTOMERS
- FORESTRY
- PRIVATE
- OTHER
Hgv:
- MISSING
- DESIGNATED
- DISCOURAGED
We would need to move the additional Hgv values into the RoadAccess enum. This would be according to how OSM is treating the values: https://wiki.openstreetmap.org/wiki/Key:access#List_of_possible_values
e.g:
RoadAccess:
- YES
- DESTINATION
- CUSTOMERS
- DELIVERY
- FORESTRY
- AGRICULTURAL
- PRIVATE
- DESIGNATED
- DISCOURAGED
- OTHER
- NO
Activity
otbutz commentedon Feb 7, 2023
The solution i'm currently experimenting with:
Without
car_accessi don't get any oneway handling. But this also blocks roads which are open for trucks and blocked for regular cars...karussell commentedon Feb 9, 2023
Do you have some real world examples for these cases?
otbutz commentedon Feb 9, 2023
An example from the OSM wiki:
access=no+hgv:designatedwhich describes the following restriction:Regular traffic including cars is prohibited but trucks should use this road.
otbutz commentedon Feb 9, 2023
But I agree that those combinations are not that common and
car_access+hgvis usually enough to cover 99% of the tagged roads.karussell commentedon Feb 20, 2023
Probably this is the same issue like #2460.
When we would have some BooleanEncodedValue like
hgv_accessit makes sense to include all the "car" and "(motor) vehicle" restrictions and it could also include hgv node tagging. But for thehgvenum it is unclear if "HGV == NO" should be 1:1 with the OSM tag or if it describes the "general hgv access". If the latter, then IMO it would then make sense when "HGV == YES" includes the other "yes" cases like HGV == DESIGNATED but this would be a bit confusing.IMO one "xy_access" EncodedValue per transportation mode like
hgv_accesswould be better and this is also simpler to use in a custom model (and car and motor vehicle restrictions would be included), but thehgvenum is still necessary to utilize the information of when HGV should be avoided or preferred and we have to accept that we partially duplicate the hgv=yes/no information (?)Now, regarding the oneway information. For #196 I thought a separate
bike_onewaywas necessary. Also forcar_accessit make sense to separate the oneway information from car_access. E.g. to model a "police car" and differentiate between reverse directions of oneways and roads that are normally inaccessible by cars. But forcar_accessthe backward compatibility would break and we would have to fix the #1835 before the split. A good solution that would still make this possible and avoid the problems could be to create a functionbackward(xy_access)and we can have the rather simple usage of justhgv_access. (And this would also avoid the question ifroundaboutshould be included inxy_onewayor not.)otbutz commentedon Feb 20, 2023
I still think that we should translate the raw access values into a simplified version for our routing:
PREFER->ALLOW->AVOID->BLOCKand let the user configure the translation using properties like we handle it with
block_privatekarussell commentedon Feb 20, 2023
Not sure what you mean as prefer/avoid has nothing to do with the access and we would still keep the hgv enum (designated/delivery/discouraged..) to implement avoid/prefer in a custom model.
block_private will go away sooner or later as this can be done with a custom model and
road_access == PRIVATEotbutz commentedon Feb 20, 2023
Why do we split
hgv_accessandhgvat all? Access is not a binary decision. We would encode the OSM taghgv=destinationashgv_access == trueand force the author of the custom model to considerhgv == DESTINATIONlater, because access to that section of the road is obviously different fromhgv == YES. This way a custom model has to evaluate the access values at runtime and ultimately use them to determine the priority of the road segment.So instead of encoding all access values into the graph and do this classification in the custom model, we could encode the result of this classification instead e.g:
karussell commentedon Feb 20, 2023
See my reasoning above: either we keep the meaning 1:1 to OSM or we have to ensure that YES also includes the other YES cases and this seems counter intuitive for an enum, so a boolean gives more clarity and we can keep the "hgv OSM tag" meaning.
Why is that a bad thing? At the end we'll have a custom model that makes such factors explicit and easily configurable.
That is exactly the plan :)
I don't think it will be slow or why do you think this is bad?
In the future we'll go exactly the opposite way: move things out into a custom model to make things easily customizable instead of mixing things into a single "compound" encoded value where we use static factors. This not only improves flexibility but also the reasoning about a route as every used encoded value can be easily viewed when debugging which is not possible with a "compound" encoded value.
But of course you can still create your own compound encoded values and use them in a custom model.
otbutz commentedon Feb 20, 2023
Sounds reasonable 👍 So we would keep the current
hgvEV and add aHgvAccessParserbased onAbstractAccessParser/CarAccessParser?karussell commentedon Feb 20, 2023
Probably a clean start might be better and maybe only rely on the "car_access" as EncodedValue? IMO this way the dependencies and differences are easier to identify and at some point we might resolve this inheritance structure for the existing parsers too.
karussell commentedon Oct 28, 2024
@otbutz can you have a look if the ModeAccessParser and the OSMRoadAccessParser from PR #3056 can satisfy this requirement?
otbutz commentedon Oct 29, 2024
Cases like
access=no+hgv:designatedare still not covered if I'm not mistaken? Would be nice if we could keep it closer to the other transportation modes and introducehgv_road_access.karussell commentedon Oct 29, 2024
You can use
hgvidentical to a theoreticalhgv_road_accessand the new OSMRoadAccessParser should work withhgvand also for cases likeaccess=no + hgv:designated.Maybe you can try it out if it works or if there are changes to OSMRoadAccessParser necessary?
otbutz commentedon Oct 29, 2024
#2744 (comment) is still not resolved IMHO.
karussell commentedon Oct 29, 2024
I thought you could do something like:
"if": "car_access == false && hgv != YES || hgv == NO", "multiply_by": "0"but the oneway restriction is important even for hgv==YES. So this does not work properly.
We could separate the
onewayat some point, but why not use another boolean, let's call ithgv_access, populated from ModeAccessParser?otbutz commentedon Oct 29, 2024
It's a separate transportation mode. Is there a reason to stick with the current HGV enum apart from breaking backwards compatibility? A HGVRoadAccess similar to FootRoadAccess would be a lot cleaner.
karussell commentedon Nov 1, 2024
Please note, there are two encoded values. One is a boolean
xy_access(in the future populated from ModeAccessParser) and the other is an enumxy_road_accesspopulated fromOSMRoadAccessParser. Both encoded values are required. Thexy_accessis still a "compound" encoded value from multiple attributes, but not something the PR changes.Now, the
hgvencoded value is already thehgv_road_access(except its name) and my question was if this in combination with the booleanhgv_accesspopulated from ModeAccessParser would still serve your needs. (If, how and when we changehgv->hgv_road_accessis also not something the PR changes)To better see the similarity you can try to populate
hgvvia OSMRoadAccessParser (instead of OSMHgvParser) via:new OSMRoadAccessParser<>(lookup.getEnumEncodedValue(Hgv.KEY, Hgv.class), OSMRoadAccessParser.toOSMRestrictions(TransportationMode.HGV), (readerWay, access) -> access, Hgv::find)Yes, this will ignore the ~900 conditional ways world-wide tagged with
hgv:conditional, but I doubt this is/was important.otbutz commentedon Nov 4, 2024
That sounds good. So we get rid of most of the car/hgv ambiguity, while still retaining the ability to handle oneways etc via
hgv_access.karussell commentedon Sep 16, 2026
I have now created hgv_road_access which is similar to road_access except that it replaces motorcar with hgv when evaluating the restrictions:
9710656
ddd5c9b
This is a first step to make merging xy_access with xy_road_access enums easier.
This was not true.
otbutz commentedon Sep 17, 2026
Awesome 🚀