Commit 48576038 authored by Danijel Schorlemmer's avatar Danijel Schorlemmer
Browse files

Implemented the import of dwelling floorspace and sizes

parent 449b89a6
Pipeline #21767 failed with stage
in 1 minute and 15 seconds
......@@ -75,9 +75,11 @@ class JapanDatabase(SpatialiteDatabase):
HouseholdData : Stores different parameters describing the household numbers,
household members, and household spaces for each district
DwellingFloorspace : Stores the floorspace per dwelling depending on the building,
dwelling, tenure types and construction material
dwelling, tenure types and construction material for each
district
DwellingDistribution: Stores the number of dwellings of different sizes depending on
the building, dwelling, tenure types and construction material
for each district
BuildingType : Stores the different types of buildings
DwellingType : Stores the different types of dwellings
TenureType : Stores the different types of tenures
......@@ -140,6 +142,7 @@ class JapanDatabase(SpatialiteDatabase):
# Create table DwellingFloorspace
sql_statement = "CREATE TABLE DwellingFloorspace ("
sql_statement += "id INTEGER PRIMARY KEY, "
sql_statement += "district_id INTEGER, "
sql_statement += "building_type_id INTEGER, "
sql_statement += "dwelling_type_id INTEGER, "
sql_statement += "tenure_type_id INTEGER, "
......@@ -151,6 +154,7 @@ class JapanDatabase(SpatialiteDatabase):
# Create table DwellingDistribution
sql_statement = "CREATE TABLE DwellingDistribution ("
sql_statement += "id INTEGER PRIMARY KEY, "
sql_statement += "district_id INTEGER, "
sql_statement += "building_type_id INTEGER, "
sql_statement += "dwelling_type_id INTEGER, "
sql_statement += "tenure_type_id INTEGER, "
......@@ -359,6 +363,60 @@ class JapanDatabase(SpatialiteDatabase):
)
self.cursor.execute(sql_statement)
def insert_dwelling_floorspace(
self,
district_id,
building_type_id,
dwelling_type_id,
tenure_type_id,
construction_material_id,
floorspace,
):
"""
Inserts a full dataset to the HouseholdData table.
Args:
district_id (int):
ID of the district. Corresponds to District.id
building_type_id (int):
ID of the building type. Corresponds to BuildingType.id
dwelling_type_id (int):
ID of the dwelling type. Corresponds to DwellingType.id
tenure_type_id (int):
ID of the tenure type. Corresponds to TenureType.id
construction_material_id (int):
ID of the construction material. Corresponds to ConstructionMaterial.id
floorspace (float):
Size of the floorspace in square meters
"""
sql_statement = "INSERT INTO DwellingFloorspace "
sql_statement += "(district_id, building_type_id, dwelling_type_id, tenure_type_id, "
sql_statement += "construction_material_id, floorspace) "
sql_statement += "VALUES (%d, %d, %d, %d, %d, %f)" % (
district_id,
building_type_id,
dwelling_type_id,
tenure_type_id,
construction_material_id,
floorspace,
)
self.cursor.execute(sql_statement)
# Create table DwellingDistribution
sql_statement = "CREATE TABLE DwellingDistribution ("
sql_statement += "id INTEGER PRIMARY KEY, "
sql_statement += "district_id INTEGER, "
sql_statement += "building_type_id INTEGER, "
sql_statement += "dwelling_type_id INTEGER, "
sql_statement += "tenure_type_id INTEGER, "
sql_statement += "construction_material_id INTEGER, "
sql_statement += "dwelling_size_id INTEGER, "
sql_statement += "number_dwelling REAL)"
self.connection.execute(sql_statement)
logger.debug("Table DwellingDistribution created")
def insert_building_type(self, building_type_id, description):
"""
Inserts a building-type description to the BuildingType table.
......
Markdown is supported
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