Country of way is wrong on road near border with curvature

Hello,

I have a road in BGR near ROU border which has ROU set as country. Initially thought is caused by countries.geojson and I used another one (Countries - GISCO - Eurostat 1m granularity). The problem is still there and is caused by the fact that GH is using an estimated center on the straight line (attached image).

image

I was wandering why aren’t you use the first or last point from the way to determine the country? If you agree with this changes I can make a PR with it.

Adding the way image:

image

We were just thinking about resolving the countries per edge instead of per way here: https://github.com/graphhopper/graphhopper/pull/2457.
But it looks like in your case this would not even help. Yes, I think I agree that using the start or end point would be better than using the center. But we probably need to resolve the countries per edge, not per way first?

Start/End is probably a bad idea as most OSM ways typically don’t cross borders but start or end there instead:

Example of the German-Polish border:

That compared with a low resolution for the border lines might yield even more weird results in border regions.

I’d rather use the point of the way which is nearest to the simplified mid:

Untitled-2021-11-05-1750

That is also true. Picking the start/end node we risk picking nodes that are right on the border (so possibly just on the wrong side of the border).

I’d rather use the point of the way which is nearest to the simplified mid:

Or maybe just any node along the way/edge?

Agree, start and end point may be on the border and in case the countries.geojson is not that granular it may result in wrong countries. Another options would be to pick up the middle (based on index) node. This can be exactly in the middle of the way or close to it (depending on the way structure).

Also, the flags for edge seems fine with me. I added my comment in the PR.

I think it is good enough to pick the point in the middle of the list as suggested by @cosmin.petrescu in https://github.com/graphhopper/graphhopper/pull/2457#discussion_r748023083

Although there is no guarantee that the points on a way are evenly distributed, this would prevent points on the border or points far from the way itself from being selected.

Btw our current border file is holding up pretty well, considering that the border is quite curved:

Yes, the borders seems fine. Probably we will use the one I suggested in the initial post because is more accurate even if the size is way bigger (around 33MB instead of 1.3MB).

This is now fixed in master, feel free to try. (https://github.com/graphhopper/graphhopper/pull/2472)

Thank you!

Powered by Discourse