instruction.getPoints().toLineString returns invalid line string

Hello, i’m trying to use GraphHopper (tried 0.13.0 as well as 1.0-pre38) with the OpenStreetMap reader to generate and process route instructions into simulated vehicle locations.

To do so, i’m generating routes and using the generated InstructionList to traverse the route vertices based on the individual points.
The problem here is that sometimes instruction.getPoints().toLineString() will generate seemingly invalid line strings, and there is no way to get the encapsulated points from ShallowImmutablePointList directly.

Unfortunately there is no documentation for the method, so i can’t know how it is intended to work, but for my use case i am implying that the distance encoded by instruction.getPoints().toLineString() should be at least somewhat similar to instruction.getDistance(), which is not the case.

Sometimes toLineString will return a line string of two coordinates which are equal (distance 0), while the encapsulated PointList in the original object actually contains >1k Points. However, the PointList’s size attribute is also 1, which doesn’t match the wrapped point list’s size. It appears that the list is a view on another PointList, but it still appears wrong to me that the distance doesn’t match and the point list contains just 2 points, which are the same point twice.

I don’t understand why this is happening and it seems to me like this is a bug.

I worked around my problem by using route.getPoints().toLineString() (which seems to always return correct lineStrings) instead of processing the instruction list, but the original problem should probably still be investigated.

Can you create a unit test that shows the wrong behaviour and what you would expect?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.