X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/a4733eed90b2ee5e7b0aac2da3f8e71cffd340a6..ddf866c4c77256f62fdfd2996ccaf7a6cdcb3074:/nominatim/tools/postcodes.py diff --git a/nominatim/tools/postcodes.py b/nominatim/tools/postcodes.py index fd355079..2be3ced6 100644 --- a/nominatim/tools/postcodes.py +++ b/nominatim/tools/postcodes.py @@ -169,7 +169,7 @@ def update_postcodes(dsn, project_dir, tokenizer): SELECT COALESCE(plx.country_code, get_country_code(ST_Centroid(pl.geometry))) as cc, token_normalized_postcode(pl.address->'postcode') as pc, - ST_Centroid(ST_Collect(ST_Centroid(pl.geometry))) as centroid + COALESCE(ST_Centroid(ST_Collect(plx.centroid)), ST_Centroid(ST_Collect(ST_Centroid(pl.geometry)))) as centroid FROM place AS pl LEFT OUTER JOIN placex AS plx ON pl.osm_id = plx.osm_id AND pl.osm_type = plx.osm_type WHERE pl.address ? 'postcode' AND pl.geometry IS NOT null GROUP BY cc, pc @@ -204,8 +204,4 @@ def can_compute(dsn): postcodes can be computed. """ with connect(dsn) as conn: - with conn.cursor() as cur: - cur.execute(""" - select exists(select 1 from information_schema.tables where table_name='place') - """) - return cur.fetchone()[0] + return conn.table_exists('place')