osm-python-tools icon indicating copy to clipboard operation
osm-python-tools copied to clipboard

Allow iteration through NominatimResult json

Open LucaPizzagalli opened this issue 8 months ago • 0 comments

Nominatim.query returns a NominatimResult object. To my understanding there is no way of iterating through the query results stored in NominatimResult._json(besides calling NominatimResult.toJSON). Instead, the various methods displayName, address etc loop through the results and return the first valid value they find.

This is extremely misleading to me, as if I write something like

response = Nominatim().query(...)
print(response. displayName())
print(response. address())

name and address could in theory belong to two different osm object (e.g. first and second result in the json array).

What instead would be natural imho is to have Nominatim.query returning an iterable, so that I can inspect the various results individually.

Am I missing something?

LucaPizzagalli avatar Jun 08 '25 15:06 LucaPizzagalli