Skip to content

Move country handling into toll parser, change default from MISSING to NO - #3111

Merged
easbar merged 7 commits into
masterfrom
move_country_into_toll_parser
Feb 10, 2025
Merged

easbar merged 7 commits into
masterfrom
move_country_into_toll_parser

Conversation

@easbar

@easbar easbar commented Jan 29, 2025

Copy link
Copy Markdown
Member

Here I moved the country handling from the different country rules right into the toll parser. This makes the country rules for toll the default. We can probably do the same with the road access rules afterwards and remove the country rules altogether.

@easbar
easbar requested a review from karussell January 29, 2025 11:54
break;
}
case BIH, GBR, IRL, MDA, MKD, MNE, NOR, RUS: {
// todonow: missing remains missing?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Related: #2450 (comment)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The general idea is to modify the toll value if we can classify it based on the country/highway combination. There are a few countries that have a slightly more complicated set of rules that prevent us from coming up with a workable fallback. For those, we have to stick with MISSING to express "we don't know".

e.g.:

  • BIH, GBR, IRL, MKD, MNE, RUS -> toll only applies to selected parts of the road network
  • MDA, NOR -> toll only applies to foreign vehicles

@easbar easbar Jan 29, 2025 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Apparently there is no general toll in Great Britain, but only for certain roads, bridges and tunnels. like the longest motorway M6 (which strangely does not have a toll tag in OSM, for example here). Like for example a relatively short section of the M6 around Birmingham.

There is a general toll for HGV >= 12t for all M- and A-roads (A-roads seem to be tagged as trunks) source. Unfortunately, we do not have an enum value for >=12t vehicles only.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

You set Toll.NO for all roads in ALB, AND, FIN, FRO, GGY, GIB, IMN, ISL, JEY, MCO, MLT, SMR, UKR, VAT. Are these countries different to, say, some non-European countries, because for these we are (more) sure there is no toll? Or why did you use NO here, but MISSING in other cases. I understand that MISSING is meant to be used if our information is incomplete, but we like to allow users of the encoded value to distinguish missing information from explicit toll=no tags (or rules).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

There are a few countries that have a slightly more complicated set of rules that prevent us from coming up with a workable fallback. For those, we have to stick with MISSING to express "we don't know".

Do you have an example where replacing 'missing' with 'no' is really a problem? I think we could just use NO everywhere and where this isn't a good fit people could either improve OSM or add some more logic here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For those countries which generally don't collect any toll

You set Toll.NO for all roads in ALB, AND, FIN, FRO, GGY, GIB, IMN, ISL, JEY, MCO, MLT, SMR, UKR, VAT. Are these countries different to, say, some non-European countries, because for these we are (more) sure there is no toll?

Exactly. At least from my last research, the end result for those was that none of them collect classic road tolls.

RoadClass roadClass = RoadClass.find(readerWay.getTag("highway", ""));
if (roadClass == RoadClass.MOTORWAY || roadClass == RoadClass.TRUNK)
toll = Toll.ALL;
// todonow: why missing not no?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't understand why we set Toll.NO for all roads with missing toll tags for Albania, Andorra etc. (see above), but here we apply a default Toll.ALL for motorways+trunks while we keep Toll.MISSING for all the other roads. Related: #2450 (comment)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think NO should be a sensible fallback for other highway types.

if (roadClass == RoadClass.MOTORWAY || roadClass == RoadClass.TRUNK)
toll = Toll.ALL;
else
// todonow: really? every road is a toll road for hgv?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Is this actually the case? (same for Liechtenstein)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

At least from what I could find online: yes. The OBU seems to count every kilometer driven in Switzerland and Liechtenstein as toll.

https://www.eurotoll.eu/our-offer/switzerland/

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Apparently yes, vehicles >= 3.5t need to pay the 'Schwerlastabgabe' for every kilometer in the entire road network.


if (toll == Toll.MISSING) {
Country country = readerWay.getTag("country", Country.MISSING);
switch (country) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we move this to a dedicated method?

    Country country = readerWay.getTag("country", Country.MISSING);
    toll = applyCountryDefaults(country, toll);

This keeps the handleWayTags short and allows to get rid of all the break statements by using return instead.

@easbar easbar changed the title Move country handling into toll parser Move country handling into toll parser, change default from MISSING to NO Jan 29, 2025
@easbar easbar added this to the 11.0 milestone Jan 29, 2025
@easbar
easbar merged commit 3ad74bc into master Feb 10, 2025
@easbar
easbar deleted the move_country_into_toll_parser branch February 10, 2025 13:57
abdulwaheedsyed added a commit to abdulwaheedsyed/graphhopper that referenced this pull request Feb 11, 2025
karussell added a commit that referenced this pull request Dec 19, 2025

This branch was previously deployed

1 inactive deployment
benchmarks — ea572918 Deployed Jan 29, 2025 by easbar
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.

2 participants