]> git.openstreetmap.org Git - nominatim.git/commitdiff
fix country handling in flex style
authorSarah Hoffmann <lonvia@denofr.de>
Thu, 10 Nov 2022 14:52:13 +0000 (15:52 +0100)
committerSarah Hoffmann <lonvia@denofr.de>
Thu, 10 Nov 2022 14:52:13 +0000 (15:52 +0100)
If the country tag does not match a 2-letter code, it needs to
be dropped.

settings/flex-base.lua
test/bdd/osm2pgsql/import/tags.feature

index d9462588479d5da2b23dcbd936d746b9eb6c432f..19f4e27bde554dd8e01cd2df2932cec7940a58e0 100644 (file)
@@ -331,8 +331,10 @@ function process_tags(o)
     end
 
     -- address keys
-    o:grab_address{match=function (k, v) return COUNTRY_TAGS(k, v) and #v == 2 end,
-                   out_key='country'}
+    o:grab_address{match=COUNTRY_TAGS, out_key='country'}
+    if o.address.country ~= nil and #o.address.country ~= 2 then
+        o.address['country'] = nil
+    end
     if o:grab_name{match=HOUSENAME_TAGS} > 0 then
         fallback = {'place', 'house'}
     end
index 83d7fe52e7d48309e825ff36e991c253e236fb33..1f6857f2c0ac3dcb5d740f49b90acdce546e45cc 100644 (file)
@@ -75,6 +75,7 @@ Feature: Tag evaluation
             n5003 Tshop=yes,country_code=x
             n5004 Tshop=yes,addr:country=us
             n5005 Tshop=yes,country=be
+            n5006 Tshop=yes,addr:country=France
             """
         Then place contains exactly
             | object | class | address         |
@@ -83,6 +84,7 @@ Feature: Tag evaluation
             | N5003  | shop  | - |
             | N5004  | shop  | 'country': 'us' |
             | N5005  | shop  | - |
+            | N5006  | shop  | - |
 
 
     Scenario: Postcodes