]> git.openstreetmap.org Git - nominatim.git/commitdiff
ignore entries without country code
authorSarah Hoffmann <lonvia@denofr.de>
Thu, 13 May 2021 10:07:20 +0000 (12:07 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Thu, 13 May 2021 12:15:42 +0000 (14:15 +0200)
nominatim/tools/postcodes.py
test/python/test_tools_postcodes.py

index 418b814faafc22c98d7428d2fad0e1a1c8479564..9bcdf2e558a4f652c66f62fdfccc489a3ee5d261 100644 (file)
@@ -157,6 +157,7 @@ def update_postcodes(dsn, project_dir, tokenizer):
                                         ST_Centroid(ST_Collect(ST_Centroid(geometry))) as centroid
                                  FROM placex
                                  WHERE address ? 'postcode' and geometry IS NOT null
+                                       and country_code is not null
                                  GROUP BY country_code, pc) xx
                                WHERE pc is not null
                                ORDER BY country_code, pc""")
index 4348b0197abff791117f9082518653ef29385b03..e0a62ec7572ff4b53d6254ff13be266dba0754f1 100644 (file)
@@ -104,6 +104,15 @@ def test_import_postcodes_remove(dsn, placex_table, postcode_table, tmp_path, to
     assert postcode_table.row_set == {('xx', 'AB 4511', 10, 12)}
 
 
+def test_import_postcodes_ignore_empty_country(dsn, placex_table, postcode_table, tmp_path, tokenizer):
+    placex_table.add(country=None, geom='POINT(10 12)',
+                     address=dict(postcode='AB 4511'))
+
+    postcodes.update_postcodes(dsn, tmp_path, tokenizer)
+
+    assert not postcode_table.row_set
+
+
 def test_import_postcodes_remove_all(dsn, placex_table, postcode_table, tmp_path, tokenizer):
     postcode_table.add('ch', '5613', 10, 12)