From dfb59754223667037a44cd953caa96e19d1ca852 Mon Sep 17 00:00:00 2001 From: Danijel Schorlemmer Date: Wed, 6 Apr 2022 13:13:40 +0200 Subject: [PATCH] Implemented get_quadkey function --- exposurelib/database.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/exposurelib/database.py b/exposurelib/database.py index 7441fd6..745753c 100644 --- a/exposurelib/database.py +++ b/exposurelib/database.py @@ -504,3 +504,18 @@ class ExposureDatabase(SpatialiteDatabase): sql_statement = "INSERT INTO DamageMethod (name) VALUES ('%s')" % name self.cursor.execute(sql_statement) + + def get_quadkey(self, building_id): + """ + Retrieves the `quadkey` of a building with `building_id` in the Building table. + + Args: + building_id: ID of the building + + Returns: + Quadkey of the tile the building is located in + """ + + sql_statement = "SELECT quadkey FROM Building WHERE building_id = %d" % building_id + self.cursor.execute(sql_statement) + return self.cursor.fetchone()[0] -- GitLab