]> git.openstreetmap.org Git - nominatim.git/commitdiff
fix geocodejson address assignment
authorSarah Hoffmann <lonvia@denofr.de>
Fri, 26 May 2023 09:43:11 +0000 (11:43 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Fri, 26 May 2023 09:43:11 +0000 (11:43 +0200)
The categories should be assigned the address part with the
highest address rank not lowest.

nominatim/api/v1/format_json.py

index 0907c95526b25d4d9b47238dad008d2ad1bc54fa..99a3f182cb2a6b72cd76fe1e3b5d383457476183 100644 (file)
@@ -54,7 +54,10 @@ def _write_geocodejson_address(out: JsonWriter,
                 out.keyval('housenumber', line.local_name)
             elif (obj_place_id is None or obj_place_id != line.place_id) \
                  and line.rank_address >= 4 and line.rank_address < 28:
-                extra[GEOCODEJSON_RANKS[line.rank_address]] = line.local_name
+                rank_name = GEOCODEJSON_RANKS[line.rank_address]
+                if rank_name not in extra:
+                    extra[rank_name] = line.local_name
+
 
     for k, v in extra.items():
         out.keyval(k, v)