From 800481e45832ecf5663737e9bf148d594ea82cd6 Mon Sep 17 00:00:00 2001 From: Margriet Palm Date: Tue, 2 Jul 2024 16:19:26 +0200 Subject: [PATCH] Fix typo --- .../migrations/versions/0223_upgrade_db_inflow.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/threedi_schema/migrations/versions/0223_upgrade_db_inflow.py b/threedi_schema/migrations/versions/0223_upgrade_db_inflow.py index 6e7eab6..864842f 100644 --- a/threedi_schema/migrations/versions/0223_upgrade_db_inflow.py +++ b/threedi_schema/migrations/versions/0223_upgrade_db_inflow.py @@ -255,6 +255,7 @@ def copy_polygons(src_table: str, tmp_geom: str): def create_buffer_polygons(src_table: str, tmp_geom: str): # create circular polygon of area 1 around the connection node + surf_id = f"{src_table.strip('v2_')}_id" op.execute(sa.text(f""" UPDATE {src_table} SET {tmp_geom} = ( @@ -262,11 +263,11 @@ def create_buffer_polygons(src_table: str, tmp_geom: str): FROM v2_connection_nodes JOIN {src_table}_map ON v2_connection_nodes.id = {src_table}_map.connection_node_id - WHERE {src_table}.id = {src_table}_map.impervious_surface_id + WHERE {src_table}.id = {src_table}_map.{surf_id} ) WHERE {tmp_geom} IS NULL AND id IN ( - SELECT {src_table}_map.{src_table.strip('v2_')}_id + SELECT {src_table}_map.{surf_id} FROM v2_connection_nodes JOIN {src_table}_map ON v2_connection_nodes.id = {src_table}_map.connection_node_id @@ -277,6 +278,7 @@ def create_buffer_polygons(src_table: str, tmp_geom: str): def create_square_polygons(src_table: str, tmp_geom: str): # create square polygon with area area around the connection node side_expr = f'sqrt({src_table}.area)' + surf_id = f"{src_table.strip('v2_')}_id" # When no geometry is defined, a square with area matching the area column # with the center at the connection node is added srid = get_global_srid() @@ -287,8 +289,8 @@ def create_square_polygons(src_table: str, tmp_geom: str): ST_Transform(v2_connection_nodes.the_geom, {srid}))) AS geom FROM {src_table}_map JOIN v2_connection_nodes ON {src_table}_map.connection_node_id = v2_connection_nodes.id - JOIN {src_table} ON {src_table}_map.{src_table.strip('v2_')}_id = {src_table}.id - WHERE {src_table}_map.{src_table.strip('v2_')}_id = {src_table}.id + JOIN {src_table} ON {src_table}_map.{surf_id} = {src_table}.id + WHERE {src_table}_map.{surf_id} = {src_table}.id GROUP BY {src_table}.id ), side_length AS (