From bce488b11c57c6774d61132fa325aafbf66b57d0 Mon Sep 17 00:00:00 2001 From: rpachaly <39889306+rpachaly@users.noreply.github.com> Date: Tue, 14 Jan 2025 11:34:32 -0300 Subject: [PATCH] A simpler sql processing --- flo2d/flo2d_tools/elevation_correctors.py | 39 ++++++----------------- 1 file changed, 9 insertions(+), 30 deletions(-) diff --git a/flo2d/flo2d_tools/elevation_correctors.py b/flo2d/flo2d_tools/elevation_correctors.py index 4697f265..ca44f3f7 100644 --- a/flo2d/flo2d_tools/elevation_correctors.py +++ b/flo2d/flo2d_tools/elevation_correctors.py @@ -229,17 +229,10 @@ def elevation_from_lines(self): SET levcrest = ( SELECT ull.correction + ull.elev FROM user_levee_lines AS ull - JOIN grid AS g - ON ST_Intersects(CastAutomagic(g.geom), CastAutomagic(ull.geom)) - WHERE ull.fid IN ({fids}) AND g.fid = ld.grid_fid + WHERE ull.fid = ld.user_line_fid + LIMIT 1 ) - WHERE EXISTS ( - SELECT 1 - FROM user_levee_lines AS ull - JOIN grid AS g - ON ST_Intersects(CastAutomagic(g.geom), CastAutomagic(ull.geom)) - WHERE ull.fid IN ({fids}) AND g.fid = ld.grid_fid - ); + WHERE ld.user_line_fid IN ({fids}); """) if updates["elev_only"]: @@ -249,17 +242,10 @@ def elevation_from_lines(self): SET levcrest = ( SELECT ull.elev FROM user_levee_lines AS ull - JOIN grid AS g - ON ST_Intersects(CastAutomagic(g.geom), CastAutomagic(ull.geom)) - WHERE ull.fid IN ({fids}) AND g.fid = ld.grid_fid + WHERE ull.fid = ld.user_line_fid + LIMIT 1 ) - WHERE EXISTS ( - SELECT 1 - FROM user_levee_lines AS ull - JOIN grid AS g - ON ST_Intersects(CastAutomagic(g.geom), CastAutomagic(ull.geom)) - WHERE ull.fid IN ({fids}) AND g.fid = ld.grid_fid - ); + WHERE ld.user_line_fid IN ({fids}); """) if updates["cor_only"]: @@ -269,17 +255,10 @@ def elevation_from_lines(self): SET levcrest = levcrest + ( SELECT ull.correction FROM user_levee_lines AS ull - JOIN grid AS g - ON ST_Intersects(CastAutomagic(g.geom), CastAutomagic(ull.geom)) - WHERE ull.fid IN ({fids}) AND g.fid = ld.grid_fid + WHERE ull.fid = ld.user_line_fid + LIMIT 1 ) - WHERE EXISTS ( - SELECT 1 - FROM user_levee_lines AS ull - JOIN grid AS g - ON ST_Intersects(CastAutomagic(g.geom), CastAutomagic(ull.geom)) - WHERE ull.fid IN ({fids}) AND g.fid = ld.grid_fid - ); + WHERE ld.user_line_fid IN ({fids}); """)