Commit c3a9174d authored by shinde's avatar shinde
Browse files

Corrected line length

parent 9ade418f
Pipeline #27871 passed with stage
in 5 minutes and 4 seconds
......@@ -355,13 +355,9 @@ class JapanDatabase(SpatialiteDatabase):
"""
sql_statement = "INSERT INTO HouseholdData "
sql_statement += (
"(district_id, building_type_id, dwelling_type_id, tenure_type_id, "
)
sql_statement += "(district_id, building_type_id, dwelling_type_id, tenure_type_id, "
sql_statement += "number_dwelling, number_household, number_household_member, "
sql_statement += (
"rooms_per_dwelling, tatami_per_dwelling, floorspace_per_dwelling, "
)
sql_statement += "rooms_per_dwelling, tatami_per_dwelling, floorspace_per_dwelling, "
sql_statement += "tatami_per_person, person_per_room) "
sql_statement += "VALUES (%d, %d, %d, %d, %f, %f, %f, %f, %f, %f, %f, %f)" % (
district_id,
......@@ -407,9 +403,7 @@ class JapanDatabase(SpatialiteDatabase):
"""
sql_statement = "INSERT INTO DwellingFloorspace "
sql_statement += (
"(district_id, building_type_id, dwelling_type_id, tenure_type_id, "
)
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,
......@@ -452,12 +446,8 @@ class JapanDatabase(SpatialiteDatabase):
"""
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 += "(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,
......@@ -607,9 +597,7 @@ class JapanDatabase(SpatialiteDatabase):
File path to the boundary file
"""
boundary_db = SpatialiteDatabase(
district_boundary_filepath, self.spatialite_filepath
)
boundary_db = SpatialiteDatabase(district_boundary_filepath, self.spatialite_filepath)
boundary_db.connect(init_spatial_metadata=False)
sql_statement = "SELECT key_code_ward, "
......@@ -621,8 +609,7 @@ class JapanDatabase(SpatialiteDatabase):
self.insert_district(
row[0],
row[1],
"ST_Transform(CastToMultiPolygon(GeomFromText('%s', 4612)), 4326)"
% row[2],
"ST_Transform(CastToMultiPolygon(GeomFromText('%s', 4612)), 4326)" % row[2],
)
logger.debug("District %d with boundary added" % row[0])
self.connection.commit()
......@@ -686,18 +673,14 @@ class JapanDatabase(SpatialiteDatabase):
# Read numbers of dwellings
dwelling_numbers_input = pandas.read_excel(
dwelling_numbers_filepath,
header=10,
usecols=[4, 5, 7, 9, 10, 11, 12, 13, 14],
dwelling_numbers_filepath, header=10, usecols=[4, 5, 7, 9, 10, 11, 12, 13, 14]
)
for index, row in dwelling_numbers_input.iterrows():
admin_id = int((row["Area classification"].split("_"))[0])
# Identify district_id based on admin_id from the District table
district_id_result = self.read_district_id(admin_id)
if (
district_id_result is None
): # Only data for which a district exist matter
if district_id_result is None: # Only data for which a district exist matter
continue
district_id = district_id_result[0]
......@@ -713,11 +696,7 @@ class JapanDatabase(SpatialiteDatabase):
for material_id in range(5):
dwelling_number = float(str(row[4 + material_id]).replace("-", "0"))
self.insert_dwelling_number(
district_id,
building_type_id,
material_id,
story_number_id,
dwelling_number,
district_id, building_type_id, material_id, story_number_id, dwelling_number
)
logger.debug(
"Dwelling number for district %s, type %s, %s added"
......@@ -738,9 +717,7 @@ class JapanDatabase(SpatialiteDatabase):
# Identify district_id based on admin_id from the District table
district_id_result = self.read_district_id(admin_id)
if (
district_id_result is None
): # Only data for which a district exist matter
if district_id_result is None: # Only data for which a district exist matter
continue
district_id = district_id_result[0]
......@@ -759,11 +736,7 @@ class JapanDatabase(SpatialiteDatabase):
if material_id == 2:
material_id = 4
self.insert_building_number(
district_id,
building_type_id,
material_id,
story_number_id,
building_number,
district_id, building_type_id, material_id, story_number_id, building_number
)
logger.debug(
"Building number for district %s, type %s, %s added"
......@@ -786,9 +759,7 @@ class JapanDatabase(SpatialiteDatabase):
# Identify district_id based on admin_id from the District table
district_id_result = self.read_district_id(admin_id)
if (
district_id_result is None
): # Only data for which a district exist matter
if district_id_result is None: # Only data for which a district exist matter
continue
district_id = district_id_result[0]
......@@ -850,9 +821,7 @@ class JapanDatabase(SpatialiteDatabase):
# Identify district_id based on admin_id from the District table
district_id_result = self.read_district_id(admin_id)
if (
district_id_result is None
): # Only data for which a district exist matter
if district_id_result is None: # Only data for which a district exist matter
continue
district_id = district_id_result[0]
......@@ -893,9 +862,7 @@ class JapanDatabase(SpatialiteDatabase):
# Prepare and insert the data to the DwellingDistribution table
for dwelling_size_type_id in range(7):
number_dwelling = float(
str(row[6 + dwelling_size_type_id]).replace("-", "0")
)
number_dwelling = float(str(row[6 + dwelling_size_type_id]).replace("-", "0"))
self.insert_dwelling_distribution(
district_id,
building_type_id,
......@@ -926,9 +893,7 @@ class JapanDatabase(SpatialiteDatabase):
# Identify district_id based on admin_id from the District table
district_id_result = self.read_district_id(admin_id)
if (
district_id_result is None
): # Only data for which a district exist matter
if district_id_result is None: # Only data for which a district exist matter
continue
district_id = district_id_result[0]
......@@ -967,15 +932,11 @@ class JapanDatabase(SpatialiteDatabase):
for construction_material_id, construction_material in enumerate(
construction_material_list
):
self.insert_construction_material(
construction_material_id, construction_material
)
self.insert_construction_material(construction_material_id, construction_material)
logger.info("Construction-material types added")
# Add the types of dwelling sizes to the database
for dwelling_size_type_id, dwelling_size_type in enumerate(
dwelling_size_type_list
):
for dwelling_size_type_id, dwelling_size_type in enumerate(dwelling_size_type_list):
self.insert_dwelling_size_type(dwelling_size_type_id, dwelling_size_type)
logger.info("Dwelling-size types added")
......
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