From 1def4e32cfda43004e0caaae5b4ba5b8f37b11a1 Mon Sep 17 00:00:00 2001 From: Laurens Oostwegel <laurens@gfz-potsdam.de> Date: Thu, 28 Mar 2024 15:10:54 +0100 Subject: [PATCH] Raise an error if the number stories exceeds 175 --- .../stories_and_floorspace.py | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/building/02_process/stories_and_floorspace/stories_and_floorspace.py b/building/02_process/stories_and_floorspace/stories_and_floorspace.py index ad4839a..847ed97 100644 --- a/building/02_process/stories_and_floorspace/stories_and_floorspace.py +++ b/building/02_process/stories_and_floorspace/stories_and_floorspace.py @@ -1,3 +1,22 @@ +#!/usr/bin/env python3 + +# Copyright (c) 2023-2024: +# Helmholtz-Zentrum Potsdam Deutsches GeoForschungsZentrum GFZ +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero +# General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. + + class StoriesAndFloorspaceRule: def __call__(self, tags, relations, area, *args, **kwargs): """ @@ -29,6 +48,9 @@ class StoriesAndFloorspaceRule: stories = ceil(float(story_string)) if stories < 1: raise ValueError("Number of stories cannot be below 1") + elif stories > 175: + raise ValueError("Number of stories cannot be above 175") + floorspace = stories * area return {"stories": stories, "floorspace": floorspace} except ValueError: -- GitLab