Skip to content

Commit

Permalink
Fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
margrietpalm committed Jul 2, 2024
1 parent e1ac02d commit 800481e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions threedi_schema/migrations/versions/0223_upgrade_db_inflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,18 +255,19 @@ 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} = (
SELECT ST_Buffer(v2_connection_nodes.the_geom, 1)
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
Expand All @@ -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()
Expand All @@ -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 (
Expand Down

0 comments on commit 800481e

Please sign in to comment.