From 6ba9d0a4d859a11c7b73965f2f2efbc8f9a634cb Mon Sep 17 00:00:00 2001 From: Danijel Schorlemmer Date: Thu, 27 Jan 2022 10:36:17 +0100 Subject: [PATCH] Simplified the SQL query copying geometries from the Geopackage file --- exposurejapan/database.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/exposurejapan/database.py b/exposurejapan/database.py index 7dd63c3..e11366d 100644 --- a/exposurejapan/database.py +++ b/exposurejapan/database.py @@ -641,7 +641,7 @@ class JapanDatabase(SpatialiteDatabase): File path to the boundary file """ - # Attach geopackage boundary database to the Japan database + # Attach Geopackage boundary database to the Japan database sql_statement = "SELECT EnableGpkgAmphibiousMode();" self.connection.execute(sql_statement) sql_statement = "ATTACH '%s' AS BoundaryDatabase" % district_boundary_filepath @@ -653,8 +653,8 @@ class JapanDatabase(SpatialiteDatabase): sql_statement = ( "INSERT INTO District (id, admin_id, name, geom) " "SELECT key_code_ward, key_code_ward, CITY_NAME, " - "ST_Transform(CastToMultiPolygon(GeomFromWKB(AsBinary(geom), %d)), " - "%d) " % (constants.JGD2000, constants.WGS84) + "ST_Transform(CastToMultiPolygon(GeomFromGPB(geom)), " + "%d) " % constants.WGS84 ) sql_statement += "FROM BoundaryDatabase.Boundary" logger.debug(sql_statement) @@ -680,7 +680,7 @@ class JapanDatabase(SpatialiteDatabase): self.cursor.execute(sql_statement) self.connection.commit() - # Detach geopackage boundary database from the Japan database + # Detach Geopackage boundary database from the Japan database sql_statement = "DETACH DATABASE 'BoundaryDatabase'" logger.debug(sql_statement) self.connection.execute(sql_statement) -- GitLab