With OverPass API, I would like to make several different queries in a single one, and then keep the results separated by query in the output.
For example:
node( <some bounding box> )[amenity~"cafe"]->.my_cafes;
node( <some bounding box> )[amenity~"restaurant"]->.my_restaus;
.my_cafes out;
.my_restaus out;
In the XML output, is it possible to keep track of which sub-query a given result is answering to (i.e., "my_cafes" or "my_restaus")? This could avoid sending many API calls.
In my example, output resulting nodes can easily be filtered with something like tag[k=amenity,v=cafe]. But it's not always the case (let's imagine two similar requests, filtered in Overpass with two different around: clauses)
A similar question was already discussed on Github: https://github.com/drolbr/Overpass-API/issues/236
Short summary from the ticket:
Use the following workaround: simply put an out count; after each out; statement. This way you can find out where each query result ends and how many entries it includes.
Related
In an HTML document I have a large inline SVG object with groups bearing a variety of IDs (or none at all). I want to find all groups other than those whose IDs start with the letter sequences l0pzlo, l1pzloand l2pzlo. The task of finding just those IDs is easy
element.querySelectorAll("[id^=l0pzlo_],[id^=l1pzlo_],[id^=l2pzlo_]")
does the trick. However, I cannot work out how to get only those elements whose IDs DO NOT start with any of the three prefixes given above. I have attempted to use :notin a variety of different ways, e.g.
element.querySelectorAll(:not('[(id^=l0pzlo)]'))";
but nothing seems to be to the liking of the browser. How can I do this?
I think it would be more useful to leave my own answer here rather than just delete the question
element.querySelectorAll('*:not([id^=l0pzlo]):not([id^=l1pzlo]):not([id^=l2pzlo])');
works. Think of it as going about the task of filtering in a non-greedy way. First you get absolutely everything and then progressively filter out what you don't need with a sequence of one or more :nots
Using OverPass I am requesting all the ways and nodes in a specific area.
The documentation says : "The nodes defining the geometry of the way are enumerated in the correct order, and indicated only by reference using their unique identifier. These nodes must have been already defined separately with their coordinates."
But in the result I get, the definitions of some nodes are missing, as I get some nodes ID child of a way that I can't find in the nodes definition.
Here is my OverPass QL query :
[bbox:{{bbox}}];
(
node;
<;
);
out;
I am missing something ?
Thank you.
Strictly speaking, a solution based on the < (recurse up) statement does not meet your requirements. To find out why, we take a look a the Overpass QL documentation:
The recurse up standalone query is written as a single less than symbol, "<".
It takes an input set. It produces a result set. Its result set is
composed of:
all ways that have a node which appears in the input set; plus
all relations that have a node or way which appears in the input set; plus
all relations that have a way which appears in the result set
You will notice that your query also returns many relations, although in your question you mentioned you wanted only nodes and ways in your result.
A correct query would look as follows. Instead of using <, we're explicitly telling in QL that we only want ways for a set of nodes, and again, all nodes for a set of ways - and nothing else!
(
node({{bbox}});
way(bn);
node(w);
);
out meta;
(Btw: please forget about the Overpass language guide mentioned above. It is incomplete and not maintained at the moment).
Your query doesn't request all "ways and nodes". Instead it just requests nodes and performs a "recurse up" to get ways these nodes are part of. However for these ways you will only obtain the nodes from your initial query. You will need an additional "recurse down" to query for all other nodes these ways consist of:
[bbox:{{bbox}}];
(
node;
<;
);
out body;
>;
out;
Example: https://overpass-turbo.eu/s/FGj
I've built a KNIME workflow that helps me analyse (sales) data from numerous channels. In the past I used to export all orders manually and use an XSLX or CSV reader but I want to do it via WooCommerce's REST API to reduce manual labor.
I would like to be able to receive all orders up until now from a single query. So far, I only get as many as the # I fill in for &per_page=X. But if I fill in like 1000, it gives an error. This + my common sense give me the feeling I'm thinking the wrong way!
If it is not possible, is looping through all pages the second best thing?
I've managed to connect to the api via basic auth. The following query returns orders, but only 10:
I've tried increasing the number per_page but I do not think this is the right way to get all orders in one table.
https://XXXX.nl/wp-json/wc/v3/orders?consumer_key=XXXX&consumer_secret=XXXX
My current mindset would like to be able to receive all orders up until now from a single query. But it personally also feels like that this is not the common way to do it. Is looping through all pages the second best thing?
Thanks in advance for your responses. I am more of a data analist than a data engineer or scientist and I hope your answers will help me towards my goal of being more of a scientist :)
It's possible by passing params "per_page" with the request
per_page integer Maximum number of items to be returned in result set. Default is 10.
Try -1 as the value
https://woocommerce.github.io/woocommerce-rest-api-docs/?php#list-all-orders
I have a query which returns a number of ways. I want to find nodes matching certain criteria which appear within those ways. Note that the nodes I'm interested in do not form part of the way itself, but do appear within the bounds of the way. Also, the ways do not all have corresponding areas, so using the area search doesn't work in all cases.
I've got a minimal example which finds way 95677318, and I want to be able to find node 1552949334:
(
way({{bbox}})["man_made"="lighthouse"];
)->.searchArea;
/*doesn't work:*/
/*node(area.searchArea)["seamark:name"];*/
/*recur down and find node directly, just for the purpose of this question*/
(
.searchArea;>;
node({{bbox}})["seamark:name"];
);
out;
(Try it on https://overpass-turbo.eu/s/EpV)
This feature is not yet available as of release 0.7.55. In case there's no corresponding area available on the Overpass server, this kind of query is simply not feasible.
See https://github.com/drolbr/Overpass-API/issues/77 for details.
I'm trying to figure out what's the best solution to find all nodes of certain types around a given GPS-Location.
Let's say I want to get all cafes, pubs, restaurant and parks around a given point X.xx,Y.yy.
[out:json];(node[amenity][leisure](around:500,52.2740711,10.5222147););out;
This returns nothing because I think it searches for nodes that are both, amenity and leisure which is not possible.
[out:json];(node[amenity or leisure](around:500,52.2740711,10.5222147););out;
[out:json];(node[amenity,leisure](around:500,52.2740711,10.5222147););out;
[out:json];(node[amenity;leisure](around:500,52.2740711,10.5222147););out;
[out:json];(node[amenity|leisure](around:500,52.2740711,10.5222147););out;
[out:json];(node[amenity]|[leisure](around:500,52.2740711,10.5222147););out;
[out:json];(node[amenity],[leisure](around:500,52.2740711,10.5222147););out;
[out:json];(node[amenity];[leisure](around:500,52.2740711,10.5222147););out;
These solutions result in an error (400: Bad Request)
The only working solution I found is the following one which results in really long queries
[out:json];(node[amenity=cafe](around:500,52.2740711,10.5222147);node[leisure=park](around:500,52.2740711,10.5222147);node[amenity=pub](around:500,52.2740711,10.5222147);node[amenity=restaurant](around:500,52.2740711,10.5222147););out;
Isn't there an easier solution without multiple "around" statements?
EDIT:
Found This on which is a little bit shorter. But still multiple "around" statements.
[out:json];(node["leisure"~"park"](around:400,52.2784715,10.5249662);node["amenity"~"cafe|pub|restaurant"](around:400,52.2784715,10.5249662););out;
What you're probably looking for is regular expression support for keys (not only values).
Here's an example based on your query above:
[out:json];
node[~"^(amenity|leisure)$"~"."](around:500,52.2740711,10.5222147);
out;
NB: Since version 0.7.54 (released in Q1/2017) Overpass API also supports filter criteria with 'or' conditions. See this example on how to use this new (if: ) filter.