This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

Overpass API : Sorted list of stations of a relation

0

Hi, I'm pretty new a OSM & the Overpass API.

I was looking for, how to retrieve a list a stations of a given relation.

Here is what came up with :

< id-query ref="2418275" type="relation" />
  < recurse type="relation-node" />  
< print/>

It works great but the station nodes are sorted by IDs in the XML. I was looking to get them sorted by the orientation (first station as first element, last station as last element).

Do you know how can I can achieve this ?

asked 02 Feb '14, 16:49

Kyro's gravatar image

Kyro
1216713
accept rate: 0%


One Answer:

3

Unfortunately, this is currently not possible with the Overpass API alone. What you can do is print the relation also and then sort the stations in a post-processing step.

answered 02 Feb '14, 17:11

tyr_asd's gravatar image

tyr_asd
1.2k51927
accept rate: 64%

1

Ok thanks, I went with a bash script to do this :

for i in curl 'http://api.openstreetmap.org/api/0.6/relation/2418275' | grep stop | awk '{print $3}' | cut -d '"' -f2; do curl http://api.openstreetmap.org/api/0.6/node/${i} ; done`

(03 Feb '14, 01:02) Kyro

Source code available on GitHub .