My main target is to get the sinuosity of the root: straights paths, curves radius and curves angles and lengths.
Using Graphhopper Directions API I’m facing an issue that doesn’t satisfy my customer: the polyline returned by GHRequest in GHResponse is too much rough and imprecise.
I’m facing very often these problems:
sometimes the polyline comes out of the street borders i.e. it doesn’t follow the actual line of the street.
curves are represented by too few segments. That doesn’t allow me to measure accurately the curve radius
on long straight paths (more than 100mt), sometimes the polyline reports curves that don’t actually exist.
Do you have some suggestions to get a more precise polyline?
To get my target the polyline should be more accurate.
Do you have some suggestions to get that in a more precise way?
The polyline should be very precise. E.g. look here
Keep in mind that it is important to have up-to-date maps as we update every 1 or 2 days. Also you can try to use the undocumented parameter &wayPointMaxDistance=0.5 and see if this improves the situation.
Do you have examples for these issues either via image or GraphHopper Maps link?
Then, in your API (i’m working on iOS) I see:
/** @brief This parameter specifies how to reduce points via douglas peucker while OSM import.
Higher value means more details, unit is meter. Default is 1. Disable via 0.
*/
here you can see a long and large curve with too few points:
The points are probably fewer than the original OSM nodes but not much precision is lost (?) as we remove only points if we can keep the precision within 1m boundary.
Here you can see a polyline that goes out of street borders:
So are you sure you have the precision problem in real world? What exactly is your use case?
Hmmh, I think the documentation is incorrect, but I might be wrong. Please just try and let me know
also keep in mind that you can (or have to) disable simplification for routing too in your case
but they are also against the actual street path.
In real world? But did you double check that the OSM data is according to real world? I mean we reduce really only a few points within the 1m limit and I would find it strange that a big error is added (but I might be wrong here). Again, your use case would be interesting
BTW: So, you are not working with the Directions API? Then I’ll move then to core->mobile
Many thanks @karussell
I’m working with both web directions API and mobile API
Let me try with simplification disabled and with 0.5 as you suggested.
In my case I see that the polyline I get from Directions API often describes curves and lines that are different from the actual curves and straight lines.
But what exactly does mean WayPointMaxDistance?
in the first link I sent before I see a large curve with distances longer that 1m
OSM stores nodes as they were mapped but often the number of them is too much and does not add precision. Therefor we remove some of them but only if they are within WayPointMaxDistance=1m
I thought a bit about this issue and I still think that 1m should be more than enough (except there is a bug) as most ways are >3m width itself. Also you should consider that the OSM data itself can have offsets or inaccuracy, maybe compare with the Aerial view instead?
Checking your examples with the underlying data, one can see that the Graphhopper polyline points are at the very same position as the nodes that define the ways. What you get is as good as it gets. Graphhopper gives the information back it has and does not add anything to it. (Which I would expect)
If you want a smoother line, you have to interpolate the segments by fitting a spline through the points.
The same way as all the map renderer do it.
Many Thanks, @PassRacer and @karussell.
I understood the real problem now with your help. on some routes, OSM data doesn’t have enough precision to comply with what my customer want. I tried also with other directions api and the precision is similar or worse than graphhopper.
Using spline seems a good suggestion. Do you have an example?
I have a question: using spline may I introduce paths that doesn’t exist?
OSM data doesn’t have enough precision to comply with what my customer want.
Again: I still believe this is already very precise and what you are looking for might be the ‘smoothing’ … but without knowing what you try to do we cannot suggest any meaningful
Many thanks @karussell,
I agree with you, OSM is precise but I need to smooth the polyline to get more points in order to have a final polyline that approximate better the real route.
I’m going to try with a spline using the web Directions API.
I’ll let you know.
Hi @karussell,
I’m trying to smooth the path by using a spline.
My idea is the following:
get the set of coordinates of the polyline from Directions API
set a spline to get more points by using interpolation
convert the new set of points into a polyline
I know how to get a spline by a given array of points on a 2D space, but I don’t understand how to get a spline from a path formed by a set of geo coordinates like the one I get from Directions API.
You said that this is similar to what navigators do to get smooth paths.
Do you have some suggestions?