From 7ad0f097c3121dd90071457e38a3518b08f321b7 Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 27 Oct 2023 10:17:15 +0200 Subject: [PATCH] Update code_utils.py Introducing `layer` in generate_model_id to make it absolutely unique --- src/hydamo/hydamo/code_utils.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/hydamo/hydamo/code_utils.py b/src/hydamo/hydamo/code_utils.py index 7770919..c372353 100644 --- a/src/hydamo/hydamo/code_utils.py +++ b/src/hydamo/hydamo/code_utils.py @@ -8,8 +8,9 @@ CODES_CSV = Path(__file__).parent.joinpath("data", "codes.csv") CODES_DF = None -WBH_CODE_TEMPLATE = "NL.WBHCODE.{wbh_code}.{code}" -BGT_CODE_TEMPLATE = "NL.BGTCODE.{bgt_code}.{code}" +WBH_CODE_TEMPLATE = "NL.WBHCODE.{wbh_code}.{layer}.{code}" +BGT_CODE_TEMPLATE = "NL.BGTCODE.{bgt_code}.{layer}.{code}" +NEN3610_ID_TEMPLATE = "NL.BGTCODE.{bgt_code}.{layer}.{nen3610_id}" def get_codes_df(): @@ -92,7 +93,7 @@ def find_codes( return df.to_dict() -def generate_model_id(code, wbh_code=None, bgt_code=None, geometry=None): +def generate_model_id(code, layer, wbh_code=None, bgt_code=None, geometry=None): """Generate a model_id from wbh_code or bgt_code and code or x/y coordinate""" if code is None: if geometry is not None: @@ -104,6 +105,9 @@ def generate_model_id(code, wbh_code=None, bgt_code=None, geometry=None): """ ) + if layer is None: + raise ValueError(f" Specify 'layer' ({layer}) to generate a model_id") + result = None if wbh_code: if wbh_code_exists(wbh_code):