Commit 741ce9bb authored by Simantini Shinde's avatar Simantini Shinde
Browse files

Dropped rows with total for basement presence

parent ff3a65fc
Pipeline #44429 passed with stage
in 2 minutes and 17 seconds
......@@ -1034,6 +1034,29 @@ class CommercialAggregatedExposure(SpatialiteDatabase):
"and basement presence datasets"
)
def drop_rows_with_total_basement_presence(self):
"""
This function deletes the rows with `total` values for basement presence dataset.
These rows are deleted to keep the `total` values coming from the
`construction material` dataset as the final value.
"""
# Drop rows with `total` values not equal to `main usage and construction material`
sql_statement = """
DELETE FROM BuildingNumber
WHERE construction_material_id = -1
AND basement_presence_id = 0
AND eq_resistance_code_presence_id = -1
AND total_floor_area_id = -1
"""
logger.debug(sql_statement)
self.cursor.execute(sql_statement)
self.connection.commit()
logger.info(
"Dropped rows in BuildingNumber table with `total` type "
"not equal to the total for `main usage and construction material`"
)
def import_exposure_data(
self,
building_numbers_main_usage_construction_material_city_filepath,
......@@ -1146,6 +1169,10 @@ class CommercialAggregatedExposure(SpatialiteDatabase):
# and `main usage and construction material`
self.fix_mismatch_total_numbers_basement_presence()
# Drop rows with `total` values not equal to `main usage and construction material`
# for basement presence dataset
self.drop_rows_with_total_basement_presence()
# Add the main usage types to the database
for main_usage_id, main_usage in enumerate(main_usage_list):
self.insert_main_usage(main_usage_id, main_usage)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment