Hi, I am sending this type of requests to Overpass API (http://overpass-turbo.eu/s/8p9):

[out:json][timeout:7]; (
out geom;

It retrieves ways around a certain set of lat/lon. And it works well as long as the number of results is reasonable. Otherwise, the timeout is reached quite easily. For this particular example, the limit seems to be 383 elements in the returned object.

I only need the end nodes's coordinates, i.e. elements.bounds, as well as tags.highway. In this context, do you have any idea I could optimize this request? Maybe only requesting certain elements of the default returned object if it's possible


asked 24 Mar '15, 20:59

agaudin's gravatar image

accept rate: 0%

edited 25 Mar '15, 21:08


What's the problem with enlarging the timeout? A 5 km radius is about 78.5 kmĀ². In a city, there's quite a lot of data in there.

The example you give seems to return about 2MB of data, which is too much for a 7 seconds timeout.

One thing I could propose is to avoid the regex. It's perfectly possible to put that query in a union instead of with a regex. But that still won't make it faster than 7 seconds. Also sorting the output per quadtile won't help enough.

(26 Mar '15, 13:15) Sanderd17

This code is meant to be part of an app and I don't want the user to wait for too long (<7 seconds). Yes, I am aware of the size returned, that's why I want to exclude unuseful elements. If need be, I'd be fine if the API returns all the elements found during the timeout instead of returning an error if not finished. Is that possible?

Thanks for your advice on the request using unions and quadtile sorting. I'm gonna try this.

(26 Mar '15, 17:17) agaudin

If your app can handle partial results, you could introduce several out geom; statements. Overpass turbo will only show the final result, but when using wget, you'll notice that the download will start almost immediately: http://overpass-turbo.eu/s/8r6 .

Another strategy could be to split your area into several smaller chunks and load them one by one. First results are available very early so your user won't have to wait for 10+ seconds for a first glimpse of a way.

Currently, there's no way to take the length of a way into account, so filtering by "short" or "long" ways is not possible.

permanent link

answered 28 Mar '15, 10:37

mmd's gravatar image

accept rate: 37%

Your answer
toggle preview

Follow this question

By Email:

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



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:


question asked: 24 Mar '15, 20:59

question was seen: 2,999 times

last updated: 28 Mar '15, 12:49

powered by OSQA