Skip to content

Commit

Permalink
A simpler sql processing
Browse files Browse the repository at this point in the history
  • Loading branch information
rpachaly committed Jan 14, 2025
1 parent 75e7f42 commit bce488b
Showing 1 changed file with 9 additions and 30 deletions.
39 changes: 9 additions & 30 deletions flo2d/flo2d_tools/elevation_correctors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]:
Expand All @@ -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"]:
Expand All @@ -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});
""")


Expand Down

0 comments on commit bce488b

Please sign in to comment.