Skip to content

Commit

Permalink
Update code_utils.py
Browse files Browse the repository at this point in the history
Introducing `layer` in generate_model_id to make it absolutely unique
  • Loading branch information
DanielTollenaar committed Oct 27, 2023
1 parent 11079cd commit 7ad0f09
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/hydamo/hydamo/code_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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:
Expand All @@ -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):
Expand Down

0 comments on commit 7ad0f09

Please sign in to comment.