Skip to content

Commit

Permalink
Verify that ornefni.gpkg is present in DB build script + updated defa…
Browse files Browse the repository at this point in the history
…ult DSV filename
  • Loading branch information
sveinbjornt committed Aug 11, 2023
1 parent e3aa17c commit 4b1f1b0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions add_placename_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

from pprint import pprint
import sqlite3
from pathlib import Path

import fiona

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions build_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -27,7 +27,7 @@

STADFONG_REMOTE_URL = "https://fasteignaskra.is/Stadfangaskra.csv"

DSV_FILENAME = "STADFANG.dsv"
DSV_FILENAME = "Stadfangaskra.csv"

DEFAULT_DBNAME = "iceaddr.db"

Expand Down

0 comments on commit 4b1f1b0

Please sign in to comment.