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

Reduce edge count by merging ways with same tags #2822

Open
easbar opened this issue May 17, 2023 · 2 comments
Open

Reduce edge count by merging ways with same tags #2822

easbar opened this issue May 17, 2023 · 2 comments

Comments

@easbar
Copy link
Member

easbar commented May 17, 2023

Sometimes roads are split into multiple OSM ways for no real reason and with our current approach this means our routing graph will contain more edges. A possible optimization would be merging such neighboring ways if the corresponding tags are identical (or at least the subset of relevant tags is identical).

It is quite easy to count the OSM nodes that only connect two ways (rather than being 'real' junctions), see here: 10d1a19

For Germany I got:

end: 3640291, junction: 12725162, connection: 2901432, intermediate: 52455693, all: 71722578

which means there are 2.9mio 'connection nodes', which only connect two OSM ways. If we merged all these nodes we would save 2.9mio edges, so 11% of the total 25.9mio edges we create for this map (no ignored highways). But of course in reality we won't be able to merge them all, because not all of them are connecting ways with identical tags and sometimes they might use the same tags but we still don't really want to merge them, for example at country borders.

If we could merge every second connection node we would be able to save around 5% of edges (but not sure if this is realistic). We would also lose the ability to assign a single OSM way ID to each edge. Overall I don't think this optimization will be really worth the effort.

@otbutz
Copy link
Contributor

otbutz commented May 17, 2023

for no real reason

The OSM API has a limit of 2000 nodes per way. The number of ways with +1.9k nodes isn't that low:

https://tools.geofabrik.de/osmi/?view=geometry&lon=21.28869&lat=43.03894&zoom=4&baselayer=OSM%20Carto%20(OSMF)&overlays=long_ways

In addition, most mappers avoid large ways because editors like iD do not handle them well.

That said, both of these problems don't affect GraphHopper. We could even solve the missing antimeridian support that way. see #2745

@easbar
Copy link
Member Author

easbar commented May 17, 2023

Ok thanks the node limit is of course a valid reason to split the way.

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

No branches or pull requests

2 participants