You are not logged in.

#1 2012-11-05 19:40:37

PeeWee32
Member
From: Leusden, NL
Registered: 2010-11-28
Posts: 1,160
Website

1 instead of 2 api calls. How?

With help from Lutz I've made a webmap with some bicycle related tags. I want to show all cycleways with tags moped=yes OR moped=designated. I have now done this by creating 2 calls (and also 2 checkboxes in the page) but I would like to combine this in 1 call/ 1 checkbox. Does anyone know how this can be done?

Current code:

 make_layer("http://overpass-api.de/api/interpreter?data=node[highway=cycleway][moped=designated](bbox);out+skel;(way[highway=cycleway][moped=designated](bbox);node(w););out+skel;", "#5FFFFF", name="Cycleway Moped=designated (lichtblauw)"),
 make_layer("http://overpass-api.de/api/interpreter?data=node[highway=cycleway][moped=yes](bbox);out+skel;(way[highway=cycleway][moped=yes](bbox);node(w););out+skel;", "#5FFFFF", name="Cycleway Moped=yes (lichtblauw)"),
 

Last edited by PeeWee32 (2012-11-05 19:41:07)

Offline

#2 2012-11-05 21:24:35

scai
Member
Registered: 2011-11-20
Posts: 159
Website

Re: 1 instead of 2 api calls. How?

For example by using the OverpassAPI.

Offline

#3 2012-11-06 17:12:09

stephan75
Member
Registered: 2008-05-28
Posts: 2,800

Re: 1 instead of 2 api calls. How?

But he IS already using OverpassAPI! ... or not?

Offline

#4 2012-11-06 18:13:27

PeeWee32
Member
From: Leusden, NL
Registered: 2010-11-28
Posts: 1,160
Website

Re: 1 instead of 2 api calls. How?

stephan75 wrote:

But he IS already using OverpassAPI! ... or not?

That's what I thought too. Any suggestions anyone or am I looking for the impossible?

Offline

#5 2012-11-07 09:32:36

Roland Olbricht
Member
Registered: 2011-11-22
Posts: 32

Re: 1 instead of 2 api calls. How?

Scai sent the link to the relevant point of documentation.

Please try

make_layer("http://overpass-api.de/api/interpreter?data=node[highway=cycleway][moped~"^designated$|^yes$"](bbox);out+skel;(way[highway=cycleway][moped~"^designated$|^yes$"](bbox);node(w););out+skel;", "#5FFFFF", name="Cycleway Moped=designated (lichtblauw)"),

This unifies both queries in a single query. In general, just move from [name=foo] or [name=bar] to [name~"^foo$|^bar$"]. The characters |^$ belong to the syntax of regular expressions and sum up to "or".

Offline

#6 2012-11-07 09:32:41

ligfietser
Member
Registered: 2008-10-09
Posts: 5,227
Website

Re: 1 instead of 2 api calls. How?

I've tried it now with [moped][moped!=no] which is working as workaround, but not exactly the same. I also tried [moped~yes|designated] but this doesn't work. Any ideas?

Edit: just saw Roland's posting, will try [moped~"^designated$|^yes$"]

Last edited by ligfietser (2012-11-07 09:40:26)

Offline

#7 2012-11-07 09:34:42

Roland Olbricht
Member
Registered: 2011-11-22
Posts: 32

Re: 1 instead of 2 api calls. How?

I'm sorry, I've forgotten to escape the double quotes:

make_layer("http://overpass-api.de/api/interpreter?data=node[highway=cycleway][moped~'^designated$|^yes$'](bbox);out+skel;(way[highway=cycleway][moped~'^designated$|^yes$'](bbox);node(w););out+skel;", "#5FFFFF", name="Cycleway Moped=designated (lichtblauw)"),

Offline

#8 2012-11-07 09:42:28

ligfietser
Member
Registered: 2008-10-09
Posts: 5,227
Website

Re: 1 instead of 2 api calls. How?

Roland Olbricht wrote:

I'm sorry, I've forgotten to escape the double quotes:

make_layer("http://overpass-api.de/api/interpreter?data=node[highway=cycleway][moped~'^designated$|^yes$'](bbox);out+skel;(way[highway=cycleway][moped~'^designated$|^yes$'](bbox);node(w););out+skel;", "#5FFFFF", name="Cycleway Moped=designated (lichtblauw)"),

Thanks Roland, it's working now. smile

Offline

#9 2012-11-07 19:12:20

PeeWee32
Member
From: Leusden, NL
Registered: 2010-11-28
Posts: 1,160
Website

Re: 1 instead of 2 api calls. How?

ligfietser wrote:

Thanks Roland, it's working now. smile

+1 wink

Offline

#10 2012-11-14 14:29:37

scai
Member
Registered: 2011-11-20
Posts: 159
Website

Re: 1 instead of 2 api calls. How?

stephan75 wrote:

But he IS already using OverpassAPI! ... or not?

That's true, I overlooked that smile

Offline

#11 2012-11-20 14:42:09

ligfietser
Member
Registered: 2008-10-09
Posts: 5,227
Website

Re: 1 instead of 2 api calls. How?

Roland Olbricht wrote:

This unifies both queries in a single query. In general, just move from [name=foo] or [name=bar] to [name~"^foo$|^bar$"]. The characters |^$ belong to the syntax of regular expressions and sum up to "or".

How can I use wildcards in the key value?

For instance in the  key [cycleway:*]=[value] see http://wiki.openstreetmap.org/wiki/Cycleway

* can be :right :left  or :both or :surface with a lot of other options after another :

Offline

Board footer

Powered by FluxBB