Can you tell me which library you used to decode the polyline? Encoding shouldn’t have any rounding issues as it’s basically just doing an integer out of your float coordinates by multiplying it with 10**5. Decoding however can have rounding problems, esp in Python, where rounding behaviour changed from v2.x to v3.x. So more likely it’s an issue with your decoder.
It could make a rounding error in encoding too though (thought it wouldn’t…), if you specify floats with a precision of > 5. So likely that’s where that error comes from. openelevationservice runs in Py3, which did some changes in rounding behaviour compared to Py2.
I think this is more on my side. I recently implemented a slightly different decoding lib into another project, which also allows you to encode precision > 5. Useful for openelevationservice too, so I might just add this today.
Oh, I see. Didn’t think you’d have done that to an ORS route. In fact, you can use elevation=true to get the elevation directly in the route response.
You’re right, it shouldn’t IMO. I first thought it might have smth to do with via points, i.e. more than 2 waypoints. I tried around a little, didn’t seem to be the case normally. However, I found a case where I observed the behavior loc[n] == loc[n-1]. Didn’t save the URL though (immediately tried another example…) and can’t reproduce anymore… What I saw was: when there’s via points, there can be the case of a middle leg that only routes from one point to the same point, i.e. duration & distance are zero for that leg. In that case it doubled the coordinate in the coordinate LineString. Hmpf, just can’t reproduce it…
Long story, short: @abhiank can you please share a (preferably small) example where you observed that behaviour? I.e. the query body/URL? Maybe the one with the 50 waypoints would be ideal.
Correct. Think I might just issue a warning in that case, instead of supporting things like that. After all, the endpoint is called line, where consecutive waypoints shouldn’t be the same inherently (I believe). Need the routing response to be fixed though…
Nope, I’m not. I’m indeed using the elevation = true flag. Its great to have the elevation data along with the points itself encoded in the same string.
The elevation requests I’m using to convert old routes with polylines received from Google’s API to be saved in the same format as the responses received from ORS with elevation data.
The polyline with 50 points which I’d shared in a previous reply and my original 2000 points are all polylines received from Google which seem to have consecutive points with the same value.
So, I’m not sure if that same behaviour/error exists in ORS directions api.
A question here - is it a loss or incorrect to simply send back the same points as received in the polyline, regardless of whether they have same consecutive points or not, in the elevation api?
Also, didnt understand -
doubled the coordinate in the coordinate LineString
A polyline could be encoded with random points too, right? (I’m not aware if that technically possible). In case it is, it wouldn’t be a line and would be just a collection of points needing elevation data…
Yes, it did, but like I said, didn’t document the exact query and was unable to reproduce. Not a biggie though generally. Seems to be very rare.
Right. The encoding is not spatially aware, you could throw any integers at it.
See my latest commit, I fixed the behavior returning less coordinates. Now, I wanna include polyline6 as well. And currently struggling with travis, which can take an indeterminable amount of time;) Should be online early next week still I hope.
Ok, just updated the servers with the latest version, including polyline6 support:) Careful though with polyline6, there’s no implementation I know which considers elevation. However, it’s not far away from GH’s encoding code. You can try to port my code, if you feel you’d like to have 6 decimal points precision on coordinates:
BTW, I found a bug in my previous decoding, which swapped X,Y… So, best re-do what you’ve done before.
i am using direction service. Please below code which service i am using it.
i need to show the directions please le me know.
var baseAddress = new Uri("https://api.openrouteservice.org");
var response = httpClient.PostAsync("/v2/directions/driving-car", content).Result;
responseData = await response.Content.ReadAsStringAsync();