i am trying to lookup localized city name from gps position via nominatim reverse call, which works pretty well when user is in town. But when in the middle of nowhere (e.g. user is anchored with his yacht near the coast), nominatim return only the administrative region. example: https://nominatim.openstreetmap.org/reverse?format=jsonv2&lat=36.540548&lon=35.742612&zoom=18 the same is returned without reverse: https://nominatim.openstreetmap.org/search?format=jsonv2&q=36.540548,35.742612&zoom=18 What we need is the name of the nearest town. Any suggestions, experiences or hacks (e.g. town of next atm or something) to get that? asked 30 Oct '20, 14:54 qeepcologne |
Nominatim, being a reverse geocoder aiming to give you the address for your location, is the wrong tool for this job. Overpass is a slightly better tool; it cannot (to my knowledge) give you the "closest" of something but it can give you "nearby things" in a given radius - here, all cities and towns within 50km of the given position:
The task of identifying the closest of several results would still be yours to solve, and this solution would, unlike Nominatim, not tell you the administrative hierarchy (i.e. what county/state/country the city is in). The best solution would probably be a server that you run yourself, with OSM data imported into a PostGIS database and a small script that would run a nearest-neighbour search in the database and return only the closest place. This would have the added advantage of not relying on servers run by other people. answered 30 Oct '20, 19:31 Frederik Ramm ♦ thanks a lot, i tried with your query on overpass-turbo and results are looking ok. We run nominatim (via docker image) on our own server. I used the openstreemap.org url to demonstrate the query to work for everybody, because our server is not public. So i have to find out how to run/install nominatim and overpass on the same database via docker.
(16 Nov '20, 08:46)
qeepcologne
|