Hello,
I am working on a solution for displaying public transport routes and am using Overpass.
I would like to extract the coordinates of each route from a particular transport operator and store them in an array list according to direction/variation, and display this in my frontend.
For this, I initially used the following query:
[out:json][timeout:25];
rel["operator"="Operator"];
out body;
>;
out skel qt;
Unfortunately, this query also gives the coordinates of the platforms along with the bus stops and route coordinates, so I switched to the following query:
[out:json][timeout:25];
rel["operator"="Operator"]->.route;
(
way(r.route)[highway!="platform"][public_transport!="platform"];
node(r.route)["public_transport"="stop_position"];
);
out body;
>;
out skel qt;
This essentially provides all the data I need. (Information about the route, route coordinates, bus stop coordinates, variations)
For the most part, this looks nice and the route is displayed perfect.
However, I also have some routes where the order of the coordinates does not seem to be correct:
I can only imagine that the order of the coordinates is incorrect, or that some way coordinates are reversed in the list I get from Overpass. But how do I recognize this?
Additionally, I have noticed that each roundabout looks like a whole circle.
Here, I suspect that Overpass returns the entire roundabout as a way, which is why it is displayed this way. Is there an alternative solution for this?
Ultimately, I just want a list of coordinates for a route/direction and display them in my frontend. Using Google Maps, I want to determine distances/durations/… , but this is not possible if I can’t get the coordinates in the correct order or if I get the entire ring for roundabouts instead of the actual entrance and exit.
I appreciate any help!