Commit 272c86f9 authored by Danijel Schorlemmer's avatar Danijel Schorlemmer
Browse files

Implemented the import of dwelling floorspace and sizes

parent 48576038
Pipeline #21768 failed with stage
in 1 minute and 16 seconds
......@@ -159,7 +159,7 @@ class JapanDatabase(SpatialiteDatabase):
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 += "dwelling_size_type_id INTEGER, "
sql_statement += "number_dwelling REAL)"
self.connection.execute(sql_statement)
logger.debug("Table DwellingDistribution created")
......@@ -373,7 +373,7 @@ class JapanDatabase(SpatialiteDatabase):
floorspace,
):
"""
Inserts a full dataset to the HouseholdData table.
Inserts a full dataset to the DwellingFloorspace table.
Args:
district_id (int):
......@@ -403,19 +403,49 @@ class JapanDatabase(SpatialiteDatabase):
)
self.cursor.execute(sql_statement)
def insert_dwelling_size_number(
self,
district_id,
building_type_id,
dwelling_type_id,
tenure_type_id,
construction_material_id,
dwelling_size_type_id,
number_dwelling,
):
"""
Inserts a full dataset to the DwellingSizeNumber table.
# 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")
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
dwelling_size_type_id (int):
ID of the dwelling-size type. Corresponds to DwellingSizeType.id
number_dwelling (float):
Number of dwellings for the combination of the other parameters
"""
sql_statement = "INSERT INTO DwellingSizeNumber "
sql_statement += "(district_id, building_type_id, dwelling_type_id, tenure_type_id, "
sql_statement += "construction_material_id, dwelling_size_type_id, number_dwelling) "
sql_statement += "VALUES (%d, %d, %d, %d, %d, %d, %f)" % (
district_id,
building_type_id,
dwelling_type_id,
tenure_type_id,
construction_material_id,
dwelling_size_type_id,
number_dwelling,
)
self.cursor.execute(sql_statement)
def insert_building_type(self, building_type_id, description):
"""
......@@ -497,6 +527,22 @@ class JapanDatabase(SpatialiteDatabase):
sql_statement += "VALUES (%d, '%s')" % (story_number_id, description)
self.cursor.execute(sql_statement)
def insert_dwelling_size_type(self, dwelling_size_type_id, description):
"""
Inserts a Dwelling-size description to the DwellingSizeType table.
Args:
dwelling_size_type_id (int):
ID of the dwelling-size type entry
description (str):
Description of the dwelling-size type entry
"""
sql_statement = "INSERT INTO DwellingSizeType "
sql_statement += "(id, description) "
sql_statement += "VALUES (%d, '%s')" % (dwelling_size_type_id, description)
self.cursor.execute(sql_statement)
def read_districts_and_boundaries(self, district_boundary_filepath):
"""
Imports all districts and boundaries from a prepared geopackage file
......
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