[OSM-talk-be] Overpass API

Jo winfixit at gmail.com
Mon Dec 26 22:32:33 UTC 2011


I discovered an extremely fast way to fetch exactly the data one needs out
of the OSM DB:

An example:

<osm-script timeout="7200" element-limit="9073741824">
  <query type="relation">
    <has-kv k="type" v="network"/>
    <has-kv k="network" v="rcn"/>
    <has-kv k="name" v="Limburg"/>
  </query>


    <union>
      <item/>
      <recurse  from="routerelation" type="relation-node"
into="routerelationsnodes"/>
      <recurse type="relation-relation" into="routerelations"/>
      <recurse from="routerelations" type="relation-way"
into="routerelationways"/>
      <recurse from="routerelationways" type="way-node"
into="routerelationwaysnodes"/>
      <recurse from="routerelationwaysnodes" type="node-way"
into="parentways"/>
      <recurse from="parentways" type="way-node" into="parentwaysnodes"/>
      <recurse from="parentways" type="way-relation"
into="parentwaysrelations"/>
    </union>


  <print mode="meta"/>
</osm-script>

This can be entered at:

http://www.overpass-api.de/query_form.html
And the result is an .osm file with a skeleton of all the rcn routes in
that network. This works a whole lot better than the APIand is an order of
magnitude faster than querying the normal API with JOSM.

Maybe it's useful for somebody else as well,

Jo

Another (simpler) example is this one:

<osm-script timeout="7200" element-limit="9073741824">
  <query type="node">
    <has-kv k="rcn_ref"/>
  </query>
    <union>
      <item/>
      <recurse type="node-relation"/>
    </union>

  <print mode="meta"/>
</osm-script>

(Worldwide, there is a way to declare a bounding box or a contour way or
relation, but I didn't find out how yet)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/talk-be/attachments/20111226/bcac086d/attachment.htm>


More information about the Talk-be mailing list