NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

Hi OSM community,

I am new here and would be grateful if you could help me with the following.

Background

I am developing an android app that uses OSM maps. (Using Nutiteq SDK)

Question

I would like to know how to query for the bus services (relations) associated with a way id.
Example: With a way id, for example 157561015, realize that bus services 170, 171, 184, ... are associated with this way.

Suggestions

  1. I noticed that openstreetmap.org has the capability to perform such a query. See http://www.openstreetmap.org/way/157561015 . Scroll down the "side-bar" to see relations

  2. Convert OSM map data into a form that can be used to create a database. Is there an easy way of doing this? (for e.g. Spatialite?)

Thank you for reading.

Regards, David

asked 20 May '14, 10:51

davidleejy's gravatar image

davidleejy
24114
accept rate: 0%


ad 1.

The website obviously has access to the main database. For external apps that are not editors, we prefer (strongly) that you use the overpass-api. You can use Overpass turbo to test your queries. These are all the bus routes using way 157561015.

If later your app becomes wildly successful, we actually prefer you setup your own database. ;)

ad 2.

I think you answered your own question: spatialite osm raw

permanent link

answered 20 May '14, 13:03

cartinus's gravatar image

cartinus
7.0k1066105
accept rate: 27%

edited 20 May '14, 13:04

Thank you cartinus.

A "relation" node in the response has "member role" elements like so:

<relation id="1147131">

<member role="" ref="174286674" type="way"/>

<member role="" ref="175840093" type="way"/>

<member role="stop" ref="410484491" type="node"/>

<tag v="WOODLANDS REG INT" k="from"/>

<tag v="Svc 961" k="name"/>

<tag v="SMRT" k="network"/>

<tag v="961" k="ref"/>

<tag v="bus" k="route"/>

<tag v="LORONG 1 GEYLANG TER" k="to"/>

<tag v="route" k="type"/>

</relation>

Might you also know how to shorten the response by leaving out "member role" elements?

(23 May '14, 14:09) davidleejy

There is now a new feature in Overpass that gives you the relations without the members.

In stead of:

(
  way(157561015);
  <;
);
rel._[route=bus];
out;

write:

(
  way(157561015);
  <;
);
rel._[route=bus];
out tags;

The only change is the last word.

(16 Jun '14, 20:00) cartinus

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×147

question asked: 20 May '14, 10:51

question was seen: 2,879 times

last updated: 16 Jun '14, 20:00

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum