diff --git a/NEWS.md b/NEWS.md index 54453687d7d..fb1b902176e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -47,20 +47,32 @@ milestone for 4.0.0 * pgr_dijkstra -**Removal of SQL deprecated functions and signatures** +**Removal of SQL deprecated functions** +* pgr_trsp(text,integer,double +* pgr_trsp(text,integer,integer,boolean,boolean,text) * pgr_trspviaedges(text,integer[],double precision[],boolean,boolean,text) * pgr_trspviavertices(text,anyarray,boolean,boolean,text) -* pgr_trsp(text,integer,double precision,integer,double precision,boolean,boolean,text) -* pgr_trsp(text,integer,integer,boolean,boolean,text) + +**Removal of SQL deprecated internal functions** + * _pgr_dijkstranear(text,anyarray,anyarray,bigint,boolean) * _pgr_dijkstranear(text,anyarray,bigint,bigint,boolean) * _pgr_dijkstranear(text,bigint,anyarray,bigint,boolean) * _pgr_dijkstra(text,anyarray,anyarray,boolean,boolean,boolean,bigint) +* _pgr_dijkstra(text,anyarray,anyarray,boolean,boolean,boolean,bigint,boolean) +* _pgr_dijkstra(text,text,boolean,boolean,bigint,boolean) * _pgr_dijkstra(text,text,boolean,boolean,boolean) +* _pgr_dijkstrav4(text,text,anyarray,anyarray,boolean,boolean,boolean,bigint,boolean) +* _pgr_trsp(text,text,anyarray,anyarray,boolean) +* _pgr_trsp(text,text,anyarray,bigint,boolean) +* _pgr_trsp(text,text,bigint,anyarray,boolean) +* _pgr_trsp(text,text,bigint,bigint,boolean) +* _pgr_trspviavertices(text,integer[],boolean,boolean,text) **Deprecation of internal C/C++ functions** +* _pgr_drivingdistance(text,anyarray,double precision,boolean,boolean) * _pgr_dijkstra(text,anyarray,anyarray,boolean,boolean,boolean,bigint)`` * _pgr_dijkstra(text,anyarray,anyarray,boolean,boolean,boolean,bigint,boolean)`` * _pgr_dijkstra(text,text,boolean,boolean,bigint,boolean)`` diff --git a/doc/src/release_notes.rst b/doc/src/release_notes.rst index 2004ac9814d..0d238565917 100644 --- a/doc/src/release_notes.rst +++ b/doc/src/release_notes.rst @@ -78,20 +78,32 @@ milestone for 4.0.0 * pgr_dijkstra -.. rubric:: Removal of SQL deprecated functions and signatures +.. rubric:: Removal of SQL deprecated functions +* pgr_trsp(text,integer,double +* pgr_trsp(text,integer,integer,boolean,boolean,text) * pgr_trspviaedges(text,integer[],double precision[],boolean,boolean,text) * pgr_trspviavertices(text,anyarray,boolean,boolean,text) -* pgr_trsp(text,integer,double precision,integer,double precision,boolean,boolean,text) -* pgr_trsp(text,integer,integer,boolean,boolean,text) + +.. rubric:: Removal of SQL deprecated internal functions + * _pgr_dijkstranear(text,anyarray,anyarray,bigint,boolean) * _pgr_dijkstranear(text,anyarray,bigint,bigint,boolean) * _pgr_dijkstranear(text,bigint,anyarray,bigint,boolean) * _pgr_dijkstra(text,anyarray,anyarray,boolean,boolean,boolean,bigint) +* _pgr_dijkstra(text,anyarray,anyarray,boolean,boolean,boolean,bigint,boolean) +* _pgr_dijkstra(text,text,boolean,boolean,bigint,boolean) * _pgr_dijkstra(text,text,boolean,boolean,boolean) +* _pgr_dijkstrav4(text,text,anyarray,anyarray,boolean,boolean,boolean,bigint,boolean) +* _pgr_trsp(text,text,anyarray,anyarray,boolean) +* _pgr_trsp(text,text,anyarray,bigint,boolean) +* _pgr_trsp(text,text,bigint,anyarray,boolean) +* _pgr_trsp(text,text,bigint,bigint,boolean) +* _pgr_trspviavertices(text,integer[],boolean,boolean,text) .. rubric:: Deprecation of internal C/C++ functions +* _pgr_drivingdistance(text,anyarray,double precision,boolean,boolean) * _pgr_dijkstra(text,anyarray,anyarray,boolean,boolean,boolean,bigint)`` * _pgr_dijkstra(text,anyarray,anyarray,boolean,boolean,boolean,bigint,boolean)`` * _pgr_dijkstra(text,text,boolean,boolean,bigint,boolean)`` diff --git a/pgtap/dijkstra/driving_distance/edge_cases/issue_519.pg b/pgtap/dijkstra/driving_distance/edge_cases/issue_519.pg index 16f4d6c9b45..53660738b04 100644 --- a/pgtap/dijkstra/driving_distance/edge_cases/issue_519.pg +++ b/pgtap/dijkstra/driving_distance/edge_cases/issue_519.pg @@ -19,7 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. BEGIN; UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); -SELECT plan(3); +SELECT CASE WHEN NOT min_version('3.6.0') AND min_lib_version('5.0.0') THEN plan(1) ELSE plan(3) END; CREATE OR REPLACE FUNCTION test_function() RETURNS SETOF TEXT AS $BODY$ @@ -41,6 +41,11 @@ BEGIN RETURN QUERY SELECT bag_has('q4', 'q2', '2: DD from [1, 5, 25] should have results of DD from 5'); RETURN QUERY SELECT bag_has('q4', 'q3', '3: DD from [1, 5, 25] should have results of DD from 25'); ELSE + IF min_lib_version('5.0.0') THEN + RETURN QUERY SELECT skip(1, 'Internal function deprecated on 3.6.0 and removed on 5.0.0'); + ELSE + --Internal function deprecated on 3.6.0 + SET client_min_messages TO WARNING; PREPARE q1 AS SELECT 1 AS from_v, node, edge, cost, agg_cost FROM pgr_drivingDistance('SELECT id, source, target, cost FROM edges', 1, 3.5); @@ -56,6 +61,8 @@ BEGIN RETURN QUERY SELECT bag_has('q4', 'q1', '1: DD from [1, 5, 25] should have results of DD from 1'); RETURN QUERY SELECT bag_has('q4', 'q2', '2: DD from [1, 5, 25] should have results of DD from 5'); RETURN QUERY SELECT bag_has('q4', 'q3', '3: DD from [1, 5, 25] should have results of DD from 25'); + SET client_min_messages TO NOTICE; + END IF; END IF; END; $BODY$ diff --git a/pgtap/dijkstra/driving_distance/inner_query.pg b/pgtap/dijkstra/driving_distance/inner_query.pg index 58b147ac008..957df4eb144 100644 --- a/pgtap/dijkstra/driving_distance/inner_query.pg +++ b/pgtap/dijkstra/driving_distance/inner_query.pg @@ -20,16 +20,23 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. BEGIN; UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); -SELECT plan(108); +SELECT CASE WHEN NOT min_version('3.6.0') AND min_lib_version('5.0.0') THEN plan(1) ELSE plan(108) END; --- ONE SOURCE -SELECT style_dijkstra('pgr_drivingdistance(', ',2, 1, true)'); - --- MANY SOURCES -SELECT style_dijkstra('pgr_drivingdistance(', ',ARRAY[2,3], 1, true)'); - +CREATE OR REPLACE FUNCTION inner_query() RETURNS SETOF TEXT AS +$BODY$ +BEGIN + IF NOT min_version('3.6.0') AND min_lib_version('5.0.0') THEN + RETURN NEXT skip(1, 'Internal function deprecated on 3.6.0 and removed on 5.0.0'); + RETURN; + END IF; + RETURN QUERY SELECT style_dijkstra('pgr_drivingdistance(', ',2, 1, true)'); + RETURN QUERY SELECT style_dijkstra('pgr_drivingdistance(', ',ARRAY[2,3], 1, true)'); +END; +$BODY$ +LANGUAGE plpgsql; +SELECT inner_query(); SELECT finish(); ROLLBACK; diff --git a/pgtap/dijkstra/driving_distance/no_crash_test.pg b/pgtap/dijkstra/driving_distance/no_crash_test.pg index ea2324d34d4..890633d90e5 100644 --- a/pgtap/dijkstra/driving_distance/no_crash_test.pg +++ b/pgtap/dijkstra/driving_distance/no_crash_test.pg @@ -20,7 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. BEGIN; UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); -SELECT plan(34); +SELECT CASE WHEN NOT min_version('3.6.0') AND min_lib_version('5.0.0') THEN plan(1) ELSE plan(34) END; PREPARE edges AS SELECT id, source, target, cost, reverse_cost FROM edges; @@ -39,6 +39,11 @@ DECLARE params TEXT[]; subs TEXT[]; BEGIN + IF NOT min_version('3.6.0') AND min_lib_version('5.0.0') THEN + RETURN NEXT skip(1, 'Internal function deprecated on 3.6.0 and removed on 5.0.0'); + RETURN; + END IF; + -- 1 to distance params = ARRAY['$$SELECT id, source, target, cost, reverse_cost FROM edges$$','1', '1.3::FLOAT']::TEXT[]; subs = ARRAY[ diff --git a/pgtap/dijkstra/driving_distance/types_check.pg b/pgtap/dijkstra/driving_distance/types_check.pg index 0068a8629f2..e3dc5e85c74 100644 --- a/pgtap/dijkstra/driving_distance/types_check.pg +++ b/pgtap/dijkstra/driving_distance/types_check.pg @@ -29,49 +29,38 @@ SELECT has_function('pgr_drivingdistance', ARRAY['text','anyarray','double preci SELECT function_returns('pgr_drivingdistance', ARRAY['text','bigint','double precision','boolean'],'setof record'); SELECT function_returns('pgr_drivingdistance', ARRAY['text','anyarray','double precision','boolean','boolean'],'setof record'); -CREATE OR REPLACE FUNCTION types_check() -RETURNS SETOF TEXT AS -$BODY$ -BEGIN +SELECT CASE +WHEN (min_version('3.6.0')) THEN + collect_tap( + set_eq( + $$SELECT proargnames from pg_proc where proname = 'pgr_drivingdistance'$$, + $$VALUES + ('{"","","","directed","seq","depth","start_vid","pred","node","edge","cost","agg_cost"}'::TEXT[]), + ('{"","","","directed","equicost","seq","depth","start_vid","pred","node","edge","cost","agg_cost"}'::TEXT[]) + $$), -IF (min_version('3.6.0')) THEN -RETURN QUERY -SELECT set_eq( - $$SELECT proargnames from pg_proc where proname = 'pgr_drivingdistance'$$, - $$VALUES - ('{"","","","directed","seq","depth","start_vid","pred","node","edge","cost","agg_cost"}'::TEXT[]), - ('{"","","","directed","equicost","seq","depth","start_vid","pred","node","edge","cost","agg_cost"}'::TEXT[]) - $$); + set_eq( + $$SELECT proallargtypes from pg_proc where proname = 'pgr_drivingdistance'$$, + $$VALUES + ('{25,20,701,16,20,20,20,20,20,20,701,701}'::OID[]), + ('{25,2277,701,16,16,20,20,20,20,20,20,701,701}'::OID[]) + $$)) + ELSE + collect_tap( + set_eq( + $$SELECT proargnames from pg_proc where proname = 'pgr_drivingdistance'$$, + $$VALUES + ('{"","","","directed","seq","node","edge","cost","agg_cost"}'::TEXT[]), + ('{"","","","directed","equicost","seq","from_v","node","edge","cost","agg_cost"}'::TEXT[]) + $$), -RETURN QUERY -SELECT set_eq( - $$SELECT proallargtypes from pg_proc where proname = 'pgr_drivingdistance'$$, - $$VALUES - ('{25,20,701,16,20,20,20,20,20,20,701,701}'::OID[]), - ('{25,2277,701,16,16,20,20,20,20,20,20,701,701}'::OID[]) - $$); -ELSE --- old signatures -RETURN QUERY -SELECT set_eq( - $$SELECT proargnames from pg_proc where proname = 'pgr_drivingdistance'$$, - $$VALUES - ('{"","","","directed","seq","node","edge","cost","agg_cost"}'::TEXT[]), - ('{"","","","directed","equicost","seq","from_v","node","edge","cost","agg_cost"}'::TEXT[]) - $$); - -RETURN QUERY -SELECT set_eq( - $$SELECT proallargtypes from pg_proc where proname = 'pgr_drivingdistance'$$, - $$VALUES - ('{25,20,701,16,23,20,20,701,701}'::OID[]), - ('{25,2277,701,16,16,23,20,20,20,701,701}'::OID[]) - $$); -END IF; + set_eq( + $$SELECT proallargtypes from pg_proc where proname = 'pgr_drivingdistance'$$, + $$VALUES + ('{25,20,701,16,23,20,20,701,701}'::OID[]), + ('{25,2277,701,16,16,23,20,20,20,701,701}'::OID[]) + $$)) END; -$BODY$ -LANGUAGE plpgsql; -SELECT * FROM types_check(); SELECT finish(); ROLLBACK; diff --git a/sql/driving_distance/_drivingDistance.sql b/sql/driving_distance/_drivingDistance.sql index 55513c77736..1674f748aef 100644 --- a/sql/driving_distance/_drivingDistance.sql +++ b/sql/driving_distance/_drivingDistance.sql @@ -25,10 +25,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ ----------------------- --- pgr_drivingDistance ----------------------- - --v3.6 CREATE FUNCTION _pgr_drivingDistancev4( TEXT, -- edges_sql @@ -48,31 +44,5 @@ RETURNS SETOF RECORD AS 'MODULE_PATHNAME' LANGUAGE c VOLATILE STRICT; --- COMMENTS - COMMENT ON FUNCTION _pgr_drivingDistancev4(TEXT, ANYARRAY, FLOAT, BOOLEAN, BOOLEAN) IS 'pgRouting internal function'; - -/* Below functions are for backward compatibility to be removed on v4*/ - ---v3.0 -CREATE FUNCTION _pgr_drivingDistance( - edges_sql TEXT, - start_vids ANYARRAY, - distance FLOAT, - directed BOOLEAN DEFAULT TRUE, - equicost BOOLEAN DEFAULT FALSE, - OUT seq INTEGER, - OUT from_v BIGINT, - OUT node BIGINT, - OUT edge BIGINT, - OUT cost FLOAT, - OUT agg_cost FLOAT) -RETURNS SETOF RECORD AS -'MODULE_PATHNAME' -LANGUAGE c VOLATILE STRICT; - --- COMMENTS - -COMMENT ON FUNCTION _pgr_drivingDistance(TEXT, ANYARRAY, FLOAT, BOOLEAN, BOOLEAN) -IS 'pgRouting internal function deprecated on v3.6.0'; diff --git a/sql/legacy/alpha_shape.sql b/sql/legacy/alpha_shape.sql deleted file mode 100644 index 90585414a80..00000000000 --- a/sql/legacy/alpha_shape.sql +++ /dev/null @@ -1,74 +0,0 @@ -/*PGR-GNU***************************************************************** - -Copyright (c) 2019 Celia Virginia Vergara Castillo -Mail: project@pgrouting.org - ------- - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - ********************************************************************PGR-GNU*/ - ------------------------------------------------------------------------ --- legacy --- The sql should return vertex x,y values. - -- Before: id is compulsory - -- Legacy: id is ignored --- Return ordered vertex ids. - -- Before: the sequence was does not represent a closed linestring - -- Legacy: the sequence was represent a closed linestring ------------------------------------------------------------------------ -CREATE OR REPLACE FUNCTION pgr_alphashape( - text, -- SQL with x, y - alpha float8 DEFAULT 0, - OUT x float8, - OUT y float8) -RETURNS SETOF record -AS -$BODY$ -DECLARE - rec record; - old_poly_seq BIGINT = 1; - old_ring BIGINT = 1; -BEGIN - FOR rec IN - WITH - multiPoly AS (SELECT pgr_pointsAsPolygon($1, sqrt(alpha)) AS geom), - singlePoly AS (SELECT (ST_dump(geom)).path[1] AS poly_seq, (ST_dump(geom)).geom FROM multipoly), - polydump AS (SELECT poly_seq, ST_DumpPoints(geom) dp FROM singlePoly) - SELECT poly_seq, (dp).path[1] AS ring, (dp).path[2] AS point_seq, st_asText((dp).geom) AS geom - FROM polydump - ORDER BY poly_seq, ring, point_seq - LOOP - IF (old_poly_seq != rec.poly_seq OR old_ring != rec.ring) THEN - RAISE NOTICE '% %', rec.poly_seq, rec.ring; - x = NULL; - y = NULL; - RETURN NEXT; - old_poly_seq := rec.poly_seq; - old_ring := rec.ring; - END IF; - - x = ST_X(rec.geom); - y = ST_Y(rec.geom); - - RETURN NEXT; - END LOOP; -END -$BODY$ -LANGUAGE plpgsql VOLATILE STRICT; - -COMMENT ON FUNCTION pgr_alphaShape(TEXT, FLOAT) -IS 'Legacy'; diff --git a/sql/legacy/legacy-developers.sql b/sql/legacy/legacy-developers.sql deleted file mode 100644 index 77c7fbb61af..00000000000 --- a/sql/legacy/legacy-developers.sql +++ /dev/null @@ -1,470 +0,0 @@ -/*PGR-GNU***************************************************************** - -FILE: legacy-developers.sql - -Copyright (c) 2015 pgRouting developers -Mail: project@pgrouting.org - ------- - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - ********************************************************************PGR-GNU*/ -------------------------------------------------------------------------------- --- Legacy FUNCTIONs that were meant to be used by --- pgRouting developers --- These FUNCTIONs wer used on the plpgsql FUNCTIONs - - --- FILE intended to be used on 3.0 -------------------------------------------------------------------------------- - ------------------------------------------------------------------------------- --- Deprecated on 2.3 --- --- pgr_getColumnName --- pgr_getTableName --- pgr_isColumnIndexed --- pgr_isColumnInTable --- pgr_quote_ident --- pgr_versionless --- pgr_startPoint --- pgr_endPoint --- pgr_pointToid RENAMED and deprecated and never announced no one has complained ------------------------------------------------------------------------------- - - --- deprecated on 2.1.0 -CREATE OR REPLACE FUNCTION pgr_getColumnName(tab text, col text) -RETURNS text AS -$BODY$ -DECLARE - sname text; - tname text; - table_name text; -BEGIN - IF pgr_isColumnInTable(tab, col) THEN RETURN NULL; - END IF; - SELECT pgr_getTableName($1) into sname, tname; - table_name := sname || '.' || tname; - EXECUTE 'SELECT ' || quote_ident(col) || ' FROM ' || table_name || ' LIMIT 1'; - RETURN col; - EXCEPTION WHEN others THEN - BEGIN - EXECUTE 'SELECT ' || quote_ident(lower(col)) || ' FROM ' || table_name || ' LIMIT 1'; - RETURN lower(col); - EXCEPTION WHEN others THEN - RETURN NULL; - END; - -END; -$BODY$ -LANGUAGE plpgsql VOLATILE STRICT; - - - - --- deprecated on 2.1.0 -CREATE OR REPLACE FUNCTION pgr_getTableName(IN tab text,OUT sname text,OUT tname text) -RETURNS RECORD AS -$BODY$ -DECLARE - table_oid regclass; - table_name text; -BEGIN - table_oid := $1::regclass; - -- $1 := replace($1, '"', ''); - SELECT sname, tname FROM _pgr_getTableName($1, 0, 'pgr_getTableName') into sname,tname; - EXCEPTION WHEN others THEN - BEGIN - table_oid := lower($1)::regclass; - SELECT sname, tname FROM _pgr_getTableName(lower($1), 0, 'pgr_getTableName') into sname,tname; - EXCEPTION WHEN others THEN - sname = 'public'; - tname = NULL; - END; -END; -$BODY$ -LANGUAGE plpgsql VOLATILE STRICT; - - - - - --- deprecated on 2.1.0 -CREATE OR REPLACE FUNCTION pgr_isColumnIndexed(tab text, col text) -RETURNS boolean AS -$BODY$ -DECLARE table_oid regclass; -BEGIN - table_oid := $1::regclass; - $1 := replace(tab, '"', ''); - RETURN _pgr_isColumnIndexed($1, $2); -END; -$BODY$ -LANGUAGE plpgsql VOLATILE STRICT; - - - - --- deprecated on 2.1.0 -CREATE OR REPLACE FUNCTION pgr_isColumnInTable(tab text, col text) -RETURNS boolean AS -$BODY$ -DECLARE - cname text; - sname text; - tname text; - table_name text; -BEGIN - SELECT pgr_getTableName($1) into sname, tname; - table_name := sname || '.' || tname; - EXECUTE 'SELECT ' || quote_ident(col) || ' FROM ' || table_name || ' LIMIT 1'; - RETURN true; - EXCEPTION WHEN others THEN - BEGIN - EXECUTE 'SELECT ' || quote_ident(lower(col)) || ' FROM ' || table_name || ' LIMIT 1'; - RETURN true; - EXCEPTION WHEN others THEN - RETURN false; - END; -END; -$BODY$ - LANGUAGE plpgsql VOLATILE STRICT; - - - - --- deprecated on 2.1.0 -CREATE OR REPLACE FUNCTION pgr_quote_ident(idname text) -RETURNS text as -$BODY$ - SELECT quote_ident($1); -$BODY$ -LANGUAGE sql IMMUTABLE; - - - - - --- deprecated on 2.1.0 -CREATE OR REPLACE FUNCTION pgr_versionless(v1 text, v2 text) -RETURNS boolean AS -$BODY$ - SELECT _pgr_versionless($1, $2); -$BODY$ -LANGUAGE sql VOLATILE STRICT; - - - - --- deprecated on 2.1.0 -CREATE OR REPLACE FUNCTION pgr_startPoint(g geometry) - RETURNS geometry as -$BODY$ - SELECT ST_startPoint($1); -$BODY$ -LANGUAGE sql IMMUTABLE; - - - - --- deprecated on 2.1.0 -CREATE OR REPLACE FUNCTION pgr_endPoint(g geometry) - RETURNS geometry as -$BODY$ - SELECT ST_endPoint($1); -$BODY$ -LANGUAGE sql IMMUTABLE; - - - -/* RENAMED and deprecated and never announced no one has complained --- deprecated on 2.1.0 -CREATE OR REPLACE FUNCTION pgr_pointToId(point geometry, tolerance double precision, vertname text, srid integer) -RETURNS bigint AS -$BODY$ - SELECT _pgr_pointToId($1, $2, $3, $4); -$BODY$ -LANGUAGE sql VOLATILE STRICT; -*/ - ------------------------------------------------------------------------------- --- Deprecated on 2.3 --- --- pgr_flipedges --- pgr_texttopoints --- pgr_vidsToDMatrix --- pgr_vidsToDMatrix --- pgr_pointstodmatrix ------------------------------------------------------------------------------- - --- Added on 2.1.0 --- deprecated on 2.3.0 -CREATE OR REPLACE FUNCTION pgr_flipedges(ga geometry[]) - RETURNS geometry[] as -$BODY$ -DECLARE - nn integer; - i integer; - g geometry; - -BEGIN - nn := array_length(ga, 1); - IF nn = 1 THEN - RETURN ga; - END IF; - - g := ST_StartPoint(ga[1]); - - IF ST_StartPoint(ga[2]) = g or ST_EndPoint(ga[2]) = g THEN - ga[1] := ST_Reverse(ga[1]); - END IF; - - g := ST_EndPoint(ga[1]); - - FOR i in 2 .. nn LOOP - IF g = ST_EndPoint(ga[i]) THEN - ga[i] := ST_Reverse(ga[i]); - END IF; - g := ST_EndPoint(ga[i]); - END LOOP; - - RETURN ga; -end; -$BODY$ -LANGUAGE plpgsql immutable; - - - --- Added on 2.1.0 --- deprecated on 2.3.0 -CREATE OR REPLACE FUNCTION pgr_texttopoints(pnts text, srid integer DEFAULT(4326)) - RETURNS geometry[] as -$BODY$ -DECLARE - a text[]; - t text; - p geometry; - g geometry[]; - -BEGIN - a := string_to_array(replace(pnts, ',', ' '), ';'); - FOR t in SELECT unnest(a) LOOP - p := ST_pointfromtext('POINT(' || t || ')', srid); - g := g || p; - END LOOP; - - RETURN g; -end; -$BODY$ -LANGUAGE plpgsql immutable; - - - --- Added on 2.1.0 --- deprecated on 2.3.0 -CREATE OR REPLACE FUNCTION pgr_vidsToDMatrix(sql TEXT, vids INTEGER[], dir BOOLEAN, has_rcost BOOLEAN, want_symmetric BOOLEAN) -RETURNS float8[] AS -$BODY$ -DECLARE -dmatrix_row float8[]; -dmatrix float8[]; -rr RECORD; -ids INTEGER[]; -total BIGINT; -BEGIN - ids := ARRAY(SELECT DISTINCT UNNEST(vids) ORDER BY 1); - - IF want_symmetric THEN - dir = false; - END IF; - - total := array_length(ids, 1); - - FOR i in 1 .. total LOOP - dmatrix_row := dmatrix_row || '+Infinity'::float8; - END LOOP; - - FOR i in 1 .. total LOOP - dmatrix := dmatrix || ARRAY[dmatrix_row]; - dmatrix[i][i] = 0; - END LOOP; - - FOR rr IN EXECUTE - 'SELECT start_vid, end_vid, agg_cost FROM pgr_dijkstraCostMatrix($1, $2, $3)' - USING - sql, ids, dir - LOOP - dmatrix[(SELECT idx FROM generate_subscripts(ids, 1) AS idx WHERE ids[idx] = rr.start_vid)] - [(SELECT idx FROM generate_subscripts(ids, 1) AS idx WHERE ids[idx] = rr.end_vid)] := rr.agg_cost; - END LOOP; - - RETURN dmatrix; -END -$BODY$ -LANGUAGE plpgsql VOLATILE -COST 100; - - --- Added on 2.1.0 --- deprecated on 2.3.0 -CREATE OR REPLACE FUNCTION pgr_vidstodmatrix( - IN vids integer[], - IN pnts geometry[], - IN edges text, - tol float8 DEFAULT(0.1), - OUT dmatrix double precision[], - OUT ids integer[]) - RETURNS record as -$BODY$ -DECLARE - dmatrix_row float8[]; - nn integer; - rr record; - t float8[]; - -BEGIN - ids := array(SELECT DISTINCT unnest(vids::integer[]) ORDER BY 1); - - nn := array_length(ids, 1); - - FOR i in 1 .. nn LOOP - dmatrix_row := dmatrix_row || '+Infinity'::float8; - END LOOP; - - FOR i in 1 .. nn LOOP - dmatrix := dmatrix || ARRAY[dmatrix_row]; - dmatrix[i][i] = 0; - END LOOP; - - FOR i in 1 .. nn LOOP - dmatrix := dmatrix || ARRAY[t]; - END LOOP; - - FOR rr IN EXECUTE - 'SELECT start_vid, end_vid, agg_cost FROM pgr_dijkstraCostMatrix($1, $2, false)' - USING - 'SELECT id, source, target, cost FROM ' || edges, - ids - LOOP - dmatrix[(SELECT idx FROM generate_subscripts(ids, 1) AS idx WHERE ids[idx] = rr.start_vid)] - [(SELECT idx FROM generate_subscripts(ids, 1) AS idx WHERE ids[idx] = rr.end_vid)] := rr.agg_cost; - END LOOP; - - RETURN; -end; -$BODY$ -LANGUAGE plpgsql STABLE cost 200; - - - --- Added on 2.1.0 --- deprecated on 2.3.0 -CREATE OR REPLACE FUNCTION pgr_pointstodmatrix(pnts geometry[], mode integer default (0), OUT dmatrix double precision[], OUT ids integer[]) - RETURNS record as -$BODY$ -DECLARE - r record; - -BEGIN - dmatrix := array[]::double precision[]; - ids := array[]::integer[]; - - FOR r in with nodes AS (SELECT row_number() over()::integer AS id, p FROM (select unnest(pnts) AS p) AS foo) - SELECT i, array_agg(dist) AS arow FROM ( - SELECT a.id AS i, b.id AS j, - case when mode=0 - THEN ST_distance(a.p, b.p) - ELSE ST_distance_sphere(a.p, b.p) - END AS dist - FROM nodes a, nodes b - ORDER BY a.id, b.id - ) AS foo group by i ORDER BY i LOOP - - dmatrix := array_cat(dmatrix, array[r.arow]); - ids := ids || array[r.i]; - END LOOP; -end; -$BODY$ -LANGUAGE plpgsql STABLE; - ------------------------------------------------------------------------ - --- Added on 2.1.0 --- deprecated on 2.4.0 -CREATE OR REPLACE FUNCTION pgr_pointstovids(pnts geometry[], edges text, tol float8 DEFAULT(0.01)) - RETURNS integer[] as -$BODY$ -DECLARE - v integer[]; - g geometry; -BEGIN - FOR g in SELECT unnest(pnts) LOOP - v := v || pgr_pointtoedgenode(edges, g, tol); - END LOOP; - - RETURN v; -end; -$BODY$ -LANGUAGE plpgsql STABLE; - - - ------------------------------------------------------------------------ - --- Added on 2.1.0 --- deprecated on 2.5.0 -CREATE OR REPLACE FUNCTION pgr_pointtoedgenode(edges text, pnt geometry, tol float8) - RETURNS integer as -$BODY$ -DECLARE - rr record; - pct float; - debuglevel text; - -BEGIN - execute 'SELECT source, target, the_geom FROM ' || quote_ident(edges) || - ' where ST_dwithin(''' || pnt::text || - '''::geometry, the_geom, ' || tol || ') ORDER BY ST_distance(''' || pnt::text || - '''::geometry, the_geom) asc limit 1' into rr; - - IF rr.the_geom IS NOT null THEN - IF geometrytype(rr.the_geom)='MULTILINESTRING' THEN - rr.the_geom := ST_GeometryN(rr.the_geom, 1); - END IF; - - IF _pgr_versionless(postgis_version(), '2.0') THEN - pct := ST_line_locate_point(rr.the_geom, pnt); - ELSE - pct := ST_lineLocatePoint(rr.the_geom, pnt); - END IF; - - IF pct < 0.5 THEN - RETURN rr.source; - ELSE - RETURN rr.target; - END IF; - ELSE - RETURN -1; - END IF; -end; -$BODY$ -LANGUAGE plpgsql VOLATILE -cost 5; - - - ------------------------------------------------------------------------------- diff --git a/sql/legacy/legacy_experimental.sql b/sql/legacy/legacy_experimental.sql deleted file mode 100644 index 2c22c75d678..00000000000 --- a/sql/legacy/legacy_experimental.sql +++ /dev/null @@ -1,496 +0,0 @@ -/*PGR-GNU***************************************************************** - -Copyright (c) 2015 ~ pgRouting developers -Mail: project@pgrouting.org - ------- - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - ********************************************************************PGR-GNU*/ - ----------------------------------------------------------------------------- --- Experimental function: pgr_labelGraph --- Original developer: Zia Mohammed --- --- Availability: --- - from v2.1 --- - up to v2.6 --- - moved to legacy on v3.0 --- --- Use Components family of functions instead ----------------------------------------------------------------------------- - -CREATE OR REPLACE FUNCTION pgr_labelGraph( - edge_table text, - id text default 'id', - source text default 'source', - target text default 'target', - subgraph text default 'subgraph', - rows_where text default 'true' - ) - RETURNS character varying AS -$BODY$ - -DECLARE - naming record; - schema_name text; - table_name text; - garbage text; - incre integer; - table_schema_name text; - query text; - ecnt integer; - sql1 text; - rec1 record; - sql2 text; - rec2 record; - rec_count record; - rec_single record; - graph_id integer; - gids int []; - -BEGIN - raise notice 'Processing:'; - raise notice 'pgr_brokenGraph(''%'',''%'',''%'',''%'',''%'',''%'')', edge_table,id,source,target,subgraph,rows_where; - raise notice 'Performing initial checks, please hold on ...'; - - Raise Notice 'Starting - Checking table ...'; - BEGIN - raise debug 'Checking % table existance', edge_table; - execute 'select * from pgr_getTableName('|| quote_literal(edge_table) ||')' into naming; - schema_name = naming.sname; - table_name = naming.tname; - table_schema_name = schema_name||'.'||table_name; - IF schema_name is null then - raise notice 'no schema'; - return 'FAIL'; - else - if table_name is null then - raise notice 'no table'; - return 'FAIL'; - end if; - end if; - END; - Raise Notice 'Ending - Checking table'; - - Raise Notice 'Starting - Checking columns'; - BEGIN - raise debug 'Checking exitance of necessary columns inside % table', edge_table; - execute 'select * from pgr_isColumnInTable('|| quote_literal(table_schema_name) ||', '|| quote_literal(id) ||')' into naming; - if naming.pgr_iscolumnintable = 'f' then - raise notice 'no id column'; - return 'FAIL'; - end if; - execute 'select * from pgr_isColumnInTable('|| quote_literal(table_schema_name) ||', '|| quote_literal(source) ||')' into naming; - if naming.pgr_iscolumnintable = 'f' then - raise notice 'no source column'; - return 'FAIL'; - end if; - execute 'select * from pgr_isColumnInTable('|| quote_literal(table_schema_name) ||', '|| quote_literal(target) ||')' into naming; - if naming.pgr_iscolumnintable = 'f' then - raise notice 'no target column'; - return 'FAIL'; - end if; - execute 'select * from pgr_isColumnInTable('|| quote_literal(table_schema_name) ||', '|| quote_literal(subgraph) ||')' into naming; - if naming.pgr_iscolumnintable = 't' then - raise notice 'subgraph column already in the table'; - return 'FAIL'; - end if; - END; - Raise Notice 'Ending - Checking columns'; - - Raise Notice 'Starting - Checking rows_where condition'; - BEGIN - raise debug 'Checking rows_where condition'; - query='select count(*) from '|| pgr_quote_ident(table_schema_name) ||' where '|| rows_where; - execute query into ecnt; - raise debug '-->Rows where condition: OK'; - raise debug ' --> OK'; - EXCEPTION WHEN OTHERS THEN - raise notice 'Got %', SQLERRM; - Raise notice 'ERROR: Condition is not correct. Please execute the following query to test your condition'; - Raise notice '%', query; - return 'FAIL'; - END; - Raise Notice 'Ending - Checking rows_where condition'; - - garbage := 'garbage001'; - incre := 1; - Raise Notice 'Starting - Checking temporary column'; - Begin - raise debug 'Checking Checking temporary columns existance'; - - While True - Loop - execute 'select * from pgr_isColumnInTable('|| quote_literal(table_schema_name) ||', '|| quote_literal(garbage) ||')' into naming; - If naming.pgr_iscolumnintable = 't' THEN - incre := incre + 1; - garbage := 'garbage00'||incre||''; - ELSE - EXIT; - END IF; - End Loop; - End; - Raise Notice 'Ending - Checking temporary column'; - - Raise Notice 'Starting - Calculating subgraphs'; - BEGIN - --------- Add necessary columns ---------- - EXECUTE 'ALTER TABLE '|| pgr_quote_ident(table_schema_name) ||' ADD COLUMN ' || pgr_quote_ident(subgraph) || ' INTEGER DEFAULT -1'; - EXECUTE 'ALTER TABLE '|| pgr_quote_ident(table_schema_name) ||' ADD COLUMN ' || pgr_quote_ident(garbage) || ' INTEGER DEFAULT 0'; - graph_id := 1; - - EXECUTE 'select count(*) as count from '|| pgr_quote_ident(table_schema_name) ||' where '|| rows_where ||'' into rec_count; - if rec_count.count = 0 then - RETURN 'rows_where condition generated 0 rows'; - end if; - - WHILE TRUE - LOOP - ---------- Assign the very first -1 row graph_id ---------- - EXECUTE 'SELECT ' || pgr_quote_ident(id) || ' AS gid FROM '|| pgr_quote_ident(table_schema_name) ||' WHERE '|| rows_where ||' AND ' || pgr_quote_ident(subgraph) || ' = -1 LIMIT 1' INTO rec_single; - EXECUTE 'UPDATE '|| pgr_quote_ident(table_schema_name) ||' SET ' || pgr_quote_ident(subgraph) || ' = ' || graph_id || ' WHERE ' || pgr_quote_ident(id) || ' = ' || rec_single.gid || ''; - - --------- Search other rows with that particular graph_id ----------- - WHILE TRUE - LOOP - EXECUTE 'SELECT COUNT(*) FROM '|| pgr_quote_ident(table_schema_name) ||' WHERE ' || pgr_quote_ident(subgraph) || ' = ' || graph_id || ' AND ' || pgr_quote_ident(garbage) || ' = 0' into rec_count; - ----------- The following if else will check those rows which already have entertained ------------ - IF (rec_count.count > 0) THEN - sql1 := 'SELECT ' || pgr_quote_ident(id) || ' AS gid, ' || pgr_quote_ident(source) || ' AS source, ' || pgr_quote_ident(target) || ' AS target FROM '|| pgr_quote_ident(table_schema_name) ||' WHERE ' || pgr_quote_ident(subgraph) || ' = ' || graph_id || ' AND ' || pgr_quote_ident(garbage) || ' = 0'; - FOR rec1 IN EXECUTE sql1 - LOOP - sql2 := 'SELECT ' || pgr_quote_ident(id) || ' AS gid, ' || pgr_quote_ident(source) || ' AS source, ' || pgr_quote_ident(target) || ' AS target FROM '|| pgr_quote_ident(table_schema_name) ||' WHERE '|| pgr_quote_ident(source) ||' = '|| rec1.source ||' OR '|| pgr_quote_ident(target) ||' = '|| rec1.source ||' OR '|| pgr_quote_ident(source) ||' = '|| rec1.target ||' OR '|| pgr_quote_ident(target) ||' = '|| rec1.target ||''; - FOR rec2 IN EXECUTE sql2 - LOOP - EXECUTE 'UPDATE '|| pgr_quote_ident(table_schema_name) ||' SET ' || pgr_quote_ident(subgraph) || ' = ' || graph_id || ' WHERE ' || pgr_quote_ident(id) || ' = ' || rec2.gid || ''; - END LOOP; - EXECUTE 'UPDATE '|| pgr_quote_ident(table_schema_name) ||' SET ' || pgr_quote_ident(garbage) || ' = 1 WHERE ' || pgr_quote_ident(id) || ' = ' || rec1.gid || ''; - END LOOP; - ELSE - EXIT; - END IF; - END LOOP; - - ------ Following is to exit the while loop. 0 means no more -1 id. - EXECUTE 'SELECT COUNT(*) AS count FROM '|| pgr_quote_ident(table_schema_name) ||' WHERE '|| rows_where ||' AND ' || pgr_quote_ident(subgraph) || ' = -1' INTO rec_count; - If (rec_count.count = 0) THEN - EXIT; - ELSE - graph_id := graph_id + 1; - END IF; - END LOOP; - - ----------- Drop garbage column ------------ - EXECUTE 'ALTER TABLE '|| pgr_quote_ident(table_schema_name) ||' DROP COLUMN ' || pgr_quote_ident(garbage) ||''; - Raise Notice 'Successfully complicated calculating subgraphs'; - END; - Raise Notice 'Ending - Calculating subgraphs'; - - RETURN 'OK'; - -END; -$BODY$ -LANGUAGE plpgsql VOLATILE STRICT; - ----------------------------------------------------------------------------- --- Experimental functions: --- pgr_maxFlowPushRelabel --- pgr_maximumcardinalitymatching --- pgr_maxFlowBoykovKolmogorov --- pgr_maxFlowEdmondsKarp --- --- Original developer: Andrea Nardelli --- mail: nrd.nardelli@gmail.com --- --- Availability: --- - from v2.3 --- - renamed on v2.5 --- - moved old names to legacy on v3.0 --- --- Use current names of Flow family of functions instead ----------------------------------------------------------------------------- - ----------------------------------------------------------------------------- --- pgr_maxFlowPushRelabel ----------------------------------------------------------------------------- -CREATE OR REPLACE FUNCTION pgr_maxFlowPushRelabel( - edges_sql TEXT, - source_vertex BIGINT, - sink_vertex BIGINT, - OUT seq INTEGER, - OUT edge_id BIGINT, - OUT source BIGINT, - OUT target BIGINT, - OUT flow BIGINT, - OUT residual_capacity BIGINT - ) - RETURNS SETOF RECORD AS - $BODY$ - BEGIN - RETURN QUERY SELECT seq, edge_id, source, target, flow, residual_capacity - FROM pgr_PushRelabel($1, $2, $3); - END - $BODY$ - LANGUAGE plpgsql VOLATILE; - -CREATE OR REPLACE FUNCTION pgr_maxFlowPushRelabel( - edges_sql TEXT, - source_vertex BIGINT, - sink_vertices ANYARRAY, - OUT seq INTEGER, - OUT edge_id BIGINT, - OUT source BIGINT, - OUT target BIGINT, - OUT flow BIGINT, - OUT residual_capacity BIGINT - ) - RETURNS SETOF RECORD AS - $BODY$ - BEGIN - RETURN QUERY SELECT seq, edge_id, source, target, flow, residual_capacity - FROM pgr_PushRelabel($1, $2, $3); - END - $BODY$ - LANGUAGE plpgsql VOLATILE; - -CREATE OR REPLACE FUNCTION pgr_maxFlowPushRelabel( - edges_sql TEXT, - source_vertices ANYARRAY, - sink_vertex BIGINT, - OUT seq INTEGER, - OUT edge_id BIGINT, - OUT source BIGINT, - OUT target BIGINT, - OUT flow BIGINT, - OUT residual_capacity BIGINT - ) - RETURNS SETOF RECORD AS - $BODY$ - BEGIN - RETURN QUERY SELECT seq, edge_id, source, target, flow, residual_capacity - FROM pgr_PushRelabel($1, $2, $3); - END - $BODY$ - LANGUAGE plpgsql VOLATILE; - -CREATE OR REPLACE FUNCTION pgr_maxFlowPushRelabel( - edges_sql TEXT, - source_vertices ANYARRAY, - sink_vertices ANYARRAY, - OUT seq INTEGER, - OUT edge_id BIGINT, - OUT source BIGINT, - OUT target BIGINT, - OUT flow BIGINT, - OUT residual_capacity BIGINT - ) - RETURNS SETOF RECORD AS - $BODY$ - BEGIN - RETURN QUERY SELECT seq, edge_id, source, target, flow, residual_capacity - FROM pgr_PushRelabel($1, $2, $3); - END - $BODY$ - LANGUAGE plpgsql VOLATILE; - ----------------------------------------------------------------------------- --- pgr_maxFlowBoykovKolmogorov ----------------------------------------------------------------------------- -CREATE OR REPLACE FUNCTION pgr_maxFlowBoykovKolmogorov( - edges_sql TEXT, - source_vertex BIGINT, - sink_vertex BIGINT, - OUT seq INTEGER, - OUT edge_id BIGINT, - OUT source BIGINT, - OUT target BIGINT, - OUT flow BIGINT, - OUT residual_capacity BIGINT - ) - RETURNS SETOF RECORD AS - $BODY$ - BEGIN - RETURN QUERY SELECT seq, edge_id, source, target, flow, residual_capacity - FROM pgr_boykovKolmogorov($1, $2, $3); - END - $BODY$ - LANGUAGE plpgsql VOLATILE; - -CREATE OR REPLACE FUNCTION pgr_maxFlowBoykovKolmogorov( - edges_sql TEXT, - source_vertex BIGINT, - sink_vertices ANYARRAY, - OUT seq INTEGER, - OUT edge_id BIGINT, - OUT source BIGINT, - OUT target BIGINT, - OUT flow BIGINT, - OUT residual_capacity BIGINT - ) - RETURNS SETOF RECORD AS - $BODY$ - BEGIN - RETURN QUERY SELECT seq, edge_id, source, target, flow, residual_capacity - FROM pgr_boykovKolmogorov($1, $2, $3); - END - $BODY$ - LANGUAGE plpgsql VOLATILE; - -CREATE OR REPLACE FUNCTION pgr_maxFlowBoykovKolmogorov( - edges_sql TEXT, - source_vertices ANYARRAY, - sink_vertex BIGINT, - OUT seq INTEGER, - OUT edge_id BIGINT, - OUT source BIGINT, - OUT target BIGINT, - OUT flow BIGINT, - OUT residual_capacity BIGINT - ) - RETURNS SETOF RECORD AS - $BODY$ - BEGIN - RETURN QUERY SELECT seq, edge_id, source, target, flow, residual_capacity - FROM pgr_boykovKolmogorov($1, $2, $3); - END - $BODY$ - LANGUAGE plpgsql VOLATILE; - -CREATE OR REPLACE FUNCTION pgr_maxFlowBoykovKolmogorov( - edges_sql TEXT, - source_vertices ANYARRAY, - sink_vertices ANYARRAY, - OUT seq INTEGER, - OUT edge_id BIGINT, - OUT source BIGINT, - OUT target BIGINT, - OUT flow BIGINT, - OUT residual_capacity BIGINT - ) - RETURNS SETOF RECORD AS - $BODY$ - BEGIN - RETURN QUERY SELECT seq, edge_id, source, target, flow, residual_capacity - FROM pgr_boykovKolmogorov($1, $2, $3); - END - $BODY$ - LANGUAGE plpgsql VOLATILE; - ----------------------------------------------------------------------------- --- pgr_maxFlowEdmondsKarp ----------------------------------------------------------------------------- -CREATE OR REPLACE FUNCTION pgr_maxFlowEdmondsKarp( - edges_sql TEXT, - source_vertex BIGINT, - sink_vertex BIGINT, - OUT seq INTEGER, - OUT edge_id BIGINT, - OUT source BIGINT, - OUT target BIGINT, - OUT flow BIGINT, - OUT residual_capacity BIGINT - ) - RETURNS SETOF RECORD AS - $BODY$ - BEGIN - RETURN QUERY SELECT seq, edge_id, source, target, flow, residual_capacity - FROM pgr_edmondsKarp($1, $2, $3); - END - $BODY$ - LANGUAGE plpgsql VOLATILE; - - -CREATE OR REPLACE FUNCTION pgr_maxFlowEdmondsKarp( - edges_sql TEXT, - source_vertex BIGINT, - sink_vertices ANYARRAY, - OUT seq INTEGER, - OUT edge_id BIGINT, - OUT source BIGINT, - OUT target BIGINT, - OUT flow BIGINT, - OUT residual_capacity BIGINT - ) - RETURNS SETOF RECORD AS - $BODY$ - BEGIN - RETURN QUERY SELECT seq, edge_id, source, target, flow, residual_capacity - FROM pgr_edmondsKarp($1, $2, $3); - END - $BODY$ - LANGUAGE plpgsql VOLATILE; - -CREATE OR REPLACE FUNCTION pgr_maxFlowEdmondsKarp( - edges_sql TEXT, - source_vertices ANYARRAY, - sink_vertex BIGINT, - OUT seq INTEGER, - OUT edge_id BIGINT, - OUT source BIGINT, - OUT target BIGINT, - OUT flow BIGINT, - OUT residual_capacity BIGINT - ) - RETURNS SETOF RECORD AS - $BODY$ - BEGIN - RETURN QUERY SELECT seq, edge_id, source, target, flow, residual_capacity - FROM pgr_edmondsKarp($1, $2, $3); - END - $BODY$ - LANGUAGE plpgsql VOLATILE; - -CREATE OR REPLACE FUNCTION pgr_maxFlowEdmondsKarp( - edges_sql TEXT, - source_vertices ANYARRAY, - sink_vertices ANYARRAY, - OUT seq INTEGER, - OUT edge_id BIGINT, - OUT source BIGINT, - OUT target BIGINT, - OUT flow BIGINT, - OUT residual_capacity BIGINT - ) - RETURNS SETOF RECORD AS - $BODY$ - BEGIN - RETURN QUERY SELECT seq, edge_id, source, target, flow, residual_capacity - FROM pgr_edmondsKarp($1, $2, $3); - END - $BODY$ - LANGUAGE plpgsql VOLATILE; - - ----------------------------------------------------------------------------- --- pgr_maximumcardinalitymatching ----------------------------------------------------------------------------- -CREATE OR REPLACE FUNCTION pgr_maximumcardinalitymatching( - edges_sql TEXT, - directed BOOLEAN DEFAULT TRUE, - OUT seq INTEGER, - OUT edge_id BIGINT, - OUT source BIGINT, - OUT target BIGINT - ) - RETURNS SETOF RECORD AS - $BODY$ - BEGIN - RETURN QUERY SELECT seq, edge_id, source, target, flow, residual_capacity - FROM pgr_maxCardinalityMatch($1, $2); - END - $BODY$ - LANGUAGE plpgsql VOLATILE; diff --git a/sql/legacy/pgrouting_version.sql b/sql/legacy/pgrouting_version.sql deleted file mode 100644 index 263d7fd683a..00000000000 --- a/sql/legacy/pgrouting_version.sql +++ /dev/null @@ -1,56 +0,0 @@ -/*PGR-MIT***************************************************************** - -FILE: pgrouting_version.sql - -Copyright (c) 2013 pgRouting developers -Mail: project@pgrouting.org -Author: Stephen Woodbridge - ------- -MIT/X license - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - -********************************************************************PGR-MIT*/ - ---v3.0 -CREATE FUNCTION pgr_version() -RETURNS TABLE( - "version" varchar, - tag varchar, - hash varchar, - branch varchar, - boost varchar - ) AS -$BODY$ - SELECT '${PROJECT_VERSION}'::varchar AS version, - '${PROJECT_FULL_VERSION}'::varchar AS tag, - '${PROJECT_GIT_HASH}'::varchar AS hash, - '${PROJECT_GIT_BRANCH}'::varchar AS branch, - '${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}'::varchar AS boost; -$BODY$ -LANGUAGE sql IMMUTABLE; - -COMMENT ON FUNCTION pgr_version() IS -'pgr_version -- Documentation - - ${PROJECT_DOC_LINK}/pgr_version.html -'; diff --git a/sql/legacy/pointsAsPolygon.sql b/sql/legacy/pointsAsPolygon.sql deleted file mode 100644 index 0bd3b6c381c..00000000000 --- a/sql/legacy/pointsAsPolygon.sql +++ /dev/null @@ -1,73 +0,0 @@ -/*PGR-GNU***************************************************************** - -Copyright (c) 2015~2019 Celia Virginia Vergara Castillo -Mail: project@pgrouting.org - ------- - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - ********************************************************************PGR-GNU*/ - ----------------------- --- pgr_pointsAsPolygon ----------------------- - - -/* ----------------------------------------------------------- --- Draws an alpha shape around given set of points. --- ** This should be rewritten as an aggregate. ** ----------------------------------------------------------- -*/ -CREATE OR REPLACE FUNCTION pgr_pointsAsPolygon( - VARCHAR, -- query (required) - alpha FLOAT8 DEFAULT 0) - -RETURNS geometry AS -$BODY$ -DECLARE - geoms geometry[]; - vertex_result record; - i BIGINT; - q TEXT; - -BEGIN - q = format($$ - WITH - a AS ( - %1$s - ), - b AS (SELECT ST_makePoint(x, y) AS geom FROM a) - SELECT array_agg(geom) FROM b - $$, $1); - -- RAISE NOTICE '%', q; - EXECUTE q INTO geoms; - - -- RAISE NOTICE 'length = %', array_length(geoms, 1); - RETURN pgr_alphashape1(geoms, sqrt(alpha), false); -END; -$BODY$ -LANGUAGE plpgsql VOLATILE STRICT; - -COMMENT ON FUNCTION pgr_pointsAsPolygon(VARCHAR, FLOAT8) -IS 'pgr_pointsAsPolygon -- Parameters: - - An SQL with columns: id, x, y -- Optional Parameters: - - alpha := 0 -- Documentation: - - ${PROJECT_DOC_LINK}/pgr_pointsAsPolygon.html -'; diff --git a/sql/legacy/routing_legacy.sql b/sql/legacy/routing_legacy.sql deleted file mode 100644 index 65913e154ca..00000000000 --- a/sql/legacy/routing_legacy.sql +++ /dev/null @@ -1,316 +0,0 @@ -/*PGR-GNU***************************************************************** - -Copyright (c) 2015 ~ pgRouting developers -Mail: project@pgrouting.org - -Copyright (c) 2015 Celia Virginia Vergara Castillo -mail: vicky_vergara@hotmail.com - ------- - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - ********************************************************************PGR-GNU*/ - -CREATE TYPE pgr_costResult AS -( - seq integer, - id1 integer, - id2 integer, - cost float8 -); - -CREATE TYPE pgr_costResult3 AS -( - seq integer, - id1 integer, - id2 integer, - id3 integer, - cost float8 -); - -CREATE TYPE pgr_geomResult AS -( - seq integer, - id1 integer, - id2 integer, - geom geometry -); - ----------------------------------------------------------------------------- --- Routing function: pgr_dijkstra --- Developer: Vicky Vergara --- --- --- Availability: --- - Created on v2.0.0 --- - Deprecated signature on v2.1.0 --- - Moved to legacy on v3.0 --- --- Use the new signatures of pgr_dijkstra instead ----------------------------------------------------------------------------- - -CREATE OR REPLACE FUNCTION pgr_dijkstra( - edges_sql TEXT, - start_vid INTEGER, - end_vid INTEGER, - directed BOOLEAN, - has_rcost BOOLEAN) -RETURNS SETOF pgr_costresult AS -$BODY$ -DECLARE -has_reverse BOOLEAN; -sql TEXT; -BEGIN - RETURN query SELECT seq-1 AS seq, node::integer AS id1, edge::integer AS id2, cost - FROM _pgr_dijkstra(sql, ARRAY[$2]::BIGINT[], ARRAY[$3]::BIGINT[], directed, false); - END -$BODY$ -LANGUAGE plpgsql VOLATILE -COST 100 -ROWS 1000; - - ------------------------------------------------------------------------------ ---- Routing function: pgr_drivingDistance ---- Developer: Vicky Vergara ---- ---- ---- Availability: ---- - Created on v2.0.0 ---- - Deprecated on v2.1.0 ---- - moved to legacy on v3.0.0 ---- ---- Use the new signatures of pgr_drivingDistance instead ------------------------------------------------------------------------------ -CREATE OR REPLACE FUNCTION pgr_drivingDistance(edges_sql text, source INTEGER, distance FLOAT8, directed BOOLEAN, has_rcost BOOLEAN) -RETURNS SETOF pgr_costresult AS -$BODY$ - SELECT seq - 1, node::INTEGER, edge::INTEGER, agg_cost - FROM pgr_drivingDistance($1, ARRAY[$2]::BIGINT[], $3, $4); -$BODY$ -LANGUAGE sql VOLATILE -COST 100 -ROWS 1000; - ----------------------------------------------------------------------------- --- Routing function: pgr_ksp --- Developer: Vicky Vergara --- --- --- Availability: --- - Created on v2.0.0 --- - Deprecated on v2.1.0 --- - moved to legacy on v3.0 --- --- Use the new signature of pgr_KSP instead ----------------------------------------------------------------------------- -CREATE OR REPLACE FUNCTION pgr_ksp(edges_sql text, start_vid integer, end_vid integer, k integer, has_rcost boolean) -RETURNS SETOF pgr_costresult3 AS -$BODY$ - SELECT ((row_number() over()) -1)::integer, (path_id - 1)::integer, node::integer, edge::integer, cost - FROM pgr_ksp($1::text, $2::BIGINT, $3::BIGINT, $4, TRUE, FALSE) WHERE path_id <= k; -$BODY$ -LANGUAGE sql VOLATILE -COST 100 -ROWS 1000; - ----------------------------------------------------------------------------- --- Routing function: pgr_kdijkstraPath --- Developer: Steve Woodbridge --- --- Availability: --- - Created on v2.0.0 --- - Deprecated signature on v2.2.0 --- - Moved to legacy on v3.0 --- --- Use the new signatures of pgr_dijkstra instead ----------------------------------------------------------------------------- -CREATE OR REPLACE FUNCTION pgr_kdijkstraPath( - sql text, - source INTEGER, - targets INTEGER ARRAY, - directed BOOLEAN, - has_rcost BOOLEAN) -RETURNS SETOF pgr_costResult3 AS -$BODY$ -SELECT (row_number() over () -1)::integer, end_vid::INTEGER, node::INTEGER, edge::INTEGER, cost -FROM pgr_dijkstra($1, $2, $3, $4); -$BODY$ -LANGUAGE sql VOLATILE -COST 100 -ROWS 1000; - - ----------------------------------------------------------------------------- --- Routing function: pgr_kdijkstraCost --- Developer: Steve Woodbridge --- --- Availability: --- - Created on v2.0.0 --- - Deprecated signature on v2.2.0 --- - Moved to legacy on v3.0 --- --- Use the new signatures of pgr_dijkstraCost instead ----------------------------------------------------------------------------- -CREATE OR REPLACE FUNCTION pgr_kdijkstracost( - sql text, - source INTEGER, - targets INTEGER array, - directed BOOLEAN, - has_rcost BOOLEAN) -RETURNS SETOF pgr_costResult AS -$BODY$ - SELECT (row_number() over () -1)::integer, start_vid::integer, end_vid::INTEGER, agg_cost - FROM pgr_dijkstraCost($1, $2, $3, $4); -$BODY$ -LANGUAGE sql VOLATILE -COST 100 -ROWS 1000; - ----------------------------------------------------------------------------- --- Routing function: pgr_apspJohnson --- Developer: Vicky Vergara --- --- --- Availability: --- - Created on v2.0.0 --- - Deprecated on v2.2.0 --- - Moved to legacy on v3.0 --- --- Use the new signatures of pgr_johnson instead ----------------------------------------------------------------------------- - -CREATE OR REPLACE FUNCTION pgr_apspJohnson(edges_sql text) -RETURNS SETOF pgr_costResult AS -$BODY$ - SELECT (row_number() over () - 1)::INTEGER, start_vid::INTEGER, end_vid::INTEGER, agg_cost - FROM pgr_johnson($1, TRUE); -$BODY$ -LANGUAGE sql VOLATILE -COST 100 -ROWS 1000; - - - - ----------------------------------------------------------------------------- --- Routing function: pgr_apspWarshall --- Developer: Vicky Vergara --- --- --- Availability: --- - Created on v2.0.0 --- - Deprecated on v2.2.0 --- - Moved to legacy on v3.0 --- --- Use the new signatures of pgr_floydWarshall instead ----------------------------------------------------------------------------- -CREATE OR REPLACE FUNCTION pgr_apspWarshall(edges_sql text, directed BOOLEAN, has_rcost BOOLEAN) -RETURNS SETOF pgr_costResult AS -$BODY$ - SELECT (row_number() over () -1)::INTEGER, start_vid::INTEGER, end_vid::INTEGER, agg_cost - FROM pgr_floydWarshall($1, $2); -$BODY$ -LANGUAGE sql VOLATILE -COST 100 -ROWS 1000; - ----------------------------------------------------------------------------- --- Routing function: pgr_astar --- Developer: Vicky Vergara --- --- --- Availability: --- - Created on v2.0.0 --- - Deprecated on v2.3.0 --- - Moved to legacy on v3.0 --- --- Use the new signatures of pgr_aStar instead ----------------------------------------------------------------------------- - -CREATE OR REPLACE FUNCTION pgr_astar(edges_sql TEXT, source_id INTEGER, target_id INTEGER, directed BOOLEAN, has_rcost BOOLEAN) -RETURNS SETOF pgr_costresult AS -$BODY$ -DECLARE -has_reverse BOOLEAN; -sql TEXT; -BEGIN - RETURN query SELECT seq - 1 AS seq, node::INTEGER AS id1, edge::INTEGER AS id2, cost - FROM pgr_astar(sql, ARRAY[$2], ARRAY[$3], directed); -END -$BODY$ -LANGUAGE plpgsql VOLATILE -COST 100 -ROWS 1000; - - - ----------------------------------------------------------------------------- --- Routing function: pgr_bdDijkstra --- Developer: Vicky Vergara --- --- --- Availability: --- - Created on v2.0.0 --- - Deprecated on v2.4.0 --- - Moved to legacy on v3.0 --- --- Use the new signatures of pgr_bdDijkstra instead ----------------------------------------------------------------------------- -CREATE OR REPLACE FUNCTION pgr_bdDijkstra(edges_sql TEXT, start_vid INTEGER, end_vid INTEGER, directed BOOLEAN, has_rcost BOOLEAN) -RETURNS SETOF pgr_costresult AS -$BODY$ -DECLARE -has_reverse BOOLEAN; -sql TEXT; -BEGIN - SELECT seq - 1 AS seq, node::integer AS id1, edge::integer AS id2, cost - FROM pgr_bdDijkstra($1, ARRAY[$2]::BIGINT[], ARRAY[$3]::BIGINT[], $4); -END -$BODY$ -LANGUAGE plpgsql VOLATILE -COST 100 -ROWS 1000; - - - - ----------------------------------------------------------------------------- --- Routing function: pgr_bdAstar --- Developer: Vicky Vergara --- --- --- Availability: --- - Created on v2.0.0 --- - Deprecated on v2.5.0 --- - Moved to legacy on v3.0 --- --- Use the new signatures of pgr_bdAstar instead ----------------------------------------------------------------------------- -CREATE OR REPLACE FUNCTION pgr_bdAstar( - edges_sql TEXT, - start_vid INTEGER, - end_vid INTEGER, - directed BOOLEAN, - has_rcost BOOLEAN) -RETURNS SETOF pgr_costresult AS -$BODY$ - SELECT seq - 1 AS seq, node::integer AS id1, edge::integer AS id2, cost - FROM pgr_bdAstar($1, ARRAY[$2]::BIGINT[], ARRAY[$3]::BIGINT[], $4); -$BODY$ -LANGUAGE sql VOLATILE -COST 100 -ROWS 1000; diff --git a/sql/legacy/tsp/TSPeucledian.sql b/sql/legacy/tsp/TSPeucledian.sql deleted file mode 100644 index d3bb611a3fb..00000000000 --- a/sql/legacy/tsp/TSPeucledian.sql +++ /dev/null @@ -1,69 +0,0 @@ -/*PGR-GNU***************************************************************** - -Copyright (c) 2016 pgRouting developers -Mail: project@pgrouting.org - -Copyright (c) 2016 Celia Virginia Vergara Castillo -mail: vicky_vergara@hotmail.com - ------- - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - ********************************************************************PGR-GNU*/ - - --------------------- --- pgr_euclideanTSP --------------------- - -CREATE OR REPLACE FUNCTION pgr_euclideanTSP( - TEXT, -- coordinates_sql (required) - - start_id BIGINT DEFAULT 0, - end_id BIGINT DEFAULT 0, - - max_processing_time FLOAT DEFAULT '+infinity'::FLOAT, - - tries_per_temperature INTEGER DEFAULT 500, - max_changes_per_temperature INTEGER DEFAULT 60, - max_consecutive_non_changes INTEGER DEFAULT 100, - - initial_temperature FLOAT DEFAULT 100, - final_temperature FLOAT DEFAULT 0.1, - cooling_factor FLOAT DEFAULT 0.9, - - randomize BOOLEAN DEFAULT true, - - OUT seq integer, - OUT node BIGINT, - OUT cost FLOAT, - OUT agg_cost FLOAT) -RETURNS SETOF RECORD AS -$BODY$ - SELECT seq, node, cost, agg_cost - FROM pgr_TSPeuclidean(_pgr_get_statement($1), $2,$3, $4, $5,$6,$7, $8,$9,$10, $11); -$BODY$ -LANGUAGE SQL VOLATILE STRICT -COST 100 -ROWS 1000; - - --- COMMENTS - - -COMMENT ON FUNCTION pgr_eucledianTSP(TEXT, BIGINT, BIGINT, FLOAT, INTEGER, INTEGER, INTEGER, FLOAT, FLOAT, FLOAT, BOOLEAN) -IS 'pgRouting deprecated function -Use pgr_TSPeuclidean instead'; diff --git a/sql/legacy/tsp/_makeDistanceMatrix.sql b/sql/legacy/tsp/_makeDistanceMatrix.sql deleted file mode 100644 index 07da120eb9b..00000000000 --- a/sql/legacy/tsp/_makeDistanceMatrix.sql +++ /dev/null @@ -1,77 +0,0 @@ -/*PGR-MIT***************************************************************** - --- --- Copyright (c) 2013 Stephen Woodbridge --- --- This files is released under an MIT-X license. -Copyright (c) 2015 pgRouting developers -Mail: project@pgrouting.org - ------- -MIT/X license - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - -********************************************************************PGR-MIT*/ - - ----------------------------- --- _pgr_makeDistanceMatrix ----------------------------- - - -create or replace function _pgr_makeDistanceMatrix - (sqlin text, - - OUT dmatrix double precision[], - OUT ids integer[]) - as -$body$ -declare - sql text; - r record; - -begin - dmatrix := array[]::double precision[]; - ids := array[]::integer[]; - - sql := 'with nodes as (' || sqlin || ') - select i, array_agg(dist) as arow from ( - select a.id as i, b.id as j, st_distance(st_makepoint(a.x, a.y), st_makepoint(b.x, b.y)) as dist - from nodes a, nodes b - order by a.id, b.id - ) as foo group by i order by i'; - - for r in execute sql loop - dmatrix := array_cat(dmatrix, array[r.arow]); - ids := ids || array[r.i]; - end loop; - -end; -$body$ -language plpgsql stable cost 10; - - --- COMMENTS - - -COMMENT ON FUNCTION _pgr_makeDistanceMatrix(TEXT) -IS 'pgRouting internal function'; diff --git a/sql/legacy/tsp/tsp_v2.0_coordinates.sql b/sql/legacy/tsp/tsp_v2.0_coordinates.sql deleted file mode 100644 index 7e2837746fa..00000000000 --- a/sql/legacy/tsp/tsp_v2.0_coordinates.sql +++ /dev/null @@ -1,108 +0,0 @@ -/*PGR-GNU***************************************************************** - -Copyright (c) 2016 pgRouting developers -Mail: project@pgrouting.org - -Copyright (c) 2016 Celia Virginia Vergara Castillo -mail: vicky_vergara@hotmail.com - ------- - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - ********************************************************************PGR-GNU*/ -/* - Old signature has: - sql: id INTEGER, x FLOAT, y FLOAT -*/ - - ------------------------ --- pgr_tsp ------------------------ - - -CREATE OR REPLACE FUNCTION pgr_tsp( - sql text, - start_id INTEGER, - end_id INTEGER default (-1), - - OUT seq INTEGER, - OUT id1 INTEGER, - OUT id2 INTEGER, - OUT cost FLOAT -) -returns setof record as -$body$ -DECLARE -table_sql TEXT; -rec RECORD; -debuglevel TEXT; -n BIGINT; - -BEGIN - RAISE NOTICE 'Deprecated Signature pgr_tsp(sql, integer, integer)'; - - table_sql := 'CREATE TEMP TABLE ___tmp ON COMMIT DROP AS ' || sql ; - EXECUTE table_sql; - - - BEGIN - EXECUTE 'SELECT id, x, y FROM ___tmp' INTO rec; - EXCEPTION - WHEN OTHERS THEN - RAISE EXCEPTION 'An expected column was not found in the query' - USING ERRCODE = 'XX000', - HINT = 'Please verify the column names: id, x, y'; - END; - - EXECUTE - 'SELECT - pg_typeof(id)::text as id_type, - pg_typeof(x)::text as x_type, - pg_typeof(y)::text as y_type FROM ___tmp' INTO rec; - - - IF NOT((rec.id_type in ('integer'::text)) - AND (rec.x_type = 'double precision'::text) - AND (rec.y_type = 'double precision'::text)) THEN - RAISE EXCEPTION '''id'' must be of type INTEGER, ''x'' ad ''y'' must be of type FLOAT' - USING ERRCODE = 'XX000'; - END IF; - - EXECUTE 'SELECT count(*) AS n FROM (' || sql || ') AS __a__' INTO rec; - n = rec.n; - - RETURN query - SELECT (seq - 1)::INTEGER AS seq, node::INTEGER AS id1, node::INTEGER AS id2, cost - FROM pgr_eucledianTSP(sql, start_id, end_id, - - tries_per_temperature := 500 * n :: INTEGER, - max_changes_per_temperature := 60 * n :: INTEGER, - max_consecutive_non_changes := 500 * n :: INTEGER, - - randomize := false) WHERE seq <= n; - DROP TABLE ___tmp; - -END; -$body$ -language plpgsql volatile STRICT cost 500 ROWS 50; - - --- COMMENTS - - -COMMENT ON FUNCTION pgr_tsp(text, INTEGER, INTEGER) -IS 'DEPRECATED'; diff --git a/sql/legacy/tsp/tsp_v2.0_matrix.sql b/sql/legacy/tsp/tsp_v2.0_matrix.sql deleted file mode 100644 index b24d988a4c5..00000000000 --- a/sql/legacy/tsp/tsp_v2.0_matrix.sql +++ /dev/null @@ -1,133 +0,0 @@ -/*PGR-GNU***************************************************************** - -Copyright (c) 2016 pgRouting developers -Mail: project@pgrouting.org - -Copyright (c) 2016 Celia Virginia Vergara Castillo -mail: vicky_vergara@hotmail.com - ------- - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - ********************************************************************PGR-GNU*/ - - ----------------- ----------------- --- tsp ----------------- ----------------- - - ------------------------ --- _pgr_unnest_matrix ------------------------ - - -CREATE OR REPLACE FUNCTION _pgr_unnest_matrix - (matrix float8[][], - - OUT start_vid integer, - OUT end_vid integer, - out agg_cost float8) -RETURNS SETOF record AS - -$body$ -DECLARE - -m float8[]; - -BEGIN - start_vid = 1; - foreach m slice 1 in ARRAY matrix - LOOP - end_vid = 1; - foreach agg_cost in ARRAY m - LOOP - RETURN next; - end_vid = end_vid + 1; - END LOOP; - start_vid = start_vid + 1; - END LOOP; -END; -$body$ -language plpgsql volatile STRICT cost 500 ROWS 50; - - -CREATE OR REPLACE FUNCTION pgr_tsp - (matrix float8[][], - - startpt INTEGER, - endpt INTEGER DEFAULT -1, - - OUT seq INTEGER, - OUT id INTEGER) -RETURNS SETOF record AS -$body$ -DECLARE -table_sql TEXT; -debuglevel TEXT; -BEGIN - RAISE NOTICE 'Deprecated Signature pgr_tsp(float8[][], integer, integer)'; - - CREATE TEMP TABLE ___tmp2 ON COMMIT DROP AS - SELECT start_vid, end_vid, agg_cost FROM _pgr_unnest_matrix( matrix ); - - - startpt := startpt + 1; - IF endpt = -1 THEN endpt := startpt; - END IF; - - - RETURN QUERY - WITH - result AS ( - SELECT seq, id FROM pgr_TSP( - $$SELECT start_vid, end_vid, agg_cost FROM ___tmp2 $$, - startpt, endpt, - - tries_per_temperature := 500 :: INTEGER, - max_changes_per_temperature := 30 :: INTEGER, - max_consecutive_non_changes := 500 :: INTEGER, - - randomize:=false) - ) - SELECT (row_number() over(ORDER BY result.seq) - 1)::INTEGER AS seq, (result.node - 1)::INTEGER AS id - - FROM result WHERE NOT(result.node = startpt AND result.seq != 1); - - DROP TABLE ___tmp2; -END; -$body$ -language plpgsql volatile STRICT cost 500 ROWS 50; - - --- COMMENTS - - -COMMENT ON FUNCTION _pgr_unnest_matrix(FLOAT[][]) -IS 'DEPRECATED'; - - -COMMENT ON FUNCTION pgr_tsp(FLOAT[][], INTEGER, INTEGER) -IS 'pgr_tsp -- Parameters - - Matrix - - startpt - - endpt -- Documentation: - - ${PGROUTING_DOC_LINK}/pgr_tsp.html -'; diff --git a/sql/legacy/vrppdtw/_gsoc_vrppdtw.sql b/sql/legacy/vrppdtw/_gsoc_vrppdtw.sql deleted file mode 100644 index 9265086f2a0..00000000000 --- a/sql/legacy/vrppdtw/_gsoc_vrppdtw.sql +++ /dev/null @@ -1,105 +0,0 @@ -/*PGR-GNU***************************************************************** -File: _gsoc_vrppdtw.sql - -Generated with Template by: -Copyright (c) 2017 pgRouting developers -Mail: project@pgrouting.org - -Function's developer: -Copyright (c) 2017 Celia Virginia Vergara Castillo -Mail: - ------- - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - ********************************************************************PGR-GNU*/ - - ----------------------------- --- _pgr_gsoc_vrppdtw ----------------------------- - - -CREATE OR REPLACE FUNCTION _pgr_gsoc_vrppdtw( - customers_sql TEXT, - max_vehicles INTEGER, - capacity FLOAT, - speed FLOAT DEFAULT 1, - max_cycles INTEGER DEFAULT 10, - - OUT seq INTEGER, - OUT vehicle_id INTEGER, - OUT vehicle_seq INTEGER, - OUT stop_id BIGINT, - OUT travel_time FLOAT, - OUT arrival_time FLOAT, - OUT wait_time FLOAT, - OUT service_time FLOAT, - OUT departure_time FLOAT -) -RETURNS SETOF RECORD AS -$BODY$ -DECLARE - orders_sql TEXT; - vehicles_sql TEXT; - final_sql TEXT; -BEGIN - orders_sql = $$WITH - customer_data AS ($$ || customers_sql || $$ ), - pickups AS ( - SELECT id, demand, x as p_x, y as p_y, opentime as p_open, closetime as p_close, servicetime as p_service - FROM customer_data WHERE pindex = 0 AND id != 0 - ), - deliveries AS ( - SELECT pindex AS id, x as d_x, y as d_y, opentime as d_open, closetime as d_close, servicetime as d_service - FROM customer_data WHERE dindex = 0 AND id != 0 - ) - SELECT id, demand, p_x, p_y, p_open, p_close, p_service, d_x, d_y, d_open, d_close, d_service - FROM pickups JOIN deliveries USING(id) ORDER BY pickups.id - $$; - - vehicles_sql = $$WITH - customer_data AS ($$ || customers_sql || $$ ) - SELECT id, x AS start_x, y AS start_y, - opentime AS start_open, closetime AS start_close, $$ || - capacity || $$ AS capacity, $$ || max_vehicles || $$ AS number, $$ || speed || $$ AS speed - FROM customer_data WHERE id = 0 LIMIT 1 - $$; --- seq | vehicle_id | vehicle_seq | stop_id | travel_time | arrival_time | wait_time | service_time | departure_time - final_sql = $$ WITH - customer_data AS ($$ || customers_sql || $$ ), - p_deliver AS (SELECT seq, vehicle_seq, vehicle_id, stop_seq, stop_type, order_id, cargo, travel_time, arrival_time, wait_time, service_time, departure_time - FROM _pgr_pickDeliverEuclidean('$$ || orders_sql || $$', '$$ || vehicles_sql || $$', 1, $$ || max_cycles || $$ )), - picks AS (SELECT p_deliver.*, pindex, dindex, id AS the_id FROM p_deliver JOIN customer_data ON (id = order_id AND stop_type = 2)), - delivers AS (SELECT p_deliver.*, pindex, dindex, dindex AS the_id FROM p_deliver JOIN customer_data ON (id = order_id AND stop_type = 3)), - depots AS (SELECT p_deliver.*, 0 as pindex, 0 as dindex, 0 AS the_id FROM p_deliver WHERE (stop_type IN (-1,1,6))), - the_union AS (SELECT * FROM picks UNION SELECT * FROM delivers UNION SELECT * from depots) - - SELECT (row_number() over(ORDER BY a.seq))::INTEGER, vehicle_seq, a.stop_seq, the_id::BIGINT, a.travel_time, a.arrival_time, a.wait_time, a.service_time, a.departure_time - FROM (SELECT * FROM the_union) AS a ORDER BY a.seq - $$; - RETURN QUERY EXECUTE final_sql; -END; -$BODY$ -LANGUAGE plpgsql VOLATILE STRICT; - - --- COMMENTS - - -COMMENT ON FUNCTION _pgr_gsoc_vrppdtw(TEXT, INTEGER, FLOAT, FLOAT, INTEGER) -IS 'pgRouting Deprecated internal function'; - diff --git a/sql/legacy/vrppdtw/gsoc_vrppdtw.sql b/sql/legacy/vrppdtw/gsoc_vrppdtw.sql deleted file mode 100644 index f2c85d26542..00000000000 --- a/sql/legacy/vrppdtw/gsoc_vrppdtw.sql +++ /dev/null @@ -1,66 +0,0 @@ -/*PGR-GNU***************************************************************** -File: reginabook.sql - -Generated with Template by: -Copyright (c) 2017 pgRouting developers -Mail: project@pgrouting.org - -Function's developer: -Copyright (c) 2017 Celia Virginia Vergara Castillo -Mail: - ------- - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - ********************************************************************PGR-GNU*/ - - ----------------------------- --- pgr_gsoc_vrppdtw ----------------------------- - - -CREATE OR REPLACE FUNCTION pgr_gsoc_vrppdtw( - text, -- SQL (required) - INTEGER, -- vehicle_num (required) - INTEGER, -- capacity (required) - - OUT seq INTEGER, - OUT id1 INTEGER, - OUT id2 INTEGER, - OUT cost FLOAT -) -RETURNS SETOF record AS -$BODY$ -DECLARE -has_reverse BOOLEAN; -customers_sql TEXT; -BEGIN - RETURN query - SELECT a.seq, vehicle_id::INTEGER AS id1, stop_id::INTEGER AS id2, departure_time AS cost - FROM _pgr_gsoc_vrppdtw($1, $2, $3, 1, 30) AS a WHERE vehicle_id NOT IN (-2); -END -$BODY$ -LANGUAGE plpgsql VOLATILE STRICT -COST 100 -ROWS 1000; - - --- COMMENTS - - -COMMENT ON FUNCTION pgr_gsoc_vrppdtw(TEXT, INTEGER, INTEGER) -IS 'pgr_gsoc_vrppdtw deprecated experimental function'; diff --git a/sql/sigs/pgrouting--4.0.sig b/sql/sigs/pgrouting--4.0.sig index 5c8022230a7..4914f4a43e4 100644 --- a/sql/sigs/pgrouting--4.0.sig +++ b/sql/sigs/pgrouting--4.0.sig @@ -127,7 +127,6 @@ pgr_dijkstra(text,text,boolean) _pgr_dijkstrav4(text,text,anyarray,anyarray,boolean,boolean,boolean,bigint,boolean) _pgr_dijkstravia(text,anyarray,boolean,boolean,boolean) pgr_dijkstravia(text,anyarray,boolean,boolean,boolean) -_pgr_drivingdistance(text,anyarray,double precision,boolean,boolean) pgr_drivingdistance(text,anyarray,double precision,boolean,boolean) pgr_drivingdistance(text,bigint,double precision,boolean) _pgr_drivingdistancev4(text,anyarray,double precision,boolean,boolean) diff --git a/src/driving_distance/driving_distance.c b/src/driving_distance/driving_distance.c index d687beb3dad..48f6d874891 100644 --- a/src/driving_distance/driving_distance.c +++ b/src/driving_distance/driving_distance.c @@ -37,10 +37,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. #include "drivers/driving_distance/driving_distance_driver.h" - -PGDLLEXPORT Datum _pgr_drivingdistance(PG_FUNCTION_ARGS); -PG_FUNCTION_INFO_V1(_pgr_drivingdistance); - PGDLLEXPORT Datum _pgr_drivingdistancev4(PG_FUNCTION_ARGS); PG_FUNCTION_INFO_V1(_pgr_drivingdistancev4); @@ -164,10 +160,14 @@ _pgr_drivingdistancev4(PG_FUNCTION_ARGS) { } -/* Old code starts here - * TODO(v4) remove old code - * its code that is used when there is an old version of SQL 3.5 and under +/* Deprecated code starts here + * TODO(v5) remove deprecated code + * This code that is used on v3.5 and under */ + +PGDLLEXPORT Datum _pgr_drivingdistance(PG_FUNCTION_ARGS); +PG_FUNCTION_INFO_V1(_pgr_drivingdistance); + PGDLLEXPORT Datum _pgr_drivingdistance(PG_FUNCTION_ARGS) { FuncCallContext *funcctx; @@ -176,6 +176,12 @@ _pgr_drivingdistance(PG_FUNCTION_ARGS) { MST_rt *result_tuples = 0; size_t result_count = 0; + ereport(NOTICE, ( + errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("A stored procedure is using deprecated C internal function '%s'", __func__), + errdetail("Library function '%s' was deprecated in pgRouting %s", __func__, "3.6.0"), + errhint("Consider upgrade pgRouting"))); + if (SRF_IS_FIRSTCALL()) { MemoryContext oldcontext;