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

Added HouseholdData for construction material

parent 214d62ab
Pipeline #39539 passed with stage
in 1 minute and 45 seconds
......@@ -1320,6 +1320,68 @@ class JapanDatabase(SpatialiteDatabase):
self.connection.commit()
logger.info("Household data added")
def calculate_household_data_for_construction_material(self):
"""
Calculates and inserts the household numbers and household members in the HouseholdData
for construction materials (wooden, wooden (excluding wooden and fire-proofed), wooden
and fire-proofed and non-wooden).
The household numbers and household members for each construction material is calculated
in the query `MappedHouseholdDataToDwellingNumber` by multiplying their `total` values
to the proportion of dwelling numbers for the respective construction material and
`total` dwelling numbers.
"""
sql_statement = """
INSERT INTO HouseholdData
(
district_id,
building_type_id,
construction_material_id,
tenure_type_id,
dwelling_type_id,
number_household,
number_household_member
)
SELECT H.district_id AS H_district_id,
H.building_type_id AS H_building_type_id,
DN.construction_material_id AS DN_construction_material_id,
H.tenure_type_id,
H.dwelling_type_id,
DN.number_dwelling / H.number_dwelling * H.number_household
AS target_hh_number,
DN.number_dwelling / H.number_dwelling * H.number_household_member
AS target_hh_member
FROM
(
(
SELECT district_id,
building_type_id,
construction_material_id,
tenure_type_id,
dwelling_type_id,
number_household,
number_household_member,
number_dwelling
FROM HouseholdData
WHERE tenure_type_id = 0 AND dwelling_type_id = 0
) AS H
INNER JOIN
(
SELECT *
FROM DwellingNumber
WHERE story_number_id = 0
) AS DN
ON H.district_id = DN.district_id
AND H.building_type_id = DN.building_type_id
) AS MappedHouseholdDataToDwellingNumber
WHERE DN_construction_material_id != 0
"""
logger.debug(sql_statement)
self.cursor.execute(sql_statement)
self.connection.commit()
logger.info("Added HouseholdData for construction-material types")
def import_floorspace_and_dwelling_sizes(
self,
dwelling_sizes_filepath,
......@@ -1572,6 +1634,10 @@ class JapanDatabase(SpatialiteDatabase):
household_data_filepath, building_type_list, dwelling_type_list, tenure_type_list
)
# Calculate number_household and number_household_member for construction-
# material types
self.calculate_household_data_for_construction_material()
# Import dwelling floorspace and number of dwellings for
# dwelling sizes types into the database
self.import_floorspace_and_dwelling_sizes(
......
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