I want to find the old name of the city. So, using Nominatim API I just execute https://nominatim.openstreetmap.org/search?#?city=Kyiv&state=Kyiv&country=Ukraine&format=json&namedetails=1 And have a list of city's names. But I can't figure out how to execute this query from the database. I can write something like: SELECT name FROM placex WHERE OSM_ID='XXXXX' But to do it I need to know the OSM_id of the city. So, my question is How to find old names (or at least osm_id) of the city if I have city_name, state and country? asked 18 Aug '20, 14:30 MariiaZav |
Searching for city use the API documented in https://nominatim.org/release-docs/latest/api/Search/ saint petersburg, russia https://nominatim.openstreetmap.org/search.php?q=saint%20petersburg%2C%20russia&format=jsonv2 or structured, though many big cities are also states which makes it harder for a computer to differentiate https://nominatim.openstreetmap.org/search.php?city=saint%20petersburg&country=russia&format=jsonv2 If you have your own server replace the domain the IP address of your server or 'localhost'. Alternatively in your installation in the 'build' directory there's a script Add
answered 18 Aug '20, 23:07 mtmail Thank you for your answer. I have no problem to execute query from Nominatim API. The main problem is to run this query from the database. It has 784 tables and no descriptions of it. I can't figure out how to get osm_id of the city without using Nominatim API and just using database.
(19 Aug '20, 19:01)
MariiaZav
Adding &debug=1 to the URL https://nominatim.openstreetmap.org/search.php?city=saint%20petersburg&country=russia&format=jsonv2&debug=1 gives some output of the SQL that is run. In the background Nominatim uses several thousand lines of code to create and manage the SQL, finding places in a world-wide database is complex, especially finding the most relevant/important city when many have the same name. There's no single or few SQL queries one can run manually to get the same result.
(19 Aug '20, 20:49)
mtmail
Thank you so much! I didn't know about the debug mode. It helps me a lot!
(20 Aug '20, 08:23)
MariiaZav
|