From 716e52019a72efe1984a9a31e995a253311908bb Mon Sep 17 00:00:00 2001 From: Abhinav Jain Date: Mon, 21 Aug 2023 03:10:07 +0530 Subject: [PATCH] [withPointsKSP][docqueries] Updating for withPointsKSP and migration docs --- docqueries/src/migration.result | 31 ++ docqueries/src/migration.test.sql | 13 + .../withPoints/doc-pgr_withPointsKSP.result | 296 ++++++++++++------ .../withPoints/doc-pgr_withPointsKSP.test.sql | 44 ++- 4 files changed, 274 insertions(+), 110 deletions(-) diff --git a/docqueries/src/migration.result b/docqueries/src/migration.result index ac237aaeec..03029b8d8b 100644 --- a/docqueries/src/migration.result +++ b/docqueries/src/migration.result @@ -868,5 +868,36 @@ SELECT seq, node, edge, cost, agg_cost FROM pgr_withPointsDD( (10 rows) /* --withpointsdd5 */ +/* --withPointsKSP1 */ +SELECT * FROM pgr_withPointsKSP( + $$SELECT id, source, target, cost, reverse_cost FROM edges$$, + $$SELECT pid, edge_id, fraction, side from pointsOfInterest$$, + 6, 10, 1,'r'); + seq | path_id | path_seq | start_vid | end_vid | node | edge | cost | agg_cost +-----+---------+----------+-----------+---------+------+------+------+---------- + 1 | 1 | 1 | 6 | 10 | 6 | 4 | 1 | 0 + 2 | 1 | 2 | 6 | 10 | 7 | 8 | 1 | 1 + 3 | 1 | 3 | 6 | 10 | 11 | 9 | 1 | 2 + 4 | 1 | 4 | 6 | 10 | 16 | 16 | 1 | 3 + 5 | 1 | 5 | 6 | 10 | 15 | 3 | 1 | 4 + 6 | 1 | 6 | 6 | 10 | 10 | -1 | 0 | 5 +(6 rows) + +/* --withPointsKSP2 */ +SELECT seq, path_seq, node, edge, cost, agg_cost FROM pgr_withPointsKSP( + $$SELECT id, source, target, cost, reverse_cost FROM edges$$, + $$SELECT pid, edge_id, fraction, side from pointsOfInterest$$, + 6, 10, 1,'r'); + seq | path_seq | node | edge | cost | agg_cost +-----+----------+------+------+------+---------- + 1 | 1 | 6 | 4 | 1 | 0 + 2 | 2 | 7 | 8 | 1 | 1 + 3 | 3 | 11 | 9 | 1 | 2 + 4 | 4 | 16 | 16 | 1 | 3 + 5 | 5 | 15 | 3 | 1 | 4 + 6 | 6 | 10 | -1 | 0 | 5 +(6 rows) + +/* --withPointsKSP3 */ ROLLBACK; ROLLBACK diff --git a/docqueries/src/migration.test.sql b/docqueries/src/migration.test.sql index 6fb18f1570..f6d261ee94 100644 --- a/docqueries/src/migration.test.sql +++ b/docqueries/src/migration.test.sql @@ -283,3 +283,16 @@ SELECT seq, node, edge, cost, agg_cost FROM pgr_withPointsDD( $$SELECT pid, edge_id, fraction, side from pointsOfInterest$$, -5, 2.3, 'r'); /* --withpointsdd5 */ +/* --withPointsKSP1 */ +SELECT * FROM pgr_withPointsKSP( + $$SELECT id, source, target, cost, reverse_cost FROM edges$$, + $$SELECT pid, edge_id, fraction, side from pointsOfInterest$$, + 6, 10, 1,'r'); + +/* --withPointsKSP2 */ +SELECT seq, path_seq, node, edge, cost, agg_cost FROM pgr_withPointsKSP( + $$SELECT id, source, target, cost, reverse_cost FROM edges$$, + $$SELECT pid, edge_id, fraction, side from pointsOfInterest$$, + 6, 10, 1,'r'); + +/* --withPointsKSP3 */ \ No newline at end of file diff --git a/docqueries/withPoints/doc-pgr_withPointsKSP.result b/docqueries/withPoints/doc-pgr_withPointsKSP.result index 89bb5cdf88..7b5c6ec5a5 100644 --- a/docqueries/withPoints/doc-pgr_withPointsKSP.result +++ b/docqueries/withPoints/doc-pgr_withPointsKSP.result @@ -8,90 +8,137 @@ SET SELECT * FROM pgr_withPointsKSP( 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - -1, -2, 2); - seq | path_id | path_seq | node | edge | cost | agg_cost ------+---------+----------+------+------+------+---------- - 1 | 1 | 1 | -1 | 1 | 0.6 | 0 - 2 | 1 | 2 | 6 | 4 | 1 | 0.6 - 3 | 1 | 3 | 7 | 8 | 1 | 1.6 - 4 | 1 | 4 | 11 | 9 | 1 | 2.6 - 5 | 1 | 5 | 16 | 15 | 0.4 | 3.6 - 6 | 1 | 6 | -2 | -1 | 0 | 4 - 7 | 2 | 1 | -1 | 1 | 0.6 | 0 - 8 | 2 | 2 | 6 | 4 | 1 | 0.6 - 9 | 2 | 3 | 7 | 8 | 1 | 1.6 - 10 | 2 | 4 | 11 | 11 | 1 | 2.6 - 11 | 2 | 5 | 12 | 13 | 1 | 3.6 - 12 | 2 | 6 | 17 | 15 | 0.6 | 4.6 - 13 | 2 | 7 | -2 | -1 | 0 | 5.2 + -1, -2, 2, 'l'); + seq | path_id | path_seq | start_vid | end_vid | node | edge | cost | agg_cost +-----+---------+----------+-----------+---------+------+------+------+---------- + 1 | 1 | 1 | -1 | -2 | -1 | 1 | 0.6 | 0 + 2 | 1 | 2 | -1 | -2 | 6 | 4 | 1 | 0.6 + 3 | 1 | 3 | -1 | -2 | 7 | 8 | 1 | 1.6 + 4 | 1 | 4 | -1 | -2 | 11 | 11 | 1 | 2.6 + 5 | 1 | 5 | -1 | -2 | 12 | 13 | 1 | 3.6 + 6 | 1 | 6 | -1 | -2 | 17 | 15 | 0.6 | 4.6 + 7 | 1 | 7 | -1 | -2 | -2 | -1 | 0 | 5.2 + 8 | 2 | 1 | -1 | -2 | -1 | 1 | 0.6 | 0 + 9 | 2 | 2 | -1 | -2 | 6 | 4 | 1 | 0.6 + 10 | 2 | 3 | -1 | -2 | 7 | 8 | 1 | 1.6 + 11 | 2 | 4 | -1 | -2 | 11 | 9 | 1 | 2.6 + 12 | 2 | 5 | -1 | -2 | 16 | 15 | 1.6 | 3.6 + 13 | 2 | 6 | -1 | -2 | -2 | -1 | 0 | 5.2 (13 rows) /* --q2 */ SELECT * FROM pgr_withPointsKSP( - 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', - 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - -1, -2, 2, - driving_side := 'l', details := true); - seq | path_id | path_seq | node | edge | cost | agg_cost ------+---------+----------+------+------+------+---------- - 1 | 1 | 1 | -1 | 1 | 0.6 | 0 - 2 | 1 | 2 | 6 | 4 | 0.7 | 0.6 - 3 | 1 | 3 | -6 | 4 | 0.3 | 1.3 - 4 | 1 | 4 | 7 | 8 | 1 | 1.6 - 5 | 1 | 5 | 11 | 11 | 1 | 2.6 - 6 | 1 | 6 | 12 | 13 | 1 | 3.6 - 7 | 1 | 7 | 17 | 15 | 0.6 | 4.6 - 8 | 1 | 8 | -2 | -1 | 0 | 5.2 - 9 | 2 | 1 | -1 | 1 | 0.6 | 0 - 10 | 2 | 2 | 6 | 4 | 0.7 | 0.6 - 11 | 2 | 3 | -6 | 4 | 0.3 | 1.3 - 12 | 2 | 4 | 7 | 8 | 1 | 1.6 - 13 | 2 | 5 | 11 | 9 | 1 | 2.6 - 14 | 2 | 6 | 16 | 15 | 1 | 3.6 - 15 | 2 | 7 | 17 | 15 | 0.6 | 4.6 - 16 | 2 | 8 | -2 | -1 | 0 | 5.2 -(16 rows) + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', + 'SELECT pid, edge_id, fraction, side from pointsOfInterest', + -1, ARRAY[-3, 7], 2, 'B', + directed => false); + seq | path_id | path_seq | start_vid | end_vid | node | edge | cost | agg_cost +-----+---------+----------+-----------+---------+------+------+------+---------- + 1 | 1 | 1 | -1 | -3 | -1 | 1 | 0.6 | 0 + 2 | 1 | 2 | -1 | -3 | 6 | 4 | 1 | 0.6 + 3 | 1 | 3 | -1 | -3 | 7 | 10 | 1 | 1.6 + 4 | 1 | 4 | -1 | -3 | 8 | 12 | 0.6 | 2.6 + 5 | 1 | 5 | -1 | -3 | -3 | -1 | 0 | 3.2 + 6 | 2 | 1 | -1 | -3 | -1 | 1 | 0.6 | 0 + 7 | 2 | 2 | -1 | -3 | 6 | 4 | 1 | 0.6 + 8 | 2 | 3 | -1 | -3 | 7 | 8 | 1 | 1.6 + 9 | 2 | 4 | -1 | -3 | 11 | 11 | 1 | 2.6 + 10 | 2 | 5 | -1 | -3 | 12 | 12 | 0.4 | 3.6 + 11 | 2 | 6 | -1 | -3 | -3 | -1 | 0 | 4 + 12 | 3 | 1 | -1 | 7 | -1 | 1 | 0.6 | 0 + 13 | 3 | 2 | -1 | 7 | 6 | 4 | 1 | 0.6 + 14 | 3 | 3 | -1 | 7 | 7 | -1 | 0 | 1.6 + 15 | 4 | 1 | -1 | 7 | -1 | 1 | 0.6 | 0 + 16 | 4 | 2 | -1 | 7 | 6 | 2 | 1 | 0.6 + 17 | 4 | 3 | -1 | 7 | 10 | 5 | 1 | 1.6 + 18 | 4 | 4 | -1 | 7 | 11 | 8 | 1 | 2.6 + 19 | 4 | 5 | -1 | 7 | 7 | -1 | 0 | 3.6 +(19 rows) /* --q3 */ SELECT * FROM pgr_withPointsKSP( - 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', - 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - -1, -2, 2, - heap_paths := true, driving_side := 'r', details := true); - seq | path_id | path_seq | node | edge | cost | agg_cost ------+---------+----------+------+------+------+---------- - 1 | 1 | 1 | -1 | 1 | 0.4 | 0 - 2 | 1 | 2 | 5 | 1 | 1 | 0.4 - 3 | 1 | 3 | 6 | 4 | 0.7 | 1.4 - 4 | 1 | 4 | -6 | 4 | 0.3 | 2.1 - 5 | 1 | 5 | 7 | 8 | 1 | 2.4 - 6 | 1 | 6 | 11 | 9 | 1 | 3.4 - 7 | 1 | 7 | 16 | 15 | 0.4 | 4.4 - 8 | 1 | 8 | -2 | -1 | 0 | 4.8 - 9 | 2 | 1 | -1 | 1 | 0.4 | 0 - 10 | 2 | 2 | 5 | 1 | 1 | 0.4 - 11 | 2 | 3 | 6 | 4 | 0.7 | 1.4 - 12 | 2 | 4 | -6 | 4 | 0.3 | 2.1 - 13 | 2 | 5 | 7 | 8 | 1 | 2.4 - 14 | 2 | 6 | 11 | 11 | 1 | 3.4 - 15 | 2 | 7 | 12 | 13 | 1 | 4.4 - 16 | 2 | 8 | 17 | 15 | 1 | 5.4 - 17 | 2 | 9 | 16 | 15 | 0.4 | 6.4 - 18 | 2 | 10 | -2 | -1 | 0 | 6.8 - 19 | 3 | 1 | -1 | 1 | 0.4 | 0 - 20 | 3 | 2 | 5 | 1 | 1 | 0.4 - 21 | 3 | 3 | 6 | 4 | 0.7 | 1.4 - 22 | 3 | 4 | -6 | 4 | 0.3 | 2.1 - 23 | 3 | 5 | 7 | 10 | 1 | 2.4 - 24 | 3 | 6 | 8 | 12 | 0.6 | 3.4 - 25 | 3 | 7 | -3 | 12 | 0.4 | 4 - 26 | 3 | 8 | 12 | 13 | 1 | 4.4 - 27 | 3 | 9 | 17 | 15 | 1 | 5.4 - 28 | 3 | 10 | 16 | 15 | 0.4 | 6.4 - 29 | 3 | 11 | -2 | -1 | 0 | 6.8 -(29 rows) + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', + 'SELECT pid, edge_id, fraction, side from pointsOfInterest', + ARRAY[-1, 6], -3, 1,'r', details:= true); + seq | path_id | path_seq | start_vid | end_vid | node | edge | cost | agg_cost +-----+---------+----------+-----------+---------+------+------+------+---------- + 1 | 1 | 1 | -1 | -3 | -1 | 1 | 0.4 | 0 + 2 | 1 | 2 | -1 | -3 | 5 | 1 | 1 | 0.4 + 3 | 1 | 3 | -1 | -3 | 6 | 4 | 0.7 | 1.4 + 4 | 1 | 4 | -1 | -3 | -6 | 4 | 0.3 | 2.1 + 5 | 1 | 5 | -1 | -3 | 7 | 10 | 1 | 2.4 + 6 | 1 | 6 | -1 | -3 | 8 | 12 | 0.6 | 3.4 + 7 | 1 | 7 | -1 | -3 | -3 | -1 | 0 | 4 + 8 | 2 | 1 | 6 | -3 | 6 | 4 | 0.7 | 0 + 9 | 2 | 2 | 6 | -3 | -6 | 4 | 0.3 | 0.7 + 10 | 2 | 3 | 6 | -3 | 7 | 10 | 1 | 1 + 11 | 2 | 4 | 6 | -3 | 8 | 12 | 0.6 | 2 + 12 | 2 | 5 | 6 | -3 | -3 | -1 | 0 | 2.6 +(12 rows) /* --q4 */ +SELECT * FROM pgr_withPointsKSP( + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', + 'SELECT pid, edge_id, fraction, side from pointsOfInterest', + ARRAY[-1, 6], ARRAY[-3, 1], 1, 'l', heap_paths:= true); + seq | path_id | path_seq | start_vid | end_vid | node | edge | cost | agg_cost +-----+---------+----------+-----------+---------+------+------+------+---------- + 1 | 1 | 1 | -1 | -3 | -1 | 1 | 0.6 | 0 + 2 | 1 | 2 | -1 | -3 | 6 | 4 | 1 | 0.6 + 3 | 1 | 3 | -1 | -3 | 7 | 10 | 1 | 1.6 + 4 | 1 | 4 | -1 | -3 | 8 | 12 | 0.6 | 2.6 + 5 | 1 | 5 | -1 | -3 | -3 | -1 | 0 | 3.2 + 6 | 2 | 1 | -1 | 1 | -1 | 1 | 0.6 | 0 + 7 | 2 | 2 | -1 | 1 | 6 | 4 | 1 | 0.6 + 8 | 2 | 3 | -1 | 1 | 7 | 7 | 1 | 1.6 + 9 | 2 | 4 | -1 | 1 | 3 | 6 | 1 | 2.6 + 10 | 2 | 5 | -1 | 1 | 1 | -1 | 0 | 3.6 + 11 | 3 | 1 | 6 | -3 | 6 | 4 | 1 | 0 + 12 | 3 | 2 | 6 | -3 | 7 | 10 | 1 | 1 + 13 | 3 | 3 | 6 | -3 | 8 | 12 | 0.6 | 2 + 14 | 3 | 4 | 6 | -3 | -3 | -1 | 0 | 2.6 + 15 | 4 | 1 | 6 | 1 | 6 | 4 | 1 | 0 + 16 | 4 | 2 | 6 | 1 | 7 | 7 | 1 | 1 + 17 | 4 | 3 | 6 | 1 | 3 | 6 | 1 | 2 + 18 | 4 | 4 | 6 | 1 | 1 | -1 | 0 | 3 +(18 rows) + +/* --q5 */ +SELECT * FROM pgr_withPointsKSP( + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', + 'SELECT pid, edge_id, fraction, side from pointsOfInterest', + 'SELECT * FROM (VALUES (-1, 10), (6, -3)) AS combinations(source, target)', + 2, 'r', details => true); + seq | path_id | path_seq | start_vid | end_vid | node | edge | cost | agg_cost +-----+---------+----------+-----------+---------+------+------+------+---------- + 1 | 1 | 1 | -1 | 10 | -1 | 1 | 0.4 | 0 + 2 | 1 | 2 | -1 | 10 | 5 | 1 | 1 | 0.4 + 3 | 1 | 3 | -1 | 10 | 6 | 4 | 0.7 | 1.4 + 4 | 1 | 4 | -1 | 10 | -6 | 4 | 0.3 | 2.1 + 5 | 1 | 5 | -1 | 10 | 7 | 8 | 1 | 2.4 + 6 | 1 | 6 | -1 | 10 | 11 | 9 | 1 | 3.4 + 7 | 1 | 7 | -1 | 10 | 16 | 16 | 1 | 4.4 + 8 | 1 | 8 | -1 | 10 | 15 | 3 | 1 | 5.4 + 9 | 1 | 9 | -1 | 10 | 10 | -1 | 0 | 6.4 + 10 | 2 | 1 | -1 | 10 | -1 | 1 | 0.4 | 0 + 11 | 2 | 2 | -1 | 10 | 5 | 1 | 1 | 0.4 + 12 | 2 | 3 | -1 | 10 | 6 | 4 | 0.7 | 1.4 + 13 | 2 | 4 | -1 | 10 | -6 | 4 | 0.3 | 2.1 + 14 | 2 | 5 | -1 | 10 | 7 | 8 | 1 | 2.4 + 15 | 2 | 6 | -1 | 10 | 11 | 11 | 1 | 3.4 + 16 | 2 | 7 | -1 | 10 | 12 | 13 | 1 | 4.4 + 17 | 2 | 8 | -1 | 10 | 17 | 15 | 1 | 5.4 + 18 | 2 | 9 | -1 | 10 | 16 | 16 | 1 | 6.4 + 19 | 2 | 10 | -1 | 10 | 15 | 3 | 1 | 7.4 + 20 | 2 | 11 | -1 | 10 | 10 | -1 | 0 | 8.4 + 21 | 3 | 1 | 6 | -3 | 6 | 4 | 0.7 | 0 + 22 | 3 | 2 | 6 | -3 | -6 | 4 | 0.3 | 0.7 + 23 | 3 | 3 | 6 | -3 | 7 | 10 | 1 | 1 + 24 | 3 | 4 | 6 | -3 | 8 | 12 | 0.6 | 2 + 25 | 3 | 5 | 6 | -3 | -3 | -1 | 0 | 2.6 +(25 rows) + +/* --q6 */ SELECT * FROM pgr_withPointsKSP( $e$ SELECT * FROM edges $e$, $p$ SELECT edge_id, round(fraction::numeric, 2) AS fraction, side @@ -100,30 +147,83 @@ SELECT * FROM pgr_withPointsKSP( (SELECT ST_POINT(2.9, 1.8)), 0.5, cap => 2) $p$, - 1, -1, 2, - driving_side := 'r'); - seq | path_id | path_seq | node | edge | cost | agg_cost ------+---------+----------+------+------+------+---------- - 1 | 1 | 1 | 1 | 6 | 1 | 0 - 2 | 1 | 2 | 3 | 7 | 1 | 1 - 3 | 1 | 3 | 7 | 8 | 1 | 2 - 4 | 1 | 4 | 11 | 9 | 1 | 3 - 5 | 1 | 5 | 16 | 16 | 1 | 4 - 6 | 1 | 6 | 15 | 3 | 1 | 5 - 7 | 1 | 7 | 10 | 5 | 0.8 | 6 - 8 | 1 | 8 | -1 | -1 | 0 | 6.8 - 9 | 2 | 1 | 1 | 6 | 1 | 0 - 10 | 2 | 2 | 3 | 7 | 1 | 1 - 11 | 2 | 3 | 7 | 10 | 1 | 2 - 12 | 2 | 4 | 8 | 12 | 1 | 3 - 13 | 2 | 5 | 12 | 13 | 1 | 4 - 14 | 2 | 6 | 17 | 15 | 1 | 5 - 15 | 2 | 7 | 16 | 16 | 1 | 6 - 16 | 2 | 8 | 15 | 3 | 1 | 7 - 17 | 2 | 9 | 10 | 5 | 0.8 | 8 - 18 | 2 | 10 | -1 | -1 | 0 | 8.8 + 1, -1, 2,'r'); + seq | path_id | path_seq | start_vid | end_vid | node | edge | cost | agg_cost +-----+---------+----------+-----------+---------+------+------+------+---------- + 1 | 1 | 1 | 1 | -1 | 1 | 6 | 1 | 0 + 2 | 1 | 2 | 1 | -1 | 3 | 7 | 1 | 1 + 3 | 1 | 3 | 1 | -1 | 7 | 8 | 1 | 2 + 4 | 1 | 4 | 1 | -1 | 11 | 9 | 1 | 3 + 5 | 1 | 5 | 1 | -1 | 16 | 16 | 1 | 4 + 6 | 1 | 6 | 1 | -1 | 15 | 3 | 1 | 5 + 7 | 1 | 7 | 1 | -1 | 10 | 5 | 0.8 | 6 + 8 | 1 | 8 | 1 | -1 | -1 | -1 | 0 | 6.8 + 9 | 2 | 1 | 1 | -1 | 1 | 6 | 1 | 0 + 10 | 2 | 2 | 1 | -1 | 3 | 7 | 1 | 1 + 11 | 2 | 3 | 1 | -1 | 7 | 10 | 1 | 2 + 12 | 2 | 4 | 1 | -1 | 8 | 12 | 1 | 3 + 13 | 2 | 5 | 1 | -1 | 12 | 13 | 1 | 4 + 14 | 2 | 6 | 1 | -1 | 17 | 15 | 1 | 5 + 15 | 2 | 7 | 1 | -1 | 16 | 16 | 1 | 6 + 16 | 2 | 8 | 1 | -1 | 15 | 3 | 1 | 7 + 17 | 2 | 9 | 1 | -1 | 10 | 5 | 0.8 | 8 + 18 | 2 | 10 | 1 | -1 | -1 | -1 | 0 | 8.8 (18 rows) -/* -- q5 */ +/* --q7 */ +SELECT * FROM pgr_withPointsKSP( + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', + 'SELECT pid, edge_id, fraction, side from pointsOfInterest', + -1, -3, 2, 'l', details := true); + seq | path_id | path_seq | start_vid | end_vid | node | edge | cost | agg_cost +-----+---------+----------+-----------+---------+------+------+------+---------- + 1 | 1 | 1 | -1 | -3 | -1 | 1 | 0.6 | 0 + 2 | 1 | 2 | -1 | -3 | 6 | 4 | 0.7 | 0.6 + 3 | 1 | 3 | -1 | -3 | -6 | 4 | 0.3 | 1.3 + 4 | 1 | 4 | -1 | -3 | 7 | 10 | 1 | 1.6 + 5 | 1 | 5 | -1 | -3 | 8 | 12 | 0.6 | 2.6 + 6 | 1 | 6 | -1 | -3 | -3 | -1 | 0 | 3.2 +(6 rows) + +/* --q8 */ +SELECT * FROM pgr_withPointsKSP( + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', + 'SELECT pid, edge_id, fraction, side from pointsOfInterest', + -1, -2, 2, 'r', + heap_paths := true, details := true); + seq | path_id | path_seq | start_vid | end_vid | node | edge | cost | agg_cost +-----+---------+----------+-----------+---------+------+------+------+---------- + 1 | 1 | 1 | -1 | -2 | -1 | 1 | 0.4 | 0 + 2 | 1 | 2 | -1 | -2 | 5 | 1 | 1 | 0.4 + 3 | 1 | 3 | -1 | -2 | 6 | 4 | 0.7 | 1.4 + 4 | 1 | 4 | -1 | -2 | -6 | 4 | 0.3 | 2.1 + 5 | 1 | 5 | -1 | -2 | 7 | 8 | 1 | 2.4 + 6 | 1 | 6 | -1 | -2 | 11 | 9 | 1 | 3.4 + 7 | 1 | 7 | -1 | -2 | 16 | 15 | 0.4 | 4.4 + 8 | 1 | 8 | -1 | -2 | -2 | -1 | 0 | 4.8 + 9 | 2 | 1 | -1 | -2 | -1 | 1 | 0.4 | 0 + 10 | 2 | 2 | -1 | -2 | 5 | 1 | 1 | 0.4 + 11 | 2 | 3 | -1 | -2 | 6 | 4 | 0.7 | 1.4 + 12 | 2 | 4 | -1 | -2 | -6 | 4 | 0.3 | 2.1 + 13 | 2 | 5 | -1 | -2 | 7 | 8 | 1 | 2.4 + 14 | 2 | 6 | -1 | -2 | 11 | 11 | 1 | 3.4 + 15 | 2 | 7 | -1 | -2 | 12 | 13 | 1 | 4.4 + 16 | 2 | 8 | -1 | -2 | 17 | 15 | 1 | 5.4 + 17 | 2 | 9 | -1 | -2 | 16 | 15 | 0.4 | 6.4 + 18 | 2 | 10 | -1 | -2 | -2 | -1 | 0 | 6.8 + 19 | 3 | 1 | -1 | -2 | -1 | 1 | 0.4 | 0 + 20 | 3 | 2 | -1 | -2 | 5 | 1 | 1 | 0.4 + 21 | 3 | 3 | -1 | -2 | 6 | 4 | 0.7 | 1.4 + 22 | 3 | 4 | -1 | -2 | -6 | 4 | 0.3 | 2.1 + 23 | 3 | 5 | -1 | -2 | 7 | 10 | 1 | 2.4 + 24 | 3 | 6 | -1 | -2 | 8 | 12 | 0.6 | 3.4 + 25 | 3 | 7 | -1 | -2 | -3 | 12 | 0.4 | 4 + 26 | 3 | 8 | -1 | -2 | 12 | 13 | 1 | 4.4 + 27 | 3 | 9 | -1 | -2 | 17 | 15 | 1 | 5.4 + 28 | 3 | 10 | -1 | -2 | 16 | 15 | 0.4 | 6.4 + 29 | 3 | 11 | -1 | -2 | -2 | -1 | 0 | 6.8 +(29 rows) + +/* --q9 */ ROLLBACK; ROLLBACK diff --git a/docqueries/withPoints/doc-pgr_withPointsKSP.test.sql b/docqueries/withPoints/doc-pgr_withPointsKSP.test.sql index 89ed7818ae..04c2484c40 100644 --- a/docqueries/withPoints/doc-pgr_withPointsKSP.test.sql +++ b/docqueries/withPoints/doc-pgr_withPointsKSP.test.sql @@ -5,20 +5,30 @@ SET extra_float_digits=-3; SELECT * FROM pgr_withPointsKSP( 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - -1, -2, 2); + -1, -2, 2, 'l'); /* --q2 */ SELECT * FROM pgr_withPointsKSP( - 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', - 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - -1, -2, 2, - driving_side := 'l', details := true); + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', + 'SELECT pid, edge_id, fraction, side from pointsOfInterest', + -1, ARRAY[-3, 7], 2, 'B', + directed => false); /* --q3 */ SELECT * FROM pgr_withPointsKSP( - 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', - 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - -1, -2, 2, - heap_paths := true, driving_side := 'r', details := true); + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', + 'SELECT pid, edge_id, fraction, side from pointsOfInterest', + ARRAY[-1, 6], -3, 1,'r', details:= true); /* --q4 */ +SELECT * FROM pgr_withPointsKSP( + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', + 'SELECT pid, edge_id, fraction, side from pointsOfInterest', + ARRAY[-1, 6], ARRAY[-3, 1], 1, 'l', heap_paths:= true); +/* --q5 */ +SELECT * FROM pgr_withPointsKSP( + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', + 'SELECT pid, edge_id, fraction, side from pointsOfInterest', + 'SELECT * FROM (VALUES (-1, 10), (6, -3)) AS combinations(source, target)', + 2, 'r', details => true); +/* --q6 */ SELECT * FROM pgr_withPointsKSP( $e$ SELECT * FROM edges $e$, $p$ SELECT edge_id, round(fraction::numeric, 2) AS fraction, side @@ -27,6 +37,16 @@ SELECT * FROM pgr_withPointsKSP( (SELECT ST_POINT(2.9, 1.8)), 0.5, cap => 2) $p$, - 1, -1, 2, - driving_side := 'r'); -/* -- q5 */ + 1, -1, 2,'r'); +/* --q7 */ +SELECT * FROM pgr_withPointsKSP( + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', + 'SELECT pid, edge_id, fraction, side from pointsOfInterest', + -1, -3, 2, 'l', details := true); +/* --q8 */ +SELECT * FROM pgr_withPointsKSP( + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', + 'SELECT pid, edge_id, fraction, side from pointsOfInterest', + -1, -2, 2, 'r', + heap_paths := true, details := true); +/* --q9 */ \ No newline at end of file