I'm doing routing on android using OpenStreetMap. The routing is working well. But the problem is that I do not know how to use the individual points of the user. I use osm2po to convert the OSM data to a routable graph. At the moment I'm finding the nearest routing point of the user individual selected point. But this is not a satisfying solution. Because it can happen that the user is selecting the middle of the street, but in the most cases the next routing point is at the end of the street. So it can happen that the end point is at the one side or on the other side.

What I tried?

First I tried to connect the routed start/end point with the selected individual point. But that provides sometimes routes where the user has to go back.

Second I tried to calculate the distance from the second last point to the last point and to the individual selected point. This works for some examples well, but not for all. So the problem is that the Geom_Way does not represent the line with points in a defined distance. So I thought it is like this start point o---x---x---x---o dest point. Where o are start/dest point and x middle points. But this is only available by curved lines. Straight lines have only o----------o a start and a destination point. Therefore the second last point in the routed point list can be far away and I can get the following construct: enter image description here I remove the coordinates as long as the distance from the last point is shorter to the destination point as to the second last point. But this can cause that all point will be removed. Otherwise if I do it only once, than I run in the cases that maybe to less points will be removed and therefore the result do not correspond to that what I want. So it is at moment a bit luck to get right result.

Is there any possibility to make a routing from an individual point to an individual point by using OSM? I don't want to use neither pgrouting nor storing of routes in the database. It is classically routing: User selects two points and the software is delivering the way from start node to the destination node.

EDIT: Maybe I calculate the distance wrong. I use UTMCoordinates and not Lat/Long. The distance will be calculated by using the Euclidean distance and I calculate the difference of lat/long from the first two coordinates.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.