Skip to content

Commit

Permalink
fix #163
Browse files Browse the repository at this point in the history
  • Loading branch information
smnorris committed Nov 20, 2024
1 parent 7fee205 commit 5db572b
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 16 deletions.
15 changes: 7 additions & 8 deletions db/functions/FWA_Downstream.sql
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ CREATE OR REPLACE FUNCTION whse_basemapping.FWA_Downstream(
localcode_ltree_b ltree
)

RETURNS boolean AS $$
RETURNS boolean language sql set search_path = public AS $$


SELECT
-- watershed code a is a descendant of watershed code b
Expand All @@ -87,7 +88,7 @@ SELECT
)

$$
language 'sql' immutable parallel safe;
immutable parallel safe;



Expand All @@ -105,9 +106,7 @@ CREATE OR REPLACE FUNCTION whse_basemapping.FWA_Downstream(
tolerance double precision default .001
)

RETURNS boolean AS $$


RETURNS boolean language sql set search_path = public AS $$

SELECT

Expand Down Expand Up @@ -186,7 +185,7 @@ RETURNS boolean AS $$
END

$$
language 'sql' immutable parallel safe;
immutable parallel safe;

CREATE OR REPLACE FUNCTION whse_basemapping.FWA_Downstream(
blue_line_key_a integer,
Expand All @@ -201,7 +200,7 @@ CREATE OR REPLACE FUNCTION whse_basemapping.FWA_Downstream(
tolerance double precision default .001
)

RETURNS boolean AS $$
RETURNS boolean language sql set search_path = public AS $$

SELECT
whse_basemapping.FWA_Downstream(
Expand All @@ -219,6 +218,6 @@ SELECT
)

$$
language 'sql' immutable parallel safe;
immutable parallel safe;

--COMMENT ON FUNCTION FWA_Downstream IS 'Compare input watershed codes and/or linear positions A and B, return TRUE if codes/positions A are downstream of codes/positions B';
1 change: 1 addition & 0 deletions db/functions/FWA_StreamsAsMVT.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ RETURNS bytea
AS $$
DECLARE
result bytea;

BEGIN
WITH

Expand Down
13 changes: 7 additions & 6 deletions db/functions/FWA_Upstream.sql
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ return TRUE when the values for b are upstream of the values for a.
*/

-- ensure the functions are created in the public schema
set search_path to public;

-- watershed code comparison only
CREATE OR REPLACE FUNCTION whse_basemapping.FWA_Upstream(
Expand All @@ -75,6 +73,8 @@ CREATE OR REPLACE FUNCTION whse_basemapping.FWA_Upstream(

RETURNS boolean AS $$

SET search_path TO public,whse_basemapping,usgs,hydrosheds;

SELECT
-- Simple case, where watershed code and local code of (a) are equivalent.
-- Return TRUE for all records in (b) that are children of (a)
Expand Down Expand Up @@ -130,7 +130,8 @@ CREATE OR REPLACE FUNCTION whse_basemapping.FWA_Upstream(
tolerance double precision default .001
)

RETURNS boolean AS $$
RETURNS boolean language sql set search_path = public AS $$


SELECT
-- b is a child of a, always
Expand Down Expand Up @@ -222,7 +223,7 @@ SELECT
END
)
$$
language 'sql' immutable parallel safe;
immutable parallel safe;


-- shortcut for points, dnstr measure a and upstr measure are equivalent
Expand All @@ -239,7 +240,7 @@ CREATE OR REPLACE FUNCTION whse_basemapping.FWA_Upstream(
tolerance double precision default .001
)

RETURNS boolean AS $$
RETURNS boolean language sql set search_path = public AS $$

SELECT
whse_basemapping.FWA_Upstream(
Expand All @@ -256,7 +257,7 @@ SELECT
tolerance
)
$$
language 'sql' immutable parallel safe;
immutable parallel safe;


--COMMENT ON FUNCTION FWA_Upstream IS 'Compare input watershed codes and/or linear positions A and B, return TRUE if codes/positions A are upstream of codes/positions B';
1 change: 1 addition & 0 deletions db/functions/FWA_UpstreamBorderCrossings.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ RETURNS text

AS $$


WITH local_segment AS
(
SELECT
Expand Down
1 change: 0 additions & 1 deletion db/functions/FWA_WatershedHex.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ declare
v_blkey integer := blue_line_key;
v_measure float := downstream_route_measure;


begin

return query
Expand Down
1 change: 0 additions & 1 deletion db/functions/FWA_WatershedStream.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ declare
v_blkey integer := blue_line_key;
v_measure float := downstream_route_measure;


begin

return query
Expand Down
1 change: 1 addition & 0 deletions db/functions/ST_Safe_Repair.sql
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ create or replace function ST_Safe_Repair(
message text default '[unspecified]'
) returns geometry as
$$

begin
if ST_IsEmpty(geom)
then
Expand Down
1 change: 1 addition & 0 deletions db/functions/hydroshed.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ AS

$$


WITH RECURSIVE walkup (hybas_id, geom) AS
(
SELECT hybas_id, wsd.geom
Expand Down

0 comments on commit 5db572b

Please sign in to comment.