Skip to content
Snippets Groups Projects
Commit 8e011e05 authored by Thorge Petersen's avatar Thorge Petersen
Browse files

More robust spatial mapping handling

parent a37a584d
Branches
Tags
No related merge requests found
......@@ -224,18 +224,22 @@ def known_spatial_uri(key, data, errors, context):
not_found = True
spatial_text = str()
spatial = str()
try:
with open(mapping_path, newline='') as mapping_file:
cr = csv.reader(mapping_file, delimiter="\t")
for row in cr:
if row[0] == value:
if row and len(row) > 2 and row[0] == value:
not_found = False
spatial_text = row[1]
loaded = json.loads(row[2])
spatial = json.dumps(loaded['geometry'])
spatial = json.dumps(loaded.get('geometry', {}))
break
if not_found:
raise toolkit.Invalid(
'spatial_uri: uri unknown')
raise toolkit.Invalid('spatial_uri: uri unknown')
except (IOError, json.decoder.JSONDecodeError, KeyError) as e:
log.error(f"Error processing spatial mapping: {e}")
raise toolkit.Invalid("Error processing spatial mapping")
new_index = next_extra_index(data)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment