Hi, I'm looking for the most performant Overpass QL query to search for:
I tried (Country "de", location "Zugspitze"):
I noticed:
E.g. I tried to limit the results like this (to places and naturals):
My very simple use case: I want to give the user the possibility to search for a location and limit the results to certain place/natural types (like cities or mountains). It's a simple location search like we see on many mapping portals - and all of them are way faster than the above. How is this done with Overpass? Or is there a completely different way I'm missing? Thanks! asked 20 Sep '20, 19:15 Lukey78 |
One Answer:
Overpass is a very generic query engine and it emphasizes flexibility over performance. Since everyone is using the same Overpass instance and people have vastly different requirements, optimizing towards one use case would often make a different use case slower. You will get the best performance by importing OSM data into a PostGIS database and preprocessing/ indexing it according to your special use case. answered 20 Sep '20, 20:15 Frederik Ramm ♦ |
Ok, that makes sense. Thank you.
I created a location database with some additional tag info from a database I use for my map server (created with osm2pgsql) like this:
Now I just need to find a way to insert the country_code.
I could use the Nominatim API of Overpass to query the ISO3166-1 code for all coordinates with an is_in query based on areas of admin_level=2.
Or is there a better way to do that on the SQL/Postgis level?
A standard osm2pgsql load without
--hstore
will not give you a country code column on the country boundaries. You'd either have to add that to the config, or use--hstore
on import. Then, something likeshould add country codes to your
location
table.There's a little thing I neglected to say in my initial reply; some POIs that you might be interested in could be mapped as an area, not as a point. You might want to repeat your
INSERT INTO...
query withplanet_osm_polygon
as the source, this time usingst_centroid(way)
instead of justway
- this will then reduce the polygons to points and add them into your location table.That is very helpful, thank you for the fast and comprehensive answer!