Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GSoC 2023: Aryan Gupta Week 2 #296

Merged
merged 4 commits into from
Jun 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ src/version/version.h
.directory
notUsed
*.swp

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

taptest.sh
run.sh
14 changes: 7 additions & 7 deletions docqueries/driving_distance/dijksraDD-issue729.result
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ UPDATE edges AS edge_table
SET node_count=count.sum
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not update result files unless things work 100%

FROM
(SELECT
from_v,
start_vid,
sum(node) AS sum
FROM
pgr_drivingDistance(
'SELECT id, source, target, ST_Length(geom) AS cost FROM edges',
ARRAY(SELECT DISTINCT source FROM edges),
1,
false)
GROUP BY from_v) AS count
WHERE edges.source=count.from_v
GROUP BY start_vid) AS count
WHERE edges.source=count.start_vid
;
ERROR: invalid reference to FROM-clause entry for table "edges"
LINE 14: WHERE edges.source=count.from_v
LINE 14: WHERE edges.source=count.start_vid
Copy link
Member

@cvvergara cvvergara Jun 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clearly there is something wrong.
Is it an original issue from the pgRouting repo?
If it is, then there is something wrong with the original. aka someone, probably me, did what you are doing without really looking.

^
HINT: Perhaps you meant to reference the table alias "edge_table".
ALTER TABLE edges
Expand All @@ -50,16 +50,16 @@ UPDATE network AS network
SET node_count=count.sum
FROM
(SELECT
from_v,
start_vid,
sum(node) AS sum
FROM
pgr_drivingDistance(
'SELECT id, source, target, cost FROM network',
ARRAY(SELECT DISTINCT source FROM network),
1,
false)
GROUP BY from_v) AS count
WHERE network.source=count.from_v
GROUP BY start_vid) AS count
WHERE network.source=count.start_vid
;
ERROR: current transaction is aborted, commands ignored until end of transaction block
ALTER TABLE network
Expand Down
12 changes: 6 additions & 6 deletions docqueries/driving_distance/dijksraDD-issue729.test.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ UPDATE edges AS edge_table
SET node_count=count.sum
FROM
(SELECT
from_v,
start_vid,
sum(node) AS sum
FROM
pgr_drivingDistance(
'SELECT id, source, target, ST_Length(geom) AS cost FROM edges',
ARRAY(SELECT DISTINCT source FROM edges),
1,
false)
GROUP BY from_v) AS count
WHERE edges.source=count.from_v
GROUP BY start_vid) AS count
WHERE edges.source=count.start_vid
;

ALTER TABLE edges
Expand All @@ -46,16 +46,16 @@ UPDATE network AS network
SET node_count=count.sum
FROM
(SELECT
from_v,
start_vid,
sum(node) AS sum
FROM
pgr_drivingDistance(
'SELECT id, source, target, cost FROM network',
ARRAY(SELECT DISTINCT source FROM network),
1,
false)
GROUP BY from_v) AS count
WHERE network.source=count.from_v
GROUP BY start_vid) AS count
WHERE network.source=count.start_vid
;

ALTER TABLE network
Expand Down
110 changes: 55 additions & 55 deletions docqueries/driving_distance/doc-pgr_drivingDistance.result
Original file line number Diff line number Diff line change
Expand Up @@ -6,73 +6,73 @@ SET
SELECT * FROM pgr_drivingDistance(
'SELECT id, source, target, cost, reverse_cost FROM edges',
11, 3.0);
seq | node | edge | cost | agg_cost
-----+------+------+------+----------
1 | 11 | -1 | 0 | 0
2 | 7 | 8 | 1 | 1
3 | 12 | 11 | 1 | 1
4 | 16 | 9 | 1 | 1
5 | 3 | 7 | 1 | 2
6 | 6 | 4 | 1 | 2
7 | 8 | 10 | 1 | 2
8 | 15 | 16 | 1 | 2
9 | 17 | 15 | 1 | 2
10 | 1 | 6 | 1 | 3
11 | 5 | 1 | 1 | 3
12 | 9 | 14 | 1 | 3
13 | 10 | 3 | 1 | 3
seq | start_vid | node | edge | cost | agg_cost
-----+-----------+------+------+------+----------
1 | 11 | 11 | -1 | 0 | 0
2 | 11 | 7 | 8 | 1 | 1
3 | 11 | 12 | 11 | 1 | 1
4 | 11 | 16 | 9 | 1 | 1
5 | 11 | 3 | 7 | 1 | 2
6 | 11 | 6 | 4 | 1 | 2
7 | 11 | 8 | 10 | 1 | 2
8 | 11 | 15 | 16 | 1 | 2
9 | 11 | 17 | 15 | 1 | 2
10 | 11 | 1 | 6 | 1 | 3
11 | 11 | 5 | 1 | 1 | 3
12 | 11 | 9 | 14 | 1 | 3
13 | 11 | 10 | 3 | 1 | 3
(13 rows)

/* --q6 */
SELECT * FROM pgr_drivingDistance(
'SELECT id, source, target, cost, reverse_cost FROM edges',
array[11, 16], 3.0, equicost => true);
seq | from_v | node | edge | cost | agg_cost
-----+--------+------+------+------+----------
1 | 11 | 11 | -1 | 0 | 0
2 | 11 | 7 | 8 | 1 | 1
3 | 11 | 12 | 11 | 1 | 1
4 | 11 | 3 | 7 | 1 | 2
5 | 11 | 6 | 4 | 1 | 2
6 | 11 | 8 | 10 | 1 | 2
7 | 11 | 1 | 6 | 1 | 3
8 | 11 | 5 | 1 | 1 | 3
9 | 11 | 9 | 14 | 1 | 3
10 | 16 | 16 | -1 | 0 | 0
11 | 16 | 15 | 16 | 1 | 1
12 | 16 | 17 | 15 | 1 | 1
13 | 16 | 10 | 3 | 1 | 2
seq | start_vid | node | edge | cost | agg_cost
-----+-----------+------+------+------+----------
1 | 11 | 11 | -1 | 0 | 0
2 | 11 | 7 | 8 | 1 | 1
3 | 11 | 12 | 11 | 1 | 1
4 | 11 | 3 | 7 | 1 | 2
5 | 11 | 6 | 4 | 1 | 2
6 | 11 | 8 | 10 | 1 | 2
7 | 11 | 1 | 6 | 1 | 3
8 | 11 | 5 | 1 | 1 | 3
9 | 11 | 9 | 14 | 1 | 3
10 | 16 | 16 | -1 | 0 | 0
11 | 16 | 15 | 16 | 1 | 1
12 | 16 | 17 | 15 | 1 | 1
13 | 16 | 10 | 3 | 1 | 2
(13 rows)

/* --q10 */
SELECT * FROM pgr_drivingDistance(
'SELECT id, source, target, cost, reverse_cost FROM edges',
array[11, 16], 3.0, directed => false);
seq | from_v | node | edge | cost | agg_cost
-----+--------+------+------+------+----------
1 | 11 | 11 | -1 | 0 | 0
2 | 11 | 7 | 8 | 1 | 1
3 | 11 | 10 | 5 | 1 | 1
4 | 11 | 12 | 11 | 1 | 1
5 | 11 | 16 | 9 | 1 | 1
6 | 11 | 3 | 7 | 1 | 2
7 | 11 | 6 | 2 | 1 | 2
8 | 11 | 8 | 10 | 1 | 2
9 | 11 | 15 | 3 | 1 | 2
10 | 11 | 17 | 15 | 1 | 2
11 | 11 | 1 | 6 | 1 | 3
12 | 11 | 5 | 1 | 1 | 3
13 | 11 | 9 | 14 | 1 | 3
14 | 16 | 16 | -1 | 0 | 0
15 | 16 | 11 | 9 | 1 | 1
16 | 16 | 15 | 16 | 1 | 1
17 | 16 | 17 | 15 | 1 | 1
18 | 16 | 7 | 8 | 1 | 2
19 | 16 | 10 | 5 | 1 | 2
20 | 16 | 12 | 13 | 1 | 2
21 | 16 | 3 | 7 | 1 | 3
22 | 16 | 6 | 4 | 1 | 3
23 | 16 | 8 | 10 | 1 | 3
seq | start_vid | node | edge | cost | agg_cost
-----+-----------+------+------+------+----------
1 | 11 | 11 | -1 | 0 | 0
2 | 11 | 7 | 8 | 1 | 1
3 | 11 | 10 | 5 | 1 | 1
4 | 11 | 12 | 11 | 1 | 1
5 | 11 | 16 | 9 | 1 | 1
6 | 11 | 3 | 7 | 1 | 2
7 | 11 | 6 | 2 | 1 | 2
8 | 11 | 8 | 10 | 1 | 2
9 | 11 | 15 | 3 | 1 | 2
10 | 11 | 17 | 15 | 1 | 2
11 | 11 | 1 | 6 | 1 | 3
12 | 11 | 5 | 1 | 1 | 3
13 | 11 | 9 | 14 | 1 | 3
14 | 16 | 16 | -1 | 0 | 0
15 | 16 | 11 | 9 | 1 | 1
16 | 16 | 15 | 16 | 1 | 1
17 | 16 | 17 | 15 | 1 | 1
18 | 16 | 7 | 8 | 1 | 2
19 | 16 | 10 | 5 | 1 | 2
20 | 16 | 12 | 13 | 1 | 2
21 | 16 | 3 | 7 | 1 | 3
22 | 16 | 6 | 4 | 1 | 3
23 | 16 | 8 | 10 | 1 | 3
(23 rows)

/* --q15 */
Expand Down
2 changes: 1 addition & 1 deletion pgtap/dijkstra/driving_distance/edge_cases/issue_1152.pg
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ SELECT lives_ok($$
$$);

SELECT bag_has($$
SELECT from_v, node, edge, cost, agg_cost
SELECT start_vid, node, edge, cost, agg_cost
FROM pgr_drivingdistance(
'SELECT * FROM tmp_net',
ARRAY[
Expand Down
8 changes: 4 additions & 4 deletions pgtap/dijkstra/driving_distance/edge_cases/issue_519.pg
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost);
SELECT plan(3);

PREPARE q1 AS
SELECT 1 AS from_v, node, edge, cost, agg_cost FROM pgr_drivingDistance( 'select id, source, target, cost from edge_table',
SELECT 1 AS start_vid, node, edge, cost, agg_cost FROM pgr_drivingDistance( 'select id, source, target, cost from edge_table',
1, 3.5);

PREPARE q2 AS
SELECT 5 AS from_v, node, edge, cost, agg_cost FROM pgr_drivingDistance( 'select id, source, target, cost from edge_table',
SELECT 5 AS start_vid, node, edge, cost, agg_cost FROM pgr_drivingDistance( 'select id, source, target, cost from edge_table',
5, 3.5);

PREPARE q3 AS
SELECT 25 AS from_v, node, edge, cost, agg_cost FROM pgr_drivingDistance( 'select id, source, target, cost from edge_table',
SELECT 25 AS start_vid, node, edge, cost, agg_cost FROM pgr_drivingDistance( 'select id, source, target, cost from edge_table',
25, 3.5);

Prepare q4 AS
SELECT from_v, node, edge, cost, agg_cost FROM pgr_drivingDistance( 'select id, source, target, cost from edge_table',
SELECT start_vid, node, edge, cost, agg_cost FROM pgr_drivingDistance( 'select id, source, target, cost from edge_table',
ARRAY[1, 5, 25], 3.5);


Expand Down
6 changes: 3 additions & 3 deletions pgtap/dijkstra/driving_distance/types_check.pg
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ SELECT function_returns('pgr_drivingdistance', ARRAY['text','anyarray','double p
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[])
('{"","","","directed","seq","start_vid","node","edge","cost","agg_cost"}'::TEXT[]),
('{"","","","directed","equicost","seq","start_vid","node","edge","cost","agg_cost"}'::TEXT[])
$$);

SELECT set_eq(
$$SELECT proallargtypes from pg_proc where proname = 'pgr_drivingdistance'$$,
$$VALUES
('{25,20,701,16,23,20,20,701,701}'::OID[]),
('{25,20,701,16,23,20,20,20,701,701}'::OID[]),
('{25,2277,701,16,16,23,20,20,20,701,701}'::OID[])
$$);

Expand Down
4 changes: 2 additions & 2 deletions sql/driving_distance/_drivingDistance.sql
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-- pgr_drivingDistance
----------------------

--v3.0
--v3.6
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 start_vid BIGINT,
OUT node BIGINT,
OUT edge BIGINT,
OUT cost FLOAT,
Expand Down
9 changes: 5 additions & 4 deletions sql/driving_distance/drivingDistance.sql
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
********************************************************************PGR-GNU*/

-- MULTIPLE
--v2.6
--v3.6
CREATE FUNCTION pgr_drivingDistance(
TEXT, -- edges_sql (required)
ANYARRAY, -- from_vids (required)
Expand All @@ -33,7 +33,7 @@ CREATE FUNCTION pgr_drivingDistance(
equicost BOOLEAN DEFAULT FALSE,

OUT seq INTEGER,
OUT from_v BIGINT,
OUT start_vid BIGINT,
OUT node BIGINT,
OUT edge BIGINT,
OUT cost FLOAT,
Expand All @@ -49,7 +49,7 @@ ROWS 1000;


-- SINGLE
--v3.0
--v3.6
CREATE FUNCTION pgr_drivingDistance(
TEXT, -- edges_sql (required)
BIGINT, -- from_vid (requierd)
Expand All @@ -58,13 +58,14 @@ CREATE FUNCTION pgr_drivingDistance(
directed BOOLEAN DEFAULT TRUE,

OUT seq INTEGER,
OUT start_vid BIGINT,
OUT node BIGINT,
OUT edge BIGINT,
OUT cost FLOAT,
OUT agg_cost FLOAT)
RETURNS SETOF RECORD AS
$BODY$
SELECT seq, node, edge, cost, agg_cost
SELECT *
FROM _pgr_drivingDistance(_pgr_get_statement($1), ARRAY[$2]::BIGINT[], $3, $4, false);
$BODY$
LANGUAGE SQL VOLATILE STRICT
Expand Down