Commit 52b692bf authored by Danijel Schorlemmer's avatar Danijel Schorlemmer
Browse files

Implemented the suggested schema for BuildingAsset and TileAsset

parent ba7a19e1
Pipeline #36817 failed with stage
in 1 minute and 25 seconds
......@@ -156,12 +156,16 @@ class ExposureDatabase(SpatialiteDatabase):
# Create table Building
sql_statement = "CREATE TABLE Building ("
sql_statement += "id INTEGER, "
sql_statement += "quadkey TEXT)"
sql_statement += "id INTEGER, "
sql_statement += "quadkey TEXT, "
sql_statement += "occupancy TEXT)"
self.connection.execute(sql_statement)
sql_statement = "SELECT AddGeometryColumn('Building', 'geom', 4326, "
sql_statement += "'MULTIPOLYGON', 'XY')"
self.connection.execute(sql_statement)
sql_statement = "SELECT AddGeometryColumn('Building', 'centroid', 4326, "
sql_statement += "'POINT', 'XY')"
self.connection.execute(sql_statement)
logger.debug("Table Building created")
# Create table Taxonomy
......@@ -271,22 +275,26 @@ class ExposureDatabase(SpatialiteDatabase):
)
self.cursor.execute(sql_statement)
def insert_building(self, building_id, geom, quadkey):
def insert_building(self, building_id, quadkey, occupancy, geom, centroid):
"""
Inserts a building and its geometry to the Building table.
Args:
building_id (int):
ID of the building
geom (geom):
Geometry of the building (multi-polygon)
quadkey (str):
ID (Quadkey) of the tile the building centroid is located in
occupancy (str):
Occupancy type of the building
geom (geom):
Geometry of the building (multi-polygon)
centroid (geom):
Centroid of the building (point)
"""
sql_statement = "INSERT INTO Building "
sql_statement += "(id, geom, quadkey) "
sql_statement += "VALUES (%d, %s, '%s')" % (building_id, geom, quadkey)
sql_statement += "(id, quadkey, occupancy, geom, centroid) "
sql_statement += "VALUES (%d, %s, %s, '%s', '%s')" % (building_id, quadkey, occupancy, geom, centroid)
self.cursor.execute(sql_statement)
def insert_taxonomy(self, taxonomy_id, taxonomy_string):
......
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