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).
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.
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?
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.
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).