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 de39264
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 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';
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';

0 comments on commit de39264

Please sign in to comment.