Skip to content

Commit c4cd95c

Browse files
committed
(SQL) _pgr_withPointsVia: removal of deprecated internal function
1 parent 54dc6d8 commit c4cd95c

File tree

4 files changed

+2
-148
lines changed

4 files changed

+2
-148
lines changed

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ milestone for 4.0.0
6666
* _pgr_trsp(text,text,bigint,anyarray,boolean)
6767
* _pgr_trsp(text,text,bigint,bigint,boolean)
6868
* _pgr_trspviavertices(text,integer[],boolean,boolean,text)
69+
* _pgr_withpointsvia(text,bigint[],double precision[],boolean)
6970
* _trsp(text,text,anyarray,anyarray,boolean)
7071
* _v4trsp(text,text,anyarray,anyarray,boolean)
7172
* _v4trsp(text,text,text,boolean)

doc/src/release_notes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ milestone for 4.0.0
9797
* _pgr_trsp(text,text,bigint,anyarray,boolean)
9898
* _pgr_trsp(text,text,bigint,bigint,boolean)
9999
* _pgr_trspviavertices(text,integer[],boolean,boolean,text)
100+
* _pgr_withpointsvia(text,bigint[],double precision[],boolean)
100101
* _trsp(text,text,anyarray,anyarray,boolean)
101102
* _v4trsp(text,text,anyarray,anyarray,boolean)
102103
* _v4trsp(text,text,text,boolean)

sql/sigs/pgrouting--4.0.sig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,5 @@ pgr_withpoints(text,text,bigint,anyarray,boolean,character,boolean)
320320
pgr_withpoints(text,text,bigint,bigint,boolean,character,boolean)
321321
pgr_withpoints(text,text,text,boolean,character,boolean)
322322
_pgr_withpoints(text,text,text,boolean,character,boolean,boolean)
323-
_pgr_withpointsvia(text,bigint[],double precision[],boolean)
324323
_pgr_withpointsvia(text,text,anyarray,boolean,boolean,boolean,character,boolean)
325324
pgr_withpointsvia(text,text,anyarray,boolean,boolean,boolean,character,boolean)

sql/withPoints/withPointsVia.sql

Lines changed: 0 additions & 147 deletions
Original file line numberDiff line numberDiff line change
@@ -77,150 +77,3 @@ IS 'pgr_withPointsVia
7777
- Documentation:
7878
- ${PROJECT_DOC_LINK}/pgr_withPointsVia.html
7979
';
80-
81-
--v2.6
82-
CREATE FUNCTION _pgr_withPointsVia(
83-
sql TEXT,
84-
via_edges BIGINT[],
85-
fraction FLOAT[],
86-
directed BOOLEAN DEFAULT TRUE,
87-
88-
OUT seq INTEGER,
89-
OUT path_id INTEGER,
90-
OUT path_seq INTEGER,
91-
OUT start_vid BIGINT,
92-
OUT end_vid BIGINT,
93-
OUT node BIGINT,
94-
OUT edge BIGINT,
95-
OUT cost FLOAT,
96-
OUT agg_cost FLOAT,
97-
OUT route_agg_cost FLOAT)
98-
99-
RETURNS SETOF RECORD AS
100-
$BODY$
101-
DECLARE
102-
has_rcost boolean;
103-
sql_new_vertices text := ' ';
104-
sql_on_vertex text;
105-
v_union text := ' ';
106-
dummyrec record;
107-
rec1 record;
108-
via_vertices int[];
109-
sql_safe text;
110-
new_edges text;
111-
BEGIN
112-
BEGIN
113-
sql_safe = 'SELECT id, source, target, cost, reverse_cost FROM ('|| sql || ') AS __a';
114-
115-
EXECUTE 'select reverse_cost, pg_typeof(reverse_cost)::text as rev_type from ('||sql_safe||' ) AS __b__ limit 1 ' INTO rec1;
116-
has_rcost := true;
117-
EXCEPTION
118-
WHEN OTHERS THEN
119-
has_rcost = false;
120-
END;
121-
122-
123-
IF array_length(via_edges, 1) != array_length(fraction, 1) then
124-
RAISE EXCEPTION 'The length of via_edges is different of length of via_edges';
125-
END IF;
126-
127-
FOR i IN 1 .. array_length(via_edges, 1)
128-
LOOP
129-
IF fraction[i] = 0 THEN
130-
sql_on_vertex := 'SELECT source FROM ('|| sql || ') __a where id = ' || via_edges[i];
131-
EXECUTE sql_on_vertex into dummyrec;
132-
via_vertices[i] = dummyrec.source;
133-
ELSE IF fraction[i] = 1 THEN
134-
sql_on_vertex := 'SELECT target FROM ('|| sql || ') __a where id = ' || via_edges[i];
135-
EXECUTE sql_on_vertex into dummyrec;
136-
via_vertices[i] = dummyrec.target;
137-
ELSE
138-
via_vertices[i] = -i;
139-
IF has_rcost THEN
140-
sql_new_vertices = sql_new_vertices || v_union ||
141-
'(SELECT id, source, ' || -i || ' AS target, cost * ' || fraction[i] || ' AS cost,
142-
reverse_cost * (1 - ' || fraction[i] || ') AS reverse_cost
143-
FROM (SELECT * FROM (' || sql || ') __b' || i || ' WHERE id = ' || via_edges[i] || ') __a' || i ||')
144-
UNION
145-
(SELECT id, ' || -i || ' AS source, target, cost * (1 -' || fraction[i] || ') AS cost,
146-
reverse_cost * ' || fraction[i] || ' AS reverse_cost
147-
FROM (SELECT * FROM (' || sql || ') __b' || i || ' where id = ' || via_edges[i] || ') __a' || i ||')';
148-
v_union = ' UNION ';
149-
ELSE
150-
sql_new_vertices = sql_new_vertices || v_union ||
151-
'(SELECT id, source, ' || -i || ' AS target, cost * ' || fraction[i] || ' AS cost
152-
FROM (SELECT * FROM (' || sql || ') __b' || i || ' WHERE id = ' || via_edges[i] || ') __a' || i ||')
153-
UNION
154-
(SELECT id, ' || -i || ' AS source, target, cost * (1 -' || fraction[i] || ') AS cost
155-
FROM (SELECT * FROM (' || sql || ') __b' || i || ' WHERE id = ' || via_edges[i] || ') __a' || i ||')';
156-
v_union = ' UNION ';
157-
END IF;
158-
END IF;
159-
END IF;
160-
END LOOP;
161-
162-
IF sql_new_vertices = ' ' THEN
163-
new_edges := sql;
164-
ELSE
165-
IF has_rcost THEN
166-
new_edges:= 'WITH
167-
orig AS ( ' || sql || '),
168-
original AS (SELECT id, source, target, cost, reverse_cost FROM orig),
169-
the_union AS ( ' || sql_new_vertices || '),
170-
first_part AS ( SELECT * FROM (SELECT id, target AS source, lead(target) OVER w AS target,
171-
lead(cost) OVER w - cost AS cost,
172-
lead(cost) OVER w - cost AS reverse_cost
173-
FROM the_union WHERE source > 0 AND cost > 0
174-
WINDOW w AS (PARTITION BY id ORDER BY cost ASC) ) as n2
175-
WHERE target IS NOT NULL),
176-
second_part AS ( SELECT * FROM (SELECT id, lead(source) OVER w AS source, source as target,
177-
reverse_cost - lead(reverse_cost) OVER w AS cost,
178-
reverse_cost - lead(reverse_cost) OVER w AS reverse_cost
179-
FROM the_union WHERE target > 0 and reverse_cost > 0
180-
WINDOW w AS (PARTITION BY id ORDER BY reverse_cost ASC) ) as n2
181-
WHERE source IS NOT NULL),
182-
more_union AS ( SELECT * from (
183-
(SELECT * FROM original)
184-
UNION
185-
(SELECT * FROM the_union)
186-
UNION
187-
(SELECT * FROM first_part)
188-
UNION
189-
(SELECT * FROM second_part) ) _union )
190-
SELECT * FROM more_union';
191-
ELSE
192-
new_edges:= 'WITH
193-
orig AS ( ' || sql || '),
194-
original AS (SELECT id, source, target, cost FROM orig),
195-
the_union AS ( ' || sql_new_vertices || '),
196-
first_part AS ( SELECT * FROM (SELECT id, target AS source, lead(target) OVER w AS target,
197-
lead(cost) OVER w - cost AS cost
198-
FROM the_union WHERE source > 0 AND cost > 0
199-
WINDOW w AS (PARTITION BY id ORDER BY cost ASC) ) as n2
200-
WHERE target IS NOT NULL ),
201-
more_union AS ( SELECT * from (
202-
(SELECT * FROM original)
203-
UNION
204-
(SELECT * FROM the_union)
205-
UNION
206-
(SELECT * FROM first_part) ) _union )
207-
SELECT * FROM more_union';
208-
END IF;
209-
END IF;
210-
211-
sql_new_vertices := sql_new_vertices || v_union || ' (' || sql || ')';
212-
213-
RETURN query SELECT *
214-
FROM pgr_dijkstraVia(new_edges, via_vertices, directed, has_rcost);
215-
END
216-
$BODY$
217-
LANGUAGE plpgsql VOLATILE STRICT
218-
COST 100
219-
ROWS 1000;
220-
221-
222-
-- COMMENTS
223-
224-
225-
COMMENT ON FUNCTION _pgr_withPointsVia(TEXT, BIGINT[], FLOAT[], BOOLEAN)
226-
IS 'pgRouting internal function deprecated on v3.4.0';

0 commit comments

Comments
 (0)