From: Sarah Hoffmann Date: Thu, 13 May 2021 10:07:20 +0000 (+0200) Subject: ignore entries without country code X-Git-Tag: v4.0.0~87^2~1 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/8f2746fe24d51cab464960c2679da5b09e7da882?ds=inline;hp=--cc ignore entries without country code --- 8f2746fe24d51cab464960c2679da5b09e7da882 diff --git a/nominatim/tools/postcodes.py b/nominatim/tools/postcodes.py index 418b814f..9bcdf2e5 100644 --- a/nominatim/tools/postcodes.py +++ b/nominatim/tools/postcodes.py @@ -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""") diff --git a/test/python/test_tools_postcodes.py b/test/python/test_tools_postcodes.py index 4348b019..e0a62ec7 100644 --- a/test/python/test_tools_postcodes.py +++ b/test/python/test_tools_postcodes.py @@ -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)