Commit 9ade418f authored by shinde's avatar shinde
Browse files

Fixed too long lines

parent c7061ae3
Pipeline #27869 failed with stage
in 4 minutes and 49 seconds
......@@ -355,9 +355,13 @@ 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,
......@@ -403,7 +407,9 @@ 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,
......@@ -446,8 +452,12 @@ 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,
......@@ -459,7 +469,9 @@ class JapanDatabase(SpatialiteDatabase):
)
self.cursor.execute(sql_statement)
def insert_population_distribution(self, district_id, total, male, female, number_household):
def insert_population_distribution(
self, district_id, total, male, female, number_household
):
"""
Inserts a full dataset to the PopulationDistribution table.
......@@ -595,7 +607,9 @@ 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, "
......@@ -607,7 +621,8 @@ 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()
......@@ -671,14 +686,18 @@ 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]
......@@ -694,7 +713,11 @@ 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"
......@@ -715,7 +738,9 @@ 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]
......@@ -734,7 +759,11 @@ 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"
......@@ -757,7 +786,9 @@ 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]
......@@ -819,7 +850,9 @@ 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]
......@@ -860,7 +893,9 @@ 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,
......@@ -883,13 +918,17 @@ class JapanDatabase(SpatialiteDatabase):
logger.info("Number and sizes of dwellings added")
# Read PopulationDistribution
population_distribution_input = pandas.read_csv(population_distribution_filepath, usecols=[2, 9, 10, 11, 12])
population_distribution_input = pandas.read_csv(
population_distribution_filepath, usecols=[2, 9, 10, 11, 12]
)
for index, row in population_distribution_input.iterrows():
admin_id = int(row["KEY_CODE"])
# 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]
......@@ -898,7 +937,9 @@ class JapanDatabase(SpatialiteDatabase):
male = int(row[2])
female = int(row[3])
number_household = int(row[4])
self.insert_population_distribution(district_id, total, male, female, number_household)
self.insert_population_distribution(
district_id, total, male, female, number_household
)
logger.debug("PopulationDistribution for district %s added" % admin_id)
logger.info("Population data added")
......@@ -926,11 +967,15 @@ 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