Commit b2337f49 authored by Simantini Shinde's avatar Simantini Shinde
Browse files

Mapped building exposure attributes and their values in BuildingAsset table

parent 959cd6bf
Pipeline #39721 passed with stage
in 1 minute and 33 seconds
......@@ -96,6 +96,7 @@ class JapanDatabase(SpatialiteDatabase):
(1-2, 3-5, ...) of numbers of stories.
DwellingSizeType : Stores the different types of dwelling sizes
BuildingClassesMapping: Stores GEM taxonomy-based building classes
BuildingAsset : Stores required building exposure assets
"""
# Create table District
......@@ -253,6 +254,22 @@ class JapanDatabase(SpatialiteDatabase):
self.connection.execute(sql_statement)
logger.debug("Table BuildingClassesMapping created")
# Create table BuildingAsset
sql_statement = "CREATE TABLE BuildingAsset ("
sql_statement += "id INTEGER PRIMARY KEY, "
sql_statement += "admin_id TEXT, "
sql_statement += "admin_name TEXT, "
sql_statement += "occupancy TEXT, "
sql_statement += "taxonomy INTEGER, "
sql_statement += "number REAL, "
sql_statement += "structural REAL, "
sql_statement += "night REAL)"
self.connection.execute(sql_statement)
sql_statement = "SELECT AddGeometryColumn('BuildingAsset', 'geom', 4326, "
sql_statement += "'MULTIPOLYGON', 'XY')"
self.connection.execute(sql_statement)
logger.debug("Table BuildingAsset created")
def insert_building_type(self, building_type_id, description):
"""
Inserts a building-type description to the BuildingType table.
......@@ -1985,3 +2002,52 @@ class JapanDatabase(SpatialiteDatabase):
logger.info(
"Imported BuildingClassesMapping table with GEM taxonomy-based building classes"
)
def assign_building_asset(self):
"""
The building attributes and their corresponding number of buildings, person per building
at night, building class, administrative name, administrative id and occupancy is mapped
from District, BuildingNumber, DwellingNumber and HouseholdData tables.
"""
sql_statement = """
INSERT INTO BuildingAsset
(
admin_id,
admin_name,
occupancy,
taxonomy,
number,
structural,
night
)
SELECT District.id, District.name, '%s',
BuildingClassesMapping.building_class, number_building, %d,
H.number_household_member
FROM District
INNER JOIN BuildingNumber
ON BuildingNumber.district_id = District.id
INNER JOIN
(
SELECT *
FROM HouseholdData
WHERE tenure_type_id = 0
AND dwelling_type_id = 0
) AS H
ON BuildingNumber.district_id = H.district_id
AND BuildingNumber.building_type_id = H.building_type_id
AND BuildingNumber.construction_material_id = H.construction_material_id
AND BuildingNumber.story_number_id = H.story_number_id
INNER JOIN BuildingClassesMapping
ON BuildingClassesMapping.building_type_id = BuildingNumber.building_type_id
AND BuildingClassesMapping.construction_material_id
= BuildingNumber.construction_material_id
AND BuildingClassesMapping.story_number_id = BuildingNumber.story_number_id
""" % (
"Res",
1,
)
logger.debug(sql_statement)
self.cursor.execute(sql_statement)
self.connection.commit()
logger.info("Building attributes and their values added into the BuildingAsset table")
......@@ -51,7 +51,7 @@ def main():
"data/e014e.xlsx",
)
db.import_gem_building_class_mapping("mapping_files/GEM_Tax_Building_class.xlsx")
db.assign_building_asset()
# Leave the program
sys.exit()
......
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