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

url for multiple tags

1

Hi! I'm using a php script to get node, way and rel from osm. This script use this url:

$url = 'http://overpass-api.de/api/interpreter?data=[out:json];(%20node%20[%22historic%22]%20('.$coo['min_lat'].','.$coo['min_lon'].','.$coo['max_lat'].','.$coo['max_lon'].');%20way%20[%22historic%22]%20('.$coo['min_lat'].','.$coo['min_lon'].','.$coo['max_lat'].','.$coo['max_lon'].');%20rel%20[%22historic%22]%20('.$coo['min_lat'].','.$coo['min_lon'].','.$coo['max_lat'].','.$coo['max_lon'].');%20);%20(._;%3E;);%20out;';

Now I would to add some tag and not only historic. Can I use a single url or have I to create a query for each tag I need? Thanks, Mk

asked 18 Jul '16, 11:18

bbg5ne's gravatar image

bbg5ne
26112
accept rate: 0%

edited 18 Jul '16, 11:24

scai's gravatar image

scai ♦
33.3k21309459


One Answer:

1

You can combine as many queries as you want in a union:

https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#Union

Here's an Overpass Turbo Wizard generated example:

http://overpass-turbo.eu/s/hmK

Also, note the "raw data directly from Overpass API" option in the Export dialog. You can use Overpass Turbo to test out queries and then quickly get the query as a url.

answered 18 Jul '16, 20:58

maxerickson's gravatar image

maxerickson
12.7k1083176
accept rate: 32%

mmm ... ok so my $url become

        $url = 'http://overpass-api.de/api/interpreter?data=[out:json];('.
        '%20node%20[%22historic%22]%20('.$coo['min_lat'].','.$coo['min_lon'].','.$coo['max_lat'].','.$coo['max_lon'].');'.
        '%20way%20[%22historic%22]%20('.$coo['min_lat'].','.$coo['min_lon'].','.$coo['max_lat'].','.$coo['max_lon'].');'.
        '%20rel%20[%22historic%22]%20('.$coo['min_lat'].','.$coo['min_lon'].','.$coo['max_lat'].','.$coo['max_lon'].');'.
        '%20node%20[%22church%22]%20('.$coo['min_lat'].','.$coo['min_lon'].','.$coo['max_lat'].','.$coo['max_lon'].');'.
        '%20way%20[%22church%22]%20('.$coo['min_lat'].','.$coo['min_lon'].','.$coo['max_lat'].','.$coo['max_lon'].');'.
        '%20rel%20[%22church%22]%20('.$coo['min_lat'].','.$coo['min_lon'].','.$coo['max_lat'].','.$coo['max_lon'].');'.
        '%20);%20(._;%3E;);%20out;';

now, is it possibile so specify ('.$coo['min_lat'].','.$coo['min_lon'].','.$coo['max_lat'].','.$coo['max_lon'].') only time, maybe at the end url? Thanks!

(19 Jul '16, 14:31) bbg5ne
1

Yes, that's called Global bounding box and described here.

(19 Jul '16, 19:20) mmd

Source code available on GitHub .