Hi, I'm pretty new to OSM. I'm working on web application in WebGL, and I have 2 major questions:
Can you give me some hints? asked 13 Dec '16, 09:53 Treant aseerel4c26 ♦ |
The To look up the hierarchy starting from the street to the country try http://nominatim.openstreetmap.org/hierarchy.php?osmid=246291409&osmtype=W and you need to parse the links in the first line. Then for each type and id you have to do more lookups. Doing a forward search for "Łódź" is too risky as you might get the wrong place back. Searching by ids (and type N,W,R) is better. OSM data doesn't contain continents. The reverse search can include polygons: http://nominatim.openstreetmap.org/reverse?format=json&osm_id=1582777&osm_type=R&polygon_geojson=1 (for the polygon parameters see) https://wiki.openstreetmap.org/wiki/Nominatim#Parameters_2 State and country polygons can become large (several megabytes). In this case set &polygon_threshold to a value between 0 and 1 to simplify the polygon in the result. 0.1 is usually a good compromise. The public Nominatim service has a usage policy (https://wiki.openstreetmap.org/wiki/Nominatim_usage_policy). Both polygon search, especially with large polygons and the hierarchy lookup are "expensive" (take more server resources than usual queries). If you crawl whole countries you will get blocked. If you send requests too fast you will get blocked. If your goal is to create a website for (paying?) customers and require high availability real-time results you should setup your own Nominatim server. answered 14 Dec '16, 17:23 mtmail |
cross-posted: https://gis.stackexchange.com/questions/221219/proper-query-of-osm-apis
Can you give examples of the Nominatim queries/URLs you're currently using?
@mtmail
I'm starting with osm_id and lonlat
Getting city name -> from osm_id and lonlat: http://nominatim.openstreetmap.org/reverse?format=json&lat=51.7728321&lon=19.4528033&osm_id=246291409&accept-language=en
Getting relation -> from city name: https://nominatim.openstreetmap.org/search.php?city=Łódź&format=json
Getting polygon -> from relation http://polygons.openstreetmap.fr/get_geojson.py?id=1582777
I only have osm_id and lonlat available and I must query for city, relation, country, continent and so on. Can I do it with one url?
Cross-posted again https://forum.openstreetmap.org/viewtopic.php?pid=622337#p622337 .