From eaf4872fed65c40c39227377d462f6ea1f7019ff Mon Sep 17 00:00:00 2001 From: Gabe Wolofsky <80077912+gabrielwol@users.noreply.github.com> Date: Thu, 25 Jul 2024 16:57:57 -0400 Subject: [PATCH] #1015 replace gwolofs with gis --- .../sql/function-centreline_case1.sql | 10 +-- .../sql/function-centreline_case2.sql | 12 +-- .../sql/function-clean_bylaws_text.sql | 76 +++++++++---------- .../sql/function-get_entire_length.sql | 6 +- .../sql/function-get_intersection_geom.sql | 12 +-- .../sql/function-get_lines_btwn_interxn.sql | 6 +- .../sql/function-text_to_centreline.sql | 34 ++++----- .../sql/function-text_to_centreline_geom.sql | 14 ++-- .../helper_functions/function-abbr_street.sql | 2 +- .../function-bylaws_get_id_to_route.sql | 10 +-- .../function-bylaws_route_id.sql | 6 +- .../function-get_intersection_id.sql | 4 +- ...et_intersection_id_highway_equals_btwn.sql | 6 +- .../function-translate_intersection_point.sql | 4 +- 14 files changed, 101 insertions(+), 101 deletions(-) diff --git a/gis/text_to_centreline/sql/function-centreline_case1.sql b/gis/text_to_centreline/sql/function-centreline_case1.sql index 44213243e..df0a3290e 100644 --- a/gis/text_to_centreline/sql/function-centreline_case1.sql +++ b/gis/text_to_centreline/sql/function-centreline_case1.sql @@ -1,6 +1,6 @@ -DROP FUNCTION IF EXISTS gwolofs._centreline_case1 (text, text, text, double precision); +DROP FUNCTION IF EXISTS gis._centreline_case1 (text, text, text, double precision); -CREATE OR REPLACE FUNCTION gwolofs._centreline_case1( +CREATE OR REPLACE FUNCTION gis._centreline_case1( highway2 text, btwn2 text, direction_btwn2 text, @@ -63,7 +63,7 @@ WITH get_int AS ST_MakeLine(oid_geom, oid_geom_translated) AS new_line, -- line from the intersection point to the translated point int_id_found AS int1, get_geom.lev_sum - FROM gwolofs._get_intersection_geom(highway2, btwn2, direction_btwn2, metres_btwn2, 0) get_geom + FROM gis._get_intersection_geom(highway2, btwn2, direction_btwn2, metres_btwn2, 0) get_geom ), get_lines AS ( @@ -242,5 +242,5 @@ EXCEPTION WHEN SQLSTATE 'XX000' THEN END; $BODY$; -ALTER FUNCTION gwolofs._centreline_case1(text, text, text, double precision) -OWNER TO gwolofs; +ALTER FUNCTION gis._centreline_case1(text, text, text, double precision) +OWNER TO gis_admins; diff --git a/gis/text_to_centreline/sql/function-centreline_case2.sql b/gis/text_to_centreline/sql/function-centreline_case2.sql index b5de798e9..2863f3822 100644 --- a/gis/text_to_centreline/sql/function-centreline_case2.sql +++ b/gis/text_to_centreline/sql/function-centreline_case2.sql @@ -1,7 +1,7 @@ -DROP FUNCTION IF EXISTS gwolofs._centreline_case2 ( +DROP FUNCTION IF EXISTS gis._centreline_case2 ( text, text, text, double precision, text, text, double precision, text, text ); -CREATE OR REPLACE FUNCTION gwolofs._centreline_case2( +CREATE OR REPLACE FUNCTION gis._centreline_case2( highway2 text, btwn1 text, direction_btwn1 text, @@ -69,12 +69,12 @@ CREATE TEMP TABLE IF NOT EXISTS _wip2 ( TRUNCATE TABLE _wip2; - _int1_result := gwolofs._get_intersection_geom(highway2, btwn1, direction_btwn1, metres_btwn1, 0); + _int1_result := gis._get_intersection_geom(highway2, btwn1, direction_btwn1, metres_btwn1, 0); _int2_result := ( CASE WHEN btwn2_orig LIKE '%point%' AND (btwn2_check NOT LIKE '% of %' OR btwn2_check LIKE ('% of ' || TRIM(btwn1))) - THEN gwolofs._get_intersection_geom(highway2, btwn2, direction_btwn2, metres_btwn2, 0) - ELSE gwolofs._get_intersection_geom(highway2, btwn2, direction_btwn2, metres_btwn2, _int1_result.int_id_found) + THEN gis._get_intersection_geom(highway2, btwn2, direction_btwn2, metres_btwn2, 0) + ELSE gis._get_intersection_geom(highway2, btwn2, direction_btwn2, metres_btwn2, _int1_result.int_id_found) END ); @@ -84,7 +84,7 @@ TRUNCATE TABLE _wip2; _int1_result.oid_geom AS oid1_geom, _int1_result.oid_geom_translated AS oid1_geom_translated, _int2_result.oid_geom AS oid2_geom, _int2_result.oid_geom_translated AS oid2_geom_translated, rout.objectid, rout.fcode, rout.fcode_desc, _int1_result.lev_sum + _int2_result.lev_sum - FROM gwolofs._get_lines_btwn_interxn(highway2, _int1_result.int_id_found, _int2_result.int_id_found) rout; + FROM gis._get_lines_btwn_interxn(highway2, _int1_result.int_id_found, _int2_result.int_id_found) rout; --those centreline found from buffer are where int_start, int_end, seq, lev_sum = NULL INSERT INTO _wip2 (geo_id, lf_name, ind_line_geom, new_line1, new_line2, diff --git a/gis/text_to_centreline/sql/function-clean_bylaws_text.sql b/gis/text_to_centreline/sql/function-clean_bylaws_text.sql index d37045afa..0829f67e1 100644 --- a/gis/text_to_centreline/sql/function-clean_bylaws_text.sql +++ b/gis/text_to_centreline/sql/function-clean_bylaws_text.sql @@ -1,5 +1,5 @@ --First create a table -CREATE TABLE IF NOT EXISTS gwolofs.cleaned_bylaws_text ( +CREATE TABLE IF NOT EXISTS gis.cleaned_bylaws_text ( bylaw_id int, highway2 text, btwn1 text, @@ -13,11 +13,11 @@ CREATE TABLE IF NOT EXISTS gwolofs.cleaned_bylaws_text ( ); --Then, create a function -DROP FUNCTION IF EXISTS gwolofs._clean_bylaws_text(int, text, text, text); -CREATE OR REPLACE FUNCTION gwolofs._clean_bylaws_text( +DROP FUNCTION IF EXISTS gis._clean_bylaws_text(int, text, text, text); +CREATE OR REPLACE FUNCTION gis._clean_bylaws_text( _bylaw_id int, highway text, frm text, t text ) -RETURNS gwolofs.cleaned_bylaws_text +RETURNS gis.cleaned_bylaws_text LANGUAGE 'plpgsql' AS $$ @@ -29,7 +29,7 @@ DECLARE -- when the input was btwn instead of from and to btwn1_v1 text := CASE WHEN t IS NULL THEN - gwolofs.abbr_street(regexp_REPLACE + gis.abbr_street(regexp_REPLACE (regexp_REPLACE (regexp_REPLACE (split_part @@ -43,7 +43,7 @@ DECLARE , '[Bb]etween ', '', 'g') , 'A point', '', 'g')) - ELSE gwolofs.abbr_street(regexp_REPLACE + ELSE gis.abbr_street(regexp_REPLACE (regexp_REPLACE (regexp_REPLACE(frm, '\(.*?\)', '', 'g') , '[0123456789.,]* metres (north|south|east|west|East|northeast|northwest|southwest|southeast) of ', '', 'g') @@ -60,7 +60,7 @@ DECLARE btwn2_orig_v1 text := CASE WHEN t IS NULL THEN (CASE WHEN split_part(regexp_REPLACE(frm, '\(.*?\)', '', 'g'), ' and ', 2) <> '' - THEN gwolofs.abbr_street(regexp_REPLACE + THEN gis.abbr_street(regexp_REPLACE (split_part (regexp_REPLACE (regexp_REPLACE @@ -72,7 +72,7 @@ DECLARE , '[Bb]etween |(A point)|(thereof)|(the northeast of)', '', 'g')) WHEN split_part(frm, ' to ', 2) <> '' - THEN gwolofs.abbr_street(regexp_REPLACE + THEN gis.abbr_street(regexp_REPLACE (regexp_REPLACE (split_part (regexp_REPLACE @@ -86,7 +86,7 @@ DECLARE END) ELSE - gwolofs.abbr_street(regexp_REPLACE + gis.abbr_street(regexp_REPLACE (regexp_REPLACE (regexp_REPLACE (regexp_REPLACE(t, '\(.*?\)', '', 'g') @@ -103,12 +103,12 @@ DECLARE END ); - highway2 text := gwolofs.abbr_street(highway); + highway2 text := gis.abbr_street(highway); direction_btwn1 text := CASE WHEN t IS NULL THEN ( CASE WHEN btwn1 LIKE '% m %' - OR gwolofs.abbr_street( regexp_REPLACE + OR gis.abbr_street( regexp_REPLACE (split_part (split_part (frm, ' to ', 1) @@ -116,7 +116,7 @@ DECLARE , '[Bb]etween ', '', 'g')) LIKE '% m %' THEN split_part (split_part - (gwolofs.abbr_street + (gis.abbr_street (regexp_REPLACE (regexp_REPLACE (regexp_REPLACE @@ -134,11 +134,11 @@ DECLARE ELSE ( CASE WHEN btwn1 LIKE '% m %' - OR gwolofs.abbr_street(frm) LIKE '% m %' + OR gis.abbr_street(frm) LIKE '% m %' THEN regexp_replace(regexp_replace (split_part (split_part - (gwolofs.abbr_street(frm), ' m ', 2) + (gis.abbr_street(frm), ' m ', 2) , ' of ', 1) , 'further ', '', 'g') , 'east/north', 'northeast', 'g') @@ -152,17 +152,17 @@ DECLARE OR ( CASE WHEN split_part(frm, ' and ', 2) <> '' - THEN gwolofs.abbr_street( regexp_REPLACE(split_part(frm, ' and ', 2), '[Bb]etween ', '', 'g')) + THEN gis.abbr_street( regexp_REPLACE(split_part(frm, ' and ', 2), '[Bb]etween ', '', 'g')) WHEN split_part(frm, ' to ', 2) <> '' - THEN gwolofs.abbr_street( regexp_REPLACE(split_part(frm, ' to ', 2), '[Bb]etween ', '', 'g')) + THEN gis.abbr_street( regexp_REPLACE(split_part(frm, ' to ', 2), '[Bb]etween ', '', 'g')) END ) LIKE '% m %' THEN ( CASE WHEN split_part(frm, ' and ', 2) <> '' - THEN regexp_REPLACE(regexp_replace(split_part(split_part( gwolofs.abbr_street(regexp_REPLACE(split_part(frm, ' and ', 2), '[Bb]etween ', '', 'g')), ' m ', 2), ' of ', 1), 'further | thereof', '', 'g'), 'east/north', 'northeast', 'g') + THEN regexp_REPLACE(regexp_replace(split_part(split_part( gis.abbr_street(regexp_REPLACE(split_part(frm, ' and ', 2), '[Bb]etween ', '', 'g')), ' m ', 2), ' of ', 1), 'further | thereof', '', 'g'), 'east/north', 'northeast', 'g') WHEN split_part(frm, ' to ', 2) <> '' - THEN regexp_REPLACE(regexp_replace(split_part(split_part(gwolofs.abbr_street(regexp_REPLACE(split_part(frm, ' to ', 2), '[Bb]etween ', '', 'g')), ' m ', 2), ' of ', 1), 'further | thereof', '', 'g'), 'east/north', 'northeast', 'g') + THEN regexp_REPLACE(regexp_replace(split_part(split_part(gis.abbr_street(regexp_REPLACE(split_part(frm, ' to ', 2), '[Bb]etween ', '', 'g')), ' m ', 2), ' of ', 1), 'further | thereof', '', 'g'), 'east/north', 'northeast', 'g') END ) ELSE NULL @@ -170,9 +170,9 @@ DECLARE ELSE ( CASE WHEN btwn2_orig LIKE '% m %' - OR gwolofs.abbr_street(t) LIKE '% m %' + OR gis.abbr_street(t) LIKE '% m %' THEN - regexp_REPLACE(regexp_replace(split_part(split_part(gwolofs.abbr_street(t), ' m ', 2), ' of ', 1), 'further ', '', 'g'), 'east/north', 'northeast', 'g') + regexp_REPLACE(regexp_replace(split_part(split_part(gis.abbr_street(t), ' m ', 2), ' of ', 1), 'further ', '', 'g'), 'east/north', 'northeast', 'g') ELSE NULL END ) @@ -182,7 +182,7 @@ DECLARE metres_btwn1 float := (CASE WHEN t IS NULL THEN ( CASE WHEN btwn1 LIKE '% m %' - OR gwolofs.abbr_street(regexp_REPLACE + OR gis.abbr_street(regexp_REPLACE (split_part (split_part(frm, ' to ', 1) , ' and ', 1) @@ -191,7 +191,7 @@ DECLARE (regexp_REPLACE (regexp_REPLACE (split_part - (gwolofs.abbr_street + (gis.abbr_street (regexp_REPLACE (split_part (split_part(frm, ' to ', 1) @@ -207,12 +207,12 @@ DECLARE ELSE ( CASE WHEN btwn1 LIKE '% m %' - OR gwolofs.abbr_street(frm) LIKE '% m %' + OR gis.abbr_street(frm) LIKE '% m %' THEN regexp_REPLACE (regexp_REPLACE (regexp_REPLACE (split_part - (gwolofs.abbr_street(frm), ' m ' ,1) + (gis.abbr_street(frm), ' m ' ,1) , 'a point ', '', 'g') , 'A point', '', 'g') , ',', 'g')::float @@ -226,18 +226,18 @@ DECLARE ( CASE WHEN btwn2_orig LIKE '% m %' OR ( CASE WHEN split_part(frm, ' and ', 2) <> '' - THEN gwolofs.abbr_street( regexp_REPLACE(regexp_REPLACE(split_part(frm, ' and ', 2), '\(.*?\)', '', 'g'), '[Bb]etween ', '', 'g')) + THEN gis.abbr_street( regexp_REPLACE(regexp_REPLACE(split_part(frm, ' and ', 2), '\(.*?\)', '', 'g'), '[Bb]etween ', '', 'g')) WHEN split_part(frm, ' to ', 2) <> '' - THEN gwolofs.abbr_street( regexp_REPLACE(regexp_REPLACE(split_part(frm, ' to ', 2), '\(.*?\)', '', 'g'), '[Bb]etween ', '', 'g')) + THEN gis.abbr_street( regexp_REPLACE(regexp_REPLACE(split_part(frm, ' to ', 2), '\(.*?\)', '', 'g'), '[Bb]etween ', '', 'g')) END ) LIKE '% m %' THEN ( CASE WHEN split_part(frm, ' and ', 2) <> '' - THEN regexp_REPLACE(regexp_REPLACE(regexp_REPLACE(split_part( gwolofs.abbr_street( regexp_REPLACE(regexp_REPLACE(split_part(frm, ' and ', 2), '\(.*\)', '', 'g'), '[Bb]etween ', '', 'g')), ' m ', 1), 'a point ', '', 'g'), 'A point', '', 'g'), ',', '', 'g')::float + THEN regexp_REPLACE(regexp_REPLACE(regexp_REPLACE(split_part( gis.abbr_street( regexp_REPLACE(regexp_REPLACE(split_part(frm, ' and ', 2), '\(.*\)', '', 'g'), '[Bb]etween ', '', 'g')), ' m ', 1), 'a point ', '', 'g'), 'A point', '', 'g'), ',', '', 'g')::float WHEN split_part(frm, ' to ', 2) <> '' - THEN regexp_REPLACE(regexp_REPLACE(regexp_REPLACE(split_part(gwolofs.abbr_street( regexp_REPLACE(regexp_REPLACE(split_part(frm, ' to ', 2), '\(.*\)', '', 'g'), '[Bb]etween ', '', 'g')), ' m ', 1), 'a point ', '', 'g'), 'A point', '', 'g'), ',', '', 'g')::float + THEN regexp_REPLACE(regexp_REPLACE(regexp_REPLACE(split_part(gis.abbr_street( regexp_REPLACE(regexp_REPLACE(split_part(frm, ' to ', 2), '\(.*\)', '', 'g'), '[Bb]etween ', '', 'g')), ' m ', 1), 'a point ', '', 'g'), 'A point', '', 'g'), ',', '', 'g')::float END ) ELSE NULL @@ -246,9 +246,9 @@ DECLARE ELSE ( CASE WHEN btwn2_orig LIKE '% m %' - OR gwolofs.abbr_street(t) LIKE '% m %' + OR gis.abbr_street(t) LIKE '% m %' THEN - regexp_REPLACE(regexp_REPLACE(regexp_REPLACE(split_part(gwolofs.abbr_street(t), ' m ', 1), 'a point ', '', 'g'), 'A point', '', 'g'), ',', '', 'g')::float + regexp_REPLACE(regexp_REPLACE(regexp_REPLACE(split_part(gis.abbr_street(t), ' m ', 1), 'a point ', '', 'g'), 'A point', '', 'g'), ',', '', 'g')::float ELSE NULL END ) @@ -262,13 +262,13 @@ DECLARE -- the difference between the two is that one of the cases has a 'of' to describe the second road that intersects with "street"/"highway2" btwn2_check text := CASE WHEN t IS NULL THEN (CASE WHEN split_part(frm, ' and ', 2) <> '' - THEN gwolofs.abbr_street(regexp_REPLACE(regexp_REPLACE(split_part(frm, ' and ', 2), '[Bb]etween ', '', 'g'), 'A point', '', 'g')) + THEN gis.abbr_street(regexp_REPLACE(regexp_REPLACE(split_part(frm, ' and ', 2), '[Bb]etween ', '', 'g'), 'A point', '', 'g')) WHEN split_part(frm, ' to ', 2) <> '' - THEN gwolofs.abbr_street(regexp_REPLACE(regexp_REPLACE(split_part(frm, ' to ', 2), '[Bb]etween ', '', 'g'), 'A point', '', 'g')) + THEN gis.abbr_street(regexp_REPLACE(regexp_REPLACE(split_part(frm, ' to ', 2), '[Bb]etween ', '', 'g'), 'A point', '', 'g')) END) ELSE - gwolofs.abbr_street(t) + gis.abbr_street(t) END ; @@ -277,8 +277,8 @@ DECLARE -- for case one -- i.e. Watson road from St. Mark's Road to a point 100 metres north -- we want the btwn2 to be St. Mark's Road (which is also btwn1) - THEN TRIM(gwolofs.abbr_street(btwn1)) - ELSE TRIM(gwolofs.abbr_street(regexp_replace(btwn2_orig , 'a point', '', 'g'))) + THEN TRIM(gis.abbr_street(btwn1)) + ELSE TRIM(gis.abbr_street(regexp_replace(btwn2_orig , 'a point', '', 'g'))) END ); @@ -287,7 +287,7 @@ RAISE NOTICE 'btwn1: %, btwn2: %, btwn2_check: %, highway2: %, metres_btwn1: %, btwn1, btwn2, btwn2_check, highway2, metres_btwn1, metres_btwn2, direction_btwn1, direction_btwn2; RETURN ROW(_bylaw_id, highway2, btwn1, direction_btwn1, metres_btwn1, btwn2, direction_btwn2, metres_btwn2, -btwn2_orig, btwn2_check)::gwolofs.cleaned_bylaws_text ; +btwn2_orig, btwn2_check)::gis.cleaned_bylaws_text ; END; $$; @@ -296,9 +296,9 @@ $$; --For testing purposes only DO $$ DECLARE - return_test gwolofs.cleaned_bylaws_text; --the table + return_test gis.cleaned_bylaws_text; --the table BEGIN - return_test := gwolofs._clean_bylaws_text(123::int, 'Chesham Drive'::text, 'The west end of Chesham Drive and Heathrow Drive'::text, NULL::text); --the function + return_test := gis._clean_bylaws_text(123::int, 'Chesham Drive'::text, 'The west end of Chesham Drive and Heathrow Drive'::text, NULL::text); --the function RAISE NOTICE 'Testing 123'; END; $$ LANGUAGE 'plpgsql'; diff --git a/gis/text_to_centreline/sql/function-get_entire_length.sql b/gis/text_to_centreline/sql/function-get_entire_length.sql index 9678035e3..325c5437a 100644 --- a/gis/text_to_centreline/sql/function-get_entire_length.sql +++ b/gis/text_to_centreline/sql/function-get_entire_length.sql @@ -1,5 +1,5 @@ -DROP FUNCTION IF EXISTS gwolofs._get_entire_length (text); -CREATE OR REPLACE FUNCTION gwolofs._get_entire_length(highway2_before_editing text) +DROP FUNCTION IF EXISTS gis._get_entire_length (text); +CREATE OR REPLACE FUNCTION gis._get_entire_length(highway2_before_editing text) RETURNS TABLE ( centreline_id integer, linear_name_full text, @@ -40,6 +40,6 @@ RAISE NOTICE 'Entire segment found for %', highway2_before_editing; END; $BODY$; -COMMENT ON FUNCTION gwolofs._get_entire_length(text) IS ' +COMMENT ON FUNCTION gis._get_entire_length(text) IS ' For bylaws with ''Entire Length'', get all the individual line_geom that constitute the whole road segment from gis_core.centreline_latest table.'; diff --git a/gis/text_to_centreline/sql/function-get_intersection_geom.sql b/gis/text_to_centreline/sql/function-get_intersection_geom.sql index e9cad57e3..b29b3e3ae 100644 --- a/gis/text_to_centreline/sql/function-get_intersection_geom.sql +++ b/gis/text_to_centreline/sql/function-get_intersection_geom.sql @@ -1,7 +1,7 @@ -DROP FUNCTION IF EXISTS gwolofs._get_intersection_geom ( +DROP FUNCTION IF EXISTS gis._get_intersection_geom ( text, text, text, double precision, integer ); -CREATE OR REPLACE FUNCTION gwolofs._get_intersection_geom( +CREATE OR REPLACE FUNCTION gis._get_intersection_geom( highway2 text, btwn text, direction text, metres float, not_int_id int, OUT oid_geom geometry, OUT oid_geom_translated geometry, @@ -20,8 +20,8 @@ oid_geom_test geometry; BEGIN int_arr := (CASE WHEN TRIM(highway2) = TRIM(btwn) - THEN (gwolofs._get_intersection_id_highway_equals_btwn(highway2, btwn, not_int_id)) - ELSE (gwolofs._get_intersection_id(highway2, btwn, not_int_id)) + THEN (gis._get_intersection_id_highway_equals_btwn(highway2, btwn, not_int_id)) + ELSE (gis._get_intersection_id(highway2, btwn, not_int_id)) END); oid_int := int_arr[1]; @@ -37,7 +37,7 @@ oid_geom_test := ( oid_geom_translated := ( CASE WHEN direction IS NOT NULL OR metres IS NOT NULL THEN (SELECT * - FROM gwolofs._translate_intersection_point(oid_geom_test, metres, direction) translated_geom) + FROM gis._translate_intersection_point(oid_geom_test, metres, direction) translated_geom) ELSE NULL END ); @@ -53,7 +53,7 @@ oid_int, ST_AsText(oid_geom), ST_AsText(oid_geom_translated), direction, metres: END; $BODY$; -COMMENT ON FUNCTION gwolofs._get_intersection_geom( +COMMENT ON FUNCTION gis._get_intersection_geom( text, text, text, float, int ) IS ' Input values of the names of two intersections, direction (may be NULL), number of units the intersection should be translated, diff --git a/gis/text_to_centreline/sql/function-get_lines_btwn_interxn.sql b/gis/text_to_centreline/sql/function-get_lines_btwn_interxn.sql index 1a44f7c2a..1ecaf519a 100644 --- a/gis/text_to_centreline/sql/function-get_lines_btwn_interxn.sql +++ b/gis/text_to_centreline/sql/function-get_lines_btwn_interxn.sql @@ -1,7 +1,7 @@ --USING centrelines aka GIS network -DROP FUNCTION IF EXISTS gwolofs._get_lines_btwn_interxn; +DROP FUNCTION IF EXISTS gis._get_lines_btwn_interxn; -CREATE OR REPLACE FUNCTION gwolofs._get_lines_btwn_interxn( +CREATE OR REPLACE FUNCTION gis._get_lines_btwn_interxn( _highway2 text, _int_start integer, _int_end integer @@ -44,7 +44,7 @@ WITH results AS ( _int_start::bigint, _int_end::bigint, FALSE ) AS dijkstra --or do pgr_dijkstra('SELECT id, source::int, target::int, - --CASE lf_name WHEN '''|| _highway2 ||''' THEN (0.3*cost)::float ELSE cost END AS cost from gwolofs.centreline_routing_undirected_lfname'::text, ... ) + --CASE lf_name WHEN '''|| _highway2 ||''' THEN (0.3*cost)::float ELSE cost END AS cost from gis.centreline_routing_undirected_lfname'::text, ... ) ) SELECT results._int_start, diff --git a/gis/text_to_centreline/sql/function-text_to_centreline.sql b/gis/text_to_centreline/sql/function-text_to_centreline.sql index bd4b9b1c6..db719631c 100644 --- a/gis/text_to_centreline/sql/function-text_to_centreline.sql +++ b/gis/text_to_centreline/sql/function-text_to_centreline.sql @@ -1,6 +1,6 @@ -DROP FUNCTION IF EXISTS gwolofs.text_to_centreline; +DROP FUNCTION IF EXISTS gis.text_to_centreline; -CREATE OR REPLACE FUNCTION gwolofs.text_to_centreline( +CREATE OR REPLACE FUNCTION gis.text_to_centreline( _bylaw_id integer, highway text, frm text, @@ -44,7 +44,7 @@ DECLARE BEGIN --STEP 1 -- clean bylaws text - clean_bylaws := gwolofs._clean_bylaws_text( + clean_bylaws := gis._clean_bylaws_text( _bylaw_id := text_to_centreline._bylaw_id, highway := text_to_centreline.highway, frm := text_to_centreline.frm, @@ -79,7 +79,7 @@ BEGIN RAISE NOTICE 'Using entire length case.'; INSERT INTO _results(geo_id, lf_name, objectid, line_geom, fcode, fcode_desc) SELECT gel.centreline_id, gel.linear_name_full, gel.objectid, gel.geom, gel.feature_code, gel.feature_code_desc - FROM gwolofs._get_entire_length(clean_bylaws.highway2) AS gel; + FROM gis._get_entire_length(clean_bylaws.highway2) AS gel; --lev_total := NULL --normal cases @@ -87,11 +87,11 @@ BEGIN THEN RAISE NOTICE 'Using normal case.'; - int1_result := gwolofs._get_intersection_geom(clean_bylaws.highway2, clean_bylaws.btwn1, clean_bylaws.direction_btwn1, clean_bylaws.metres_btwn1, 0); + int1_result := gis._get_intersection_geom(clean_bylaws.highway2, clean_bylaws.btwn1, clean_bylaws.direction_btwn1, clean_bylaws.metres_btwn1, 0); int2_result := (CASE WHEN clean_bylaws.btwn2_orig ILIKE '%point%' AND (clean_bylaws.btwn2_check NOT ILIKE '% of %' OR clean_bylaws.btwn2_check ILIKE ('% of ' || TRIM(clean_bylaws.btwn1))) - THEN gwolofs._get_intersection_geom(clean_bylaws.highway2, clean_bylaws.btwn2, clean_bylaws.direction_btwn2, clean_bylaws.metres_btwn2, 0) - ELSE gwolofs._get_intersection_geom(clean_bylaws.highway2, clean_bylaws.btwn2, clean_bylaws.direction_btwn2, clean_bylaws.metres_btwn2, int1_result.int_id_found) + THEN gis._get_intersection_geom(clean_bylaws.highway2, clean_bylaws.btwn2, clean_bylaws.direction_btwn2, clean_bylaws.metres_btwn2, 0) + ELSE gis._get_intersection_geom(clean_bylaws.highway2, clean_bylaws.btwn2, clean_bylaws.direction_btwn2, clean_bylaws.metres_btwn2, int1_result.int_id_found) END); INSERT INTO _results(int_start, int_end, seq, geo_id, lf_name, line_geom, @@ -100,7 +100,7 @@ BEGIN int1_result.oid_geom AS oid1_geom, int1_result.oid_geom_translated AS oid1_geom_translated, int2_result.oid_geom AS oid2_geom, int2_result.oid_geom_translated AS oid2_geom_translated, rout.objectid, rout.fcode, rout.fcode_desc - FROM gwolofs._get_lines_btwn_interxn(clean_bylaws.highway2, int1_result.int_id_found, int2_result.int_id_found) rout; + FROM gis._get_lines_btwn_interxn(clean_bylaws.highway2, int1_result.int_id_found, int2_result.int_id_found) rout; -- sum of the levenshtein distance of both of the intersections matched UPDATE _results SET lev_sum = int1_result.lev_sum + int2_result.lev_sum; @@ -112,7 +112,7 @@ BEGIN INSERT INTO _results(int_start, geo_id, lf_name, line_geom, section, oid1_geom, oid1_geom_translated, objectid, fcode, fcode_desc, lev_sum) SELECT case1.int1, case1.geo_id, case1.lf_name, case1.line_geom, case1.section, case1.oid1_geom, case1.oid1_geom_translated, case1.objectid, case1.fcode, case1.fcode_desc, case1.lev_sum - FROM gwolofs._centreline_case1(clean_bylaws.highway2, clean_bylaws.btwn2, clean_bylaws.direction_btwn2, clean_bylaws.metres_btwn2) case1; + FROM gis._centreline_case1(clean_bylaws.highway2, clean_bylaws.btwn2, clean_bylaws.direction_btwn2, clean_bylaws.metres_btwn2) case1; --interxns_and_offsets ELSE @@ -122,7 +122,7 @@ BEGIN SELECT case2.int_start, case2.int_end, case2.seq, case2.geo_id, case2.lf_name, case2.line_geom, case2.section, case2.oid1_geom, case2.oid1_geom_translated, case2.oid2_geom, case2.oid2_geom_translated, case2.objectid, case2.fcode, case2.fcode_desc, case2.lev_sum - FROM gwolofs._centreline_case2(clean_bylaws.highway2, clean_bylaws.btwn1, clean_bylaws.direction_btwn1, clean_bylaws.metres_btwn1, + FROM gis._centreline_case2(clean_bylaws.highway2, clean_bylaws.btwn1, clean_bylaws.direction_btwn1, clean_bylaws.metres_btwn1, clean_bylaws.btwn2, clean_bylaws.direction_btwn2, clean_bylaws.metres_btwn2, clean_bylaws.btwn2_orig, clean_bylaws.btwn2_check) case2 ; END IF; @@ -168,22 +168,22 @@ EXCEPTION WHEN SQLSTATE 'XX000' THEN END; $BODY$; -ALTER FUNCTION gwolofs.text_to_centreline(integer, text, text, text) -OWNER TO gwolofs; +ALTER FUNCTION gis.text_to_centreline(integer, text, text, text) +OWNER TO gis_admins; -GRANT EXECUTE ON FUNCTION gwolofs.text_to_centreline( +GRANT EXECUTE ON FUNCTION gis.text_to_centreline( integer, text, text, text ) TO bdit_humans; -GRANT EXECUTE ON FUNCTION gwolofs.text_to_centreline( +GRANT EXECUTE ON FUNCTION gis.text_to_centreline( integer, text, text, text -) TO gwolofs; +) TO gis_admins; -REVOKE ALL ON FUNCTION gwolofs.text_to_centreline( +REVOKE ALL ON FUNCTION gis.text_to_centreline( integer, text, text, text ) FROM public; -COMMENT ON FUNCTION gwolofs.text_to_centreline(integer, text, text, text) +COMMENT ON FUNCTION gis.text_to_centreline(integer, text, text, text) IS ' The main function for converting text descriptions of locations where bylaws are in effect to centreline segment geometry Check out README in https://github.com/CityofToronto/bdit_data-sources/tree/master/gis/text_to_centreline for more information diff --git a/gis/text_to_centreline/sql/function-text_to_centreline_geom.sql b/gis/text_to_centreline/sql/function-text_to_centreline_geom.sql index 07f83066f..426505b15 100644 --- a/gis/text_to_centreline/sql/function-text_to_centreline_geom.sql +++ b/gis/text_to_centreline/sql/function-text_to_centreline_geom.sql @@ -1,8 +1,8 @@ --- FUNCTION: gwolofs.text_to_centreline_geom(text, text, text) +-- FUNCTION: gis.text_to_centreline_geom(text, text, text) -DROP FUNCTION IF EXISTS gwolofs.text_to_centreline_geom (text, text, text); +DROP FUNCTION IF EXISTS gis.text_to_centreline_geom (text, text, text); -CREATE OR REPLACE FUNCTION gwolofs.text_to_centreline_geom( +CREATE OR REPLACE FUNCTION gis.text_to_centreline_geom( _street text, _from_loc text, _to_loc text, @@ -17,17 +17,17 @@ AS $BODY$ BEGIN _return_geom := ST_LINEMERGE(ST_Union(line_geom)) AS geom FROM -gwolofs.text_to_centreline(0, +gis.text_to_centreline(0, _street , _from_loc , _to_loc); END; $BODY$; -ALTER FUNCTION gwolofs.text_to_centreline_geom(text, text, text) OWNER TO gwolofs; +ALTER FUNCTION gis.text_to_centreline_geom(text, text, text) OWNER TO gis_admins; -GRANT EXECUTE ON FUNCTION gwolofs.text_to_centreline_geom(text, text, text) TO bdit_humans; -COMMENT ON FUNCTION gwolofs.text_to_centreline_geom(text, text, text) IS +GRANT EXECUTE ON FUNCTION gis.text_to_centreline_geom(text, text, text) TO bdit_humans; +COMMENT ON FUNCTION gis.text_to_centreline_geom(text, text, text) IS 'Wrapper function to the text to centreline functions to return only a single line geometry. _street is the streetname _from_loc is the starting point, preferably a street name of an intersection diff --git a/gis/text_to_centreline/sql/helper_functions/function-abbr_street.sql b/gis/text_to_centreline/sql/helper_functions/function-abbr_street.sql index d55eb48b6..dd8a54ddd 100644 --- a/gis/text_to_centreline/sql/helper_functions/function-abbr_street.sql +++ b/gis/text_to_centreline/sql/helper_functions/function-abbr_street.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE FUNCTION gwolofs.abbr_street( +CREATE OR REPLACE FUNCTION gis.abbr_street( _input_street text ) RETURNS text diff --git a/gis/text_to_centreline/sql/helper_functions/function-bylaws_get_id_to_route.sql b/gis/text_to_centreline/sql/helper_functions/function-bylaws_get_id_to_route.sql index 5562799dd..0b151d355 100644 --- a/gis/text_to_centreline/sql/helper_functions/function-bylaws_get_id_to_route.sql +++ b/gis/text_to_centreline/sql/helper_functions/function-bylaws_get_id_to_route.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE FUNCTION gwolofs.bylaws_get_id_to_route( +CREATE OR REPLACE FUNCTION gis.bylaws_get_id_to_route( _bylaw_id integer, highway text, frm text, @@ -30,7 +30,7 @@ BEGIN --STEP 1 -- clean bylaws text - clean_bylaws := gwolofs._clean_bylaws_text(_bylaw_id, highway, frm, t); + clean_bylaws := gis._clean_bylaws_text(_bylaw_id, highway, frm, t); --STEP 2 -- get centrelines geoms @@ -45,11 +45,11 @@ BEGIN lev_sum2 int ); -int1_result := gwolofs._get_intersection_geom(clean_bylaws.highway2, clean_bylaws.btwn1, clean_bylaws.direction_btwn1, clean_bylaws.metres_btwn1, 0); +int1_result := gis._get_intersection_geom(clean_bylaws.highway2, clean_bylaws.btwn1, clean_bylaws.direction_btwn1, clean_bylaws.metres_btwn1, 0); int2_result := (CASE WHEN clean_bylaws.btwn2_orig LIKE '%point%' AND (clean_bylaws.btwn2_check NOT LIKE '% of %' OR clean_bylaws.btwn2_check LIKE ('% of ' || TRIM(clean_bylaws.btwn1))) - THEN gwolofs._get_intersection_geom(clean_bylaws.highway2, clean_bylaws.btwn2, clean_bylaws.direction_btwn2, clean_bylaws.metres_btwn2, 0) - ELSE gwolofs._get_intersection_geom(clean_bylaws.highway2, clean_bylaws.btwn2, clean_bylaws.direction_btwn2, clean_bylaws.metres_btwn2, int1_result.int_id_found) + THEN gis._get_intersection_geom(clean_bylaws.highway2, clean_bylaws.btwn2, clean_bylaws.direction_btwn2, clean_bylaws.metres_btwn2, 0) + ELSE gis._get_intersection_geom(clean_bylaws.highway2, clean_bylaws.btwn2, clean_bylaws.direction_btwn2, clean_bylaws.metres_btwn2, int1_result.int_id_found) END); INSERT INTO _results(int_start, int_end, diff --git a/gis/text_to_centreline/sql/helper_functions/function-bylaws_route_id.sql b/gis/text_to_centreline/sql/helper_functions/function-bylaws_route_id.sql index e5fd36e9c..a42067f6e 100644 --- a/gis/text_to_centreline/sql/helper_functions/function-bylaws_route_id.sql +++ b/gis/text_to_centreline/sql/helper_functions/function-bylaws_route_id.sql @@ -1,6 +1,6 @@ -DROP FUNCTION IF EXISTS gwolofs.bylaws_route_id; +DROP FUNCTION IF EXISTS gis.bylaws_route_id; -CREATE OR REPLACE FUNCTION gwolofs.bylaws_route_id( +CREATE OR REPLACE FUNCTION gis.bylaws_route_id( _bylaw_id integer, highway2 text, _int_start integer, @@ -39,7 +39,7 @@ SELECT rout.objectid, rout.fcode, rout.fcode_desc -FROM gwolofs._get_lines_btwn_interxn(highway2, _int_start, _int_end) rout; +FROM gis._get_lines_btwn_interxn(highway2, _int_start, _int_end) rout; END; $BODY$; diff --git a/gis/text_to_centreline/sql/helper_functions/function-get_intersection_id.sql b/gis/text_to_centreline/sql/helper_functions/function-get_intersection_id.sql index bd6e878f6..f530743c8 100644 --- a/gis/text_to_centreline/sql/helper_functions/function-get_intersection_id.sql +++ b/gis/text_to_centreline/sql/helper_functions/function-get_intersection_id.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE FUNCTION gwolofs._get_intersection_id( +CREATE OR REPLACE FUNCTION gis._get_intersection_id( highway2 text, btwn text, not_int_id int ) RETURNS int [] AS $$ @@ -47,7 +47,7 @@ END; $$ LANGUAGE plpgsql; -COMMENT ON FUNCTION gwolofs._get_intersection_id(text, text, int) IS ' +COMMENT ON FUNCTION gis._get_intersection_id(text, text, int) IS ' Input two street names of streets that intersect each other, and 0 or an intersection id that you do not want the function to return (i.e. sometimes two streets intersect each other twice so if you want to get both intersections by calling this function you would input the first returned intersection id into the function on the second time the function is called). diff --git a/gis/text_to_centreline/sql/helper_functions/function-get_intersection_id_highway_equals_btwn.sql b/gis/text_to_centreline/sql/helper_functions/function-get_intersection_id_highway_equals_btwn.sql index de6e68c8b..c94aa63c4 100644 --- a/gis/text_to_centreline/sql/helper_functions/function-get_intersection_id_highway_equals_btwn.sql +++ b/gis/text_to_centreline/sql/helper_functions/function-get_intersection_id_highway_equals_btwn.sql @@ -4,7 +4,7 @@ -- intersection_id of the first intersection in the bylaw text (or 0 if we are trying to find -- the first intersection). -- not_int_id is there so we dont ever get the same intersections matched twice -CREATE OR REPLACE FUNCTION gwolofs._get_intersection_id_highway_equals_btwn( +CREATE OR REPLACE FUNCTION gis._get_intersection_id_highway_equals_btwn( highway2 text, btwn text, not_int_id int ) RETURNS int [] AS $$ @@ -68,11 +68,11 @@ RETURN ARRAY[oid, lev_sum, int_id_found]; END; $$ LANGUAGE plpgsql; -COMMENT ON FUNCTION gwolofs._get_intersection_id_highway_equals_btwn( +COMMENT ON FUNCTION gis._get_intersection_id_highway_equals_btwn( text, text, int ) IS ' Get intersection id from a text street name when intersection is a cul de sac or a dead end or a pseudo intersection. -In these cases the intersection name (intersec5 of gwolofs.centreline_intersection) would just be the name of the street. +In these cases the intersection name (intersec5 of gis.centreline_intersection) would just be the name of the street. Input two street names of streets that intersect each other, and 0 or an intersection id that you do not want the function to return (i.e. sometimes two streets intersect each other twice so if you want to get both intersections by calling this function you would input the diff --git a/gis/text_to_centreline/sql/helper_functions/function-translate_intersection_point.sql b/gis/text_to_centreline/sql/helper_functions/function-translate_intersection_point.sql index 03d7462e7..4273939b3 100644 --- a/gis/text_to_centreline/sql/helper_functions/function-translate_intersection_point.sql +++ b/gis/text_to_centreline/sql/helper_functions/function-translate_intersection_point.sql @@ -1,5 +1,5 @@ -- Modified the function so that the translation is happening at an angle 17.5 like the Toronto map -CREATE OR REPLACE FUNCTION gwolofs._translate_intersection_point( +CREATE OR REPLACE FUNCTION gis._translate_intersection_point( oid_geom geometry, metres float, direction text ) RETURNS geometry AS $translated_geom$ @@ -24,7 +24,7 @@ END; $translated_geom$ LANGUAGE plpgsql; -COMMENT ON FUNCTION gwolofs._translate_intersection_point( +COMMENT ON FUNCTION gis._translate_intersection_point( oid_geom geometry, metres float, direction text ) IS ' Inputs are the geometry of a point, the number of units that you would like the point to be translated, and the direction that you would like the point to be translated.