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

How to optimize requests on ways?

0

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

http://overpass-api.de/api/interpreter?data=
[out:json][timeout:7]; (
    way(around:5000,48.9,2.4)
    ["highway"~"cycleway|footway|path|track"]
    ["access"!="private"]
);
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

Cheers

asked 24 Mar '15, 20:59

agaudin's gravatar image

agaudin
6113
accept rate: 0%

edited 25 Mar '15, 21:08

1

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

One Answer:

2

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.

answered 28 Mar '15, 10:37

mmd's gravatar image

mmd
5.7k15388
accept rate: 37%

Source code available on GitHub .