NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

I have two requests to get supermarkets within a country but both are slow and I'm asking myself if there is a way to improve them.

The first query is used to get supermarkets in France only, within a radius of 2 kilometers around the coordinates provided :

[out:json][timeout:25];

area(3602202162)->.searchArea;
(
  nwr["shop"="supermarket"](around:2000,48.8534,2.3488)(area.searchArea);
);

out;

(In this example, the coordinates correspond to the location of Paris).

For the second request, I want to obtain supermarkets in France only as well but sorted by brand and city. Currently, I use the query below to get all the supermarkets in a given city (but it's not limited to France). After my request, I sort the results by brand in my code.

[out:json][timeout:25];

area["name"="Paris"]->.RESULTS;
(
  nwr["shop"="supermarket"](area.RESULTS);
);

out;

Is it possible to improve both queries and make them faster? I'd also like to limit the second query to France, and why not, if it's more efficient sort the results by brand with the API and not with my code.

asked 13 Aug '19, 15:21

Arouraz's gravatar image

Arouraz
11112
accept rate: 0%

edited 14 Aug '19, 18:06

1

please note that supermarkets (and POIs in general) can also be mapped as ways or as relations. You have to use 'nwr' instead of 'node'

(14 Aug '19, 04:10) escada

I didn't know that, I updated the code, thank you!

(14 Aug '19, 18:08) Arouraz

The Default timeout value is 180. Setting it to 40 isn't required.

Depending on what you want to do with the output data, converting it to json is often unnecessary.

Quotation marks are only needed when a colon is in the expression.

Specifying France isn't required as the around statement limits the search area.

As there's only one line of code the containing brackets aren't required

nwr[shop=supermarket](around:2000,48.8534,2.3488);
out center;

There's quire a few areas with Paris as it's name. Best to specify a single one. I used this one https://www.openstreetmap.org/relation/7444, If you wish to use another relation, add its id to 3600000000 to get the area id. If you're only using using a single area once, then there's no need to store it in a variable (RESULTS).

area(id:3600007444);
nwr[shop=supermarket](area);
out center;

rel(id:7444);
out geom;

I think relation 2202162 is the incorrect one to use for mainland France:

https://overpass-turbo.eu/s/LDR

permanent link

answered 19 Aug '19, 18:04

DaveF's gravatar image

DaveF
3.3k8498133
accept rate: 16%

edited 19 Aug '19, 18:13

Follow this question

By Email:

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

By RSS:

Answers

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:

×228
×71
×58
×6

question asked: 13 Aug '19, 15:21

question was seen: 3,847 times

last updated: 19 Aug '19, 18:13

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum