Commit 481626da authored by Tara Evaz Zadeh's avatar Tara Evaz Zadeh
Browse files

Modified setup.py and database.py

parent f2197c39
Pipeline #26096 passed with stage
in 1 minute and 41 seconds
......@@ -10,7 +10,13 @@ setup(
version="0.1",
description="Compute damage-state probabilities for assets in scenario earthquakes",
license="AGPLv3+",
install_requires=["pandas", "numpy", "scipy", "shapely", "pyproj"],
install_requires=[
"pandas",
"numpy",
"scipy",
"shapely",
"pyproj",
],
extras_require={
"tests": tests_require,
"linters": linters_require,
......
......@@ -376,26 +376,27 @@ class ExposureDatabase(Database):
self.create_tables()
tile_ids = []
with open(building_geometries_filepath) as csv_file:
reader = csv.reader(csv_file, delimiter=";")
next(reader)
for building in reader:
building_id = int(building[0][4:])
tile_id = int(
building[2][5:] # Removes the first 5 characters (i.e. the part 'cell_').
)
if tile_id not in tile_ids:
tile_ids.append(tile_id)
self.insert_building(
building_id,
"ST_Transform(CastToMultiPolygon(GeomFromText('%s', 3857)), 4326)"
% building[1],
tile_id,
)
logger.info("Buildings imported")
self.connection.commit()
if building_geometries_filepath:
with open(building_geometries_filepath) as csv_file:
reader = csv.reader(csv_file, delimiter=";")
next(reader)
for building in reader:
building_id = int(building[0][4:])
tile_id = int(
building[2][5:] # Removes the first 5 characters (i.e. the part 'cell_').
)
if tile_id not in tile_ids:
tile_ids.append(tile_id)
self.insert_building(
building_id,
"ST_Transform(CastToMultiPolygon(GeomFromText('%s', 3857)), 4326)"
% building[1],
tile_id,
)
logger.info("Buildings imported")
self.connection.commit()
else:
print("Please provide the input `-g`,`--building-geometries` if there are any building assets in the input CSV format exposure file. ")
# Create temporary storage for taxonomy strings and districts
taxonomy_list = []
district_list = []
......@@ -510,6 +511,10 @@ class ExposureDatabase(Database):
)
writer.writerow(fieldnames)
#if exists BuildingAsset:
# Building asset exposure output
sql_statement = "SELECT BuildingAsset.id, "
sql_statement += "X(ST_Centroid(Building.geom)), "
......@@ -591,8 +596,8 @@ class ExposureDatabase(Database):
asset[9],
asset[10],
asset[11],
None,
None,
'-1',
'POINT EMPTY',
]
writer.writerow(write_asset)
line_number += 1
......
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