From 2dea02a6ac9d7af855bec1af201158c38bce0464 Mon Sep 17 00:00:00 2001 From: Santonia27 Date: Fri, 8 Nov 2024 09:04:41 +0100 Subject: [PATCH] update untis class --- hydromt_fiat/api/data_types.py | 18 +++++++++++++++--- hydromt_fiat/api/exposure_vm.py | 1 + 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/hydromt_fiat/api/data_types.py b/hydromt_fiat/api/data_types.py index cd34002c..9aabca9c 100644 --- a/hydromt_fiat/api/data_types.py +++ b/hydromt_fiat/api/data_types.py @@ -10,9 +10,21 @@ class ExtractionMethod(str, Enum): class Units(str, Enum): - meters = ["meters", "m"] - feet = ["feet", "ft"] - + meters = "meters", + feet = "feet" + @classmethod + def from_string(cls, value: str): + """Map different strings to the correct Units enum.""" + mappings = { + "meters": cls.meters, + "m": cls.meters, + "feet": cls.feet, + "ft": cls.feet, + } + try: + return mappings[value] + except KeyError: + raise ValueError(f"Unknown unit: {value}") class Conversion(float, Enum): meters_to_feet = 3.28084 diff --git a/hydromt_fiat/api/exposure_vm.py b/hydromt_fiat/api/exposure_vm.py index 6cbda049..0b656a76 100644 --- a/hydromt_fiat/api/exposure_vm.py +++ b/hydromt_fiat/api/exposure_vm.py @@ -135,6 +135,7 @@ def set_asset_locations_source_and_get_data( ground_elevation_unit=ground_elevation_unit, bf_conversion=bf_conversion, keep_unclassified=keep_unclassified, + unit=Units.meters.value, ) primary_object_types = ( self.exposure.exposure_db["Primary Object Type"].unique().tolist()