Commit fd6b955a authored by Simantini Shinde's avatar Simantini Shinde
Browse files

Removed admin_id

parent 9a1dd8ff
Pipeline #39023 passed with stage
in 1 minute and 30 seconds
......@@ -97,8 +97,6 @@ class JapanDatabase(SpatialiteDatabase):
# Create table District
sql_statement = "CREATE TABLE District ("
sql_statement += "id INTEGER PRIMARY KEY, "
# admin_id is same as id and will be deleted later
sql_statement += "admin_id INTEGER, "
sql_statement += "name TEXT, "
sql_statement += "area_size REAL)"
self.connection.execute(sql_statement)
......@@ -306,11 +304,11 @@ class JapanDatabase(SpatialiteDatabase):
logger.debug(sql_statement)
self.connection.execute(sql_statement)
# From the boundary database select admin_id, name and geometry
# From the boundary database select id, name and geometry
# and insert into Districts table in the Japan database
sql_statement = (
"INSERT INTO District (id, admin_id, name, geom) "
"SELECT key_code_ward, key_code_ward, CITY_NAME, "
"INSERT INTO District (id, name, geom) "
"SELECT key_code_ward, CITY_NAME, "
"ST_Transform(CastToMultiPolygon(GeomFromGPB(geom)), "
"%d) " % constants.WGS84
)
......@@ -344,19 +342,19 @@ class JapanDatabase(SpatialiteDatabase):
self.connection.execute(sql_statement)
logger.info("Districts and boundaries added")
def get_district_id(self, admin_id):
def get_district_id(self, id):
"""
Gets the ID of the district in the Districts table corresponding
to the ID of the administrative district specified.
Args:
admin_id (int):
id (int):
ID of the administrative district
"""
# Identify district_id based on admin_id from the District table
sql_statement = "SELECT id FROM District "
sql_statement += "WHERE admin_id = %d" % admin_id
sql_statement += "WHERE id = %d" % id
self.cursor.execute(sql_statement)
result = self.cursor.fetchone()
return result
......
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