Typical Overpass query on my private instance

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Typical Overpass query on my private instance

Igor Brejc
I use my private instance to fetch the data for map rendering, so I'm only interested in features that can be rendered on a given map scale (highways, places, roads, water bodies etc.). I do need to cover large(r) areas, however, and with my instance,I'm currently only able to cover smaller countries (like Austria or Netherlands), but on Germany Overpass fails with a cryptic error message (I wrote about that a few days ago).

Here's a sample query for Austria (and my notes are below):

<osm-script timeout="5000" element-limit="3221225472">
  <union>
    <query type="relation" into="boundary">
      <bbox-query s="45.8011448171477" w="7.66442092363624" n="49.677755113755" e="18.6829971975442" />
      <has-kv k="type" v="boundary" />
      <has-kv k="boundary" v="administrative" />
    </query>
    <recurse from="boundary" type="relation-way" into="boundary" />
    <recurse from="boundary" type="way-node" into="boundary" />
    <query type="way">
      <bbox-query s="45.8011448171477" w="7.66442092363624" n="49.677755113755" e="18.6829971975442" />
      <has-kv k="aeroway" v="runway" />
    </query>
    <query type="way">
      <bbox-query s="45.8011448171477" w="7.66442092363624" n="49.677755113755" e="18.6829971975442" />
      <has-kv k="railway" v="rail" />
    </query>
    <query type="way">
      <bbox-query s="45.8011448171477" w="7.66442092363624" n="49.677755113755" e="18.6829971975442" />
      <has-kv k="highway" regv="^(motorway|motorway_link|trunk|trunk_link|primary|secondary)$" />
    </query>
    <query type="way">
      <bbox-query s="45.8011448171477" w="7.66442092363624" n="49.677755113755" e="18.6829971975442" />
      <has-kv k="natural" regv="^(coastline|land|water)$" />
    </query>
    <query type="relation">
      <bbox-query s="45.8011448171477" w="7.66442092363624" n="49.677755113755" e="18.6829971975442" />
      <has-kv k="natural" regv="^(coastline|land|water)$" />
    </query>
    <query type="way">
      <bbox-query s="45.8011448171477" w="7.66442092363624" n="49.677755113755" e="18.6829971975442" />
      <has-kv k="landuse" v="reservoir" />
    </query>
    <query type="relation">
      <bbox-query s="45.8011448171477" w="7.66442092363624" n="49.677755113755" e="18.6829971975442" />
      <has-kv k="landuse" v="reservoir" />
    </query>
    <query type="way">
      <bbox-query s="45.8011448171477" w="7.66442092363624" n="49.677755113755" e="18.6829971975442" />
      <has-kv k="waterway" regv="^(canal|drain|river|riverbank)$" />
    </query>
    <query type="relation">
      <bbox-query s="45.8011448171477" w="7.66442092363624" n="49.677755113755" e="18.6829971975442" />
      <has-kv k="waterway" regv="^(canal|drain|river|riverbank)$" />
    </query>
  </union>
  <union>
    <item />
    <recurse type="down" />
  </union>
  <print mode="body" />
</osm-script>

  1. Initially, I didn't use 'regv' expressions to match several values for the same tag because I thought they would be slower than using separate 'v' queries - and I was wrong. Combining the queries using 'regv' saved me around 25% of query execution time.
  2. It would be even better if Overpass allowed a more complex 'or' expressions to be specified inside a single <query> element. Then I could combine several query elements (since they all use the same bbox) into one, like 'railway=rail OR  highway=^(motorway|motorway_link|trunk|trunk_link|primary|secondary)$' and presumably speed up the query even more.
  3. Would it be possible to parallelize things, so certain <query> elements could run on separate cores?
Igor