Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query times out #21

Closed
yahya-plotprojects opened this issue Aug 11, 2020 · 2 comments
Closed

Query times out #21

yahya-plotprojects opened this issue Aug 11, 2020 · 2 comments

Comments

@yahya-plotprojects
Copy link

When running the following query:

area(3600165475);
(
node["amenity"="fast_food"](area);
way["amenity"="fast_food"](area);
relation["amenity"="fast_food"](area);
);
out center;

I get this error:

Exception: [overpass] error in result (cache/overpass-0e7ebc0bbe8cd160b8389a3314ba688ba0f3c47f): [timeout:500][out:json];area(3600165475);
            (
            node["amenity"="fast_food"](area);
            way["amenity"="fast_food"](area);
            relation["amenity"="fast_food"](area);
            );
            out center;

During handling of the above exception, another exception occurred:

Exception: [overpass] runtime error: Query timed out in "print" at line 7 after 26 seconds.
    return search_areas(search_term_type, search_term, areas)
  File "/Users/work/Library/Application Support/JetBrains/PyCharmCE2020.1/scratches/scratch_4.py", line 181, in search_areas
    res = scrape_data(search_query)
  File "/Users/work/Library/Application Support/JetBrains/PyCharmCE2020.1/scratches/scratch_4.py", line 100, in scrape_data
    r = api.query(search_query, timeout=500)
  File "/Users/work/plotproject.scrips/lib/python3.7/site-packages/OSMPythonTools/internal/cacheObject.py", line 42, in query
    raise(Exception('[' + self._prefix + '] error in result (' + filename + '): ' + queryString))
Exception: [overpass] error in result (cache/overpass-0e7ebc0bbe8cd160b8389a3314ba688ba0f3c47f): [timeout:500][out:json];area(3600165475);
            (
            node["amenity"="fast_food"](area);
            way["amenity"="fast_food"](area);
            relation["amenity"="fast_food"](area);
            );
            out center;

I am using the following code where I set the timeout to be 500 seconds:

search_query = f"""(
            node["{search_term_type}"="{search_term}"]({search_box});
            way["{search_term_type}"="{search_term}"]({search_box});
            relation["{search_term_type}"="{search_term}"]({search_box});
            );
            out center;"""
api = Overpass()
r = api.query(search_query, timeout=500)

OSMPythonTools version is 0.2.8

However, when I run the same query in https://overpass-turbo.eu/ it works just fine. It also works fine on Postman

@EsbernJakobsen
Copy link
Contributor

You are not constructing your search query correctly. You are using a multiline f-string, whereas you need to use the overpassQueryBuilder as described in the docs. You can then pass the returned search_query string to the query() function.

@mocnik-science
Copy link
Owner

mocnik-science commented Sep 30, 2020

Yes, the answer provided is correct. (Thanks!!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants