Open pankus opened 2 years ago
@pankus, If you take a look at official Nominatim API page https://nominatim.org/release-docs/latest/api/Search/#language-of-results, you can find this line: accept-language=<browser language string>
. According to library source code, Nominatim.query()
accepts **kwargs
which are connected with request parameters params = kwargs['params'] if 'params' in kwargs else {}
allowing you to pass original API parameters. So, you can do something like this:
from OSMPythonTools.nominatim import Nominatim
nominatim = Nominatim()
loc = nominatim.query("United Arab Emirates", params = {'accept-language':'en'})
print(loc.displayName())
# United Arab Emirates
Without params = {'accept-language':'en'}
it returns it's local language variant الإمارات العربية المتحد
In your case of reverse search, it will also try to return attributes in the desired language (if they exist in OSM database) for methods like loc.address()
.
Maybe I didn't understand how to do it, but it would be very useful to be able to pass a language-related parameter in Nominatim. Something similar to:
loc = nominatim.query(*coordinates, reverse=True, wkt=True, language='en' )