From 4b1f1b05d9ee7d1a3e874b95647d86fe28dbaff0 Mon Sep 17 00:00:00 2001 From: Sveinbjorn Thordarson Date: Fri, 11 Aug 2023 20:16:15 +0000 Subject: [PATCH] Verify that ornefni.gpkg is present in DB build script + updated default DSV filename --- add_placename_data.py | 7 +++++-- build_db.py | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/add_placename_data.py b/add_placename_data.py index 0bf34e1..b5e38e6 100755 --- a/add_placename_data.py +++ b/add_placename_data.py @@ -9,6 +9,7 @@ from pprint import pprint import sqlite3 +from pathlib import Path import fiona @@ -109,10 +110,13 @@ def add_placename_additions(dbc) -> None: def add_placenames_from_is50v(dbc) -> None: """Read IS50V geo layers from file, add all placenames ("örnefni") to DB.""" + if not Path(GPKG_FILE).exists(): + print(f"Could not find file {GPKG_FILE}") + exit(1) + for layer in fiona.listlayers(GPKG_FILE): with fiona.open(GPKG_FILE, encoding="utf-8", layer=layer) as src: for i in src: - wanted_layer = [layer.startswith(p) for p in LAYERS] if True not in wanted_layer: # print("Skipping layer " + layer) @@ -143,7 +147,6 @@ def add_placenames_from_is50v(dbc) -> None: # Special handling of flakes - use center point elif type(c) is list: - if not c: # print("Faulty flake: {0}".format(n)) # pprint(i) diff --git a/build_db.py b/build_db.py index 57cd152..8187394 100755 --- a/build_db.py +++ b/build_db.py @@ -2,7 +2,7 @@ """ Create stadfong address database from from the - DSV file at ftp://ftp.skra.is/skra/STADFANG.dsv.zip + Staðfangaskrá CSV dataset. From data compiled by Registers Iceland (CC-BY): https://opingogn.is/dataset/stadfangaskra @@ -27,7 +27,7 @@ STADFONG_REMOTE_URL = "https://fasteignaskra.is/Stadfangaskra.csv" -DSV_FILENAME = "STADFANG.dsv" +DSV_FILENAME = "Stadfangaskra.csv" DEFAULT_DBNAME = "iceaddr.db"