Commit 11de1987 authored by Danijel Schorlemmer's avatar Danijel Schorlemmer
Browse files

Implemented the import of dwelling floorspace and sizes

parent 7a3bc118
Pipeline #22976 failed with stage
in 1 minute and 55 seconds
......@@ -403,7 +403,7 @@ class JapanDatabase(SpatialiteDatabase):
)
self.cursor.execute(sql_statement)
def insert_dwelling_size_number(
def insert_dwelling_distribution(
self,
district_id,
building_type_id,
......@@ -414,7 +414,7 @@ class JapanDatabase(SpatialiteDatabase):
number_dwelling,
):
"""
Inserts a full dataset to the DwellingSizeNumber table.
Inserts a full dataset to the DwellingDistribution table.
Args:
district_id (int):
......@@ -433,7 +433,7 @@ class JapanDatabase(SpatialiteDatabase):
Number of dwellings for the combination of the other parameters
"""
sql_statement = "INSERT INTO DwellingSizeNumber "
sql_statement = "INSERT INTO DwellingDistribution "
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)" % (
......@@ -560,7 +560,7 @@ class JapanDatabase(SpatialiteDatabase):
sql_statement = "SELECT key_code_ward, "
sql_statement += "CITY_NAME, "
sql_statement += "AsWKT(CastAutomagic(geom)) "
sql_statement += "FROM estat_bound_municipal"
sql_statement += "FROM Boundary"
boundary_db.cursor.execute(sql_statement)
for row in boundary_db.cursor:
self.insert_district(
......@@ -829,15 +829,10 @@ class JapanDatabase(SpatialiteDatabase):
# Prepare and insert the data to the DwellingSizeNumber table
for dwelling_size_type_id in range(7):
number_dwelling = float(str(row[6 + dwelling_size_type_id]).replace("-", "0"))
self.insert_dwelling_size_number(
district_id,
building_type_id,
dwelling_type_id,
tenure_type_id,
construction_material_id,
dwelling_size_type_id,
number_dwelling,
)
self.insert_dwelling_distribution(district_id, building_type_id,
dwelling_type_id, tenure_type_id,
construction_material_id,
dwelling_size_type_id, number_dwelling)
logger.debug(
"Dwelling numbers by size for district %s, type %s, %s, %s, %s added"
% (
......
......@@ -42,7 +42,7 @@ def main():
logger.warning("Spatialite extension cannot be loaded. Exiting ...")
exit()
db.create_tables()
db.read_districts_and_boundaries("data/estat_bound_municipal.gpkg")
db.read_districts_and_boundaries("data/Boundary.gpkg")
db.import_exposure_data(
"data/e008_3e.xlsx", "data/e039_3e.xlsx", "data/e011_2e.xlsx", "data/e014e.xlsx"
)
......
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