-
-
Notifications
You must be signed in to change notification settings - Fork 42
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: Yige Huang Week 2 #299
Changes from all commits
3cbc379
c7e56ae
ef24f0f
8756440
7d3af8a
a7f46ef
dd845f7
184c357
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,53 +20,17 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
|
||
BEGIN; | ||
|
||
SELECT PLAN(6); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please do not change pgtap tests at this time, put it back as it was ... |
||
SELECT PLAN(4); | ||
|
||
|
||
--- | ||
--- DIRECTED GRAPH | ||
--- | ||
-------- both driving sides | ||
|
||
PREPARE q1 AS | ||
SELECT node, edge, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM pgr_withPointsDD( | ||
'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', | ||
'SELECT pid, edge_id, fraction, side from pointsOfInterest', | ||
-1, 6.8, driving_side := 'b', details := false) | ||
ORDER BY seq; | ||
|
||
|
||
SELECT | ||
node::BIGINT, edge::BIGINT, round(cost, 12) AS cost, round(agg_cost, 12) AS agg_cost | ||
INTO test1 | ||
FROM | ||
(VALUES | ||
( -1 , -1 , 0 , 0), | ||
( 1 , 1 , 0.4 , 0.4), | ||
( 2 , 1 , 0.6 , 0.6), | ||
( 5 , 4 , 1 , 1.6), | ||
( 6 , 8 , 1 , 2.6), | ||
( 8 , 7 , 1 , 2.6), | ||
( 10 , 10 , 1 , 2.6), | ||
( 7 , 6 , 1 , 3.6), | ||
( 9 , 9 , 1 , 3.6), | ||
( 11 , 11 , 1 , 3.6), | ||
( 13 , 14 , 1 , 3.6), | ||
( 4 , 16 , 1 , 4.6), | ||
( 12 , 13 , 1 , 4.6), | ||
( 3 , 3 , 1 , 5.6) | ||
) AS t (node, edge, cost, agg_cost); | ||
|
||
|
||
SELECT set_eq('q1', | ||
$$SELECT node, edge, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM test1$$, | ||
'Should be aggregating individual costs: both driving sides, DIR'); | ||
|
||
|
||
|
||
-------- right driving side | ||
|
||
PREPARE q2 AS | ||
PREPARE q1 AS | ||
SELECT node, edge, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM pgr_withPointsDD( | ||
'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', | ||
'SELECT pid, edge_id, fraction, side from pointsOfInterest', | ||
|
@@ -75,7 +39,7 @@ SELECT node, edge, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12 | |
|
||
SELECT | ||
node::BIGINT, edge::BIGINT, cost::FLOAT, agg_cost::FLOAT | ||
INTO test2 | ||
INTO test1 | ||
FROM | ||
(VALUES | ||
( -1 , -1 , 0 , 0), | ||
|
@@ -95,13 +59,13 @@ FROM | |
) AS t (node, edge, cost, agg_cost); | ||
|
||
|
||
SELECT set_eq('q2', | ||
$$SELECT node, edge, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM test2$$, | ||
SELECT set_eq('q1', | ||
$$SELECT node, edge, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM test1$$, | ||
'Should be aggregating individual costs: right driving side, DIR'); | ||
|
||
-------- left driving side | ||
|
||
PREPARE q3 AS | ||
PREPARE q2 AS | ||
SELECT node, edge, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM pgr_withPointsDD( | ||
'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', | ||
'SELECT pid, edge_id, fraction, side from pointsOfInterest', | ||
|
@@ -111,7 +75,7 @@ ORDER BY seq; | |
|
||
SELECT | ||
node::BIGINT, edge::BIGINT, cost::FLOAT, agg_cost::FLOAT | ||
INTO test3 | ||
INTO test2 | ||
FROM | ||
(VALUES | ||
(-1 , -1 , 0 , 0), | ||
|
@@ -131,8 +95,8 @@ FROM | |
) AS t (node, edge, cost, agg_cost); | ||
|
||
|
||
SELECT set_eq('q3', | ||
$$SELECT node, edge, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM test3$$, | ||
SELECT set_eq('q2', | ||
$$SELECT node, edge, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM test2$$, | ||
'Should be aggregating individual costs: left driving side, DIR'); | ||
|
||
--- | ||
|
@@ -142,7 +106,7 @@ SELECT set_eq('q3', | |
-- all results on udirected graph are "allegedly" equal | ||
SELECT | ||
node::BIGINT, cost::FLOAT, agg_cost::FLOAT | ||
INTO test4 | ||
INTO test3 | ||
FROM | ||
(VALUES | ||
( -1 , 0 , 0), | ||
|
@@ -161,44 +125,31 @@ FROM | |
( 12 , 1 , 4.6) | ||
) AS t (node, cost, agg_cost); | ||
|
||
-------- both driving sides | ||
|
||
PREPARE q4 AS | ||
SELECT node, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM pgr_withPointsDD( | ||
'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', | ||
'SELECT pid, edge_id, fraction, side from pointsOfInterest', | ||
-1, 6.8, driving_side := 'b', details := false, directed:=false); | ||
|
||
SELECT set_eq('q4', | ||
$$SELECT node, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM test4$$, | ||
'Should be aggregating individual costs: both driving sides, UNDI'); | ||
|
||
|
||
|
||
-------- right driving side | ||
|
||
PREPARE q5 AS | ||
PREPARE q4 AS | ||
SELECT node, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM pgr_withPointsDD( | ||
'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', | ||
'SELECT pid, edge_id, fraction, side from pointsOfInterest', | ||
-1, 6.8, driving_side := 'r', details := false, directed:=false); | ||
|
||
|
||
SELECT set_eq('q5', | ||
$$SELECT node, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM test4$$, | ||
SELECT set_eq('q4', | ||
$$SELECT node, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM test3$$, | ||
'Should be aggregating individual costs: right driving side, UNDI'); | ||
|
||
-------- left driving side | ||
|
||
PREPARE q6 AS | ||
PREPARE q5 AS | ||
SELECT node, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM pgr_withPointsDD( | ||
'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', | ||
'SELECT pid, edge_id, fraction, side from pointsOfInterest', | ||
-1, 6.8, driving_side := 'l', details := false, directed:=false); | ||
|
||
|
||
SELECT set_eq('q6', | ||
$$SELECT node, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM test4$$, | ||
SELECT set_eq('q5', | ||
$$SELECT node, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM test3$$, | ||
'Should be aggregating individual costs: left driving side, UNDI'); | ||
|
||
SELECT * FROM finish(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,7 @@ CREATE FUNCTION _pgr_withPointsDD( | |
distance FLOAT, | ||
|
||
directed BOOLEAN DEFAULT true, | ||
driving_side CHAR DEFAULT 'b', | ||
driving_side CHAR DEFAULT 'r', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I still like the default value to be |
||
details BOOLEAN DEFAULT false, | ||
equicost BOOLEAN DEFAULT false, | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,41 +23,42 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
********************************************************************PGR-GNU*/ | ||
|
||
-- SINGLE | ||
--v2.6 | ||
--v3.6 | ||
CREATE FUNCTION pgr_withPointsDD( | ||
TEXT, --edges_sql (required) | ||
TEXT, -- points_sql (required) | ||
BIGINT, -- from_vid (required) | ||
FLOAT, -- distance (required) | ||
|
||
directed BOOLEAN DEFAULT true, | ||
driving_side CHAR DEFAULT 'b', | ||
driving_side CHAR DEFAULT 'r', | ||
details BOOLEAN DEFAULT false, | ||
|
||
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 seq, start_vid, node, edge, cost, agg_cost | ||
FROM _pgr_withPointsDD(_pgr_get_statement($1), _pgr_get_statement($2), ARRAY[$3]::BIGINT[], $4, $5, $6, $7, false); | ||
$BODY$ | ||
LANGUAGE SQL VOLATILE STRICT | ||
COST 100 | ||
ROWS 1000; | ||
|
||
-- MULTIPLE | ||
--v2.6 | ||
--v3.6 | ||
CREATE FUNCTION pgr_withPointsDD( | ||
TEXT, --edges_sql (required) | ||
TEXT, -- points_sql (required) | ||
ANYARRAY, -- from_vid (required) | ||
FLOAT, -- distance (required) | ||
|
||
directed BOOLEAN DEFAULT true, | ||
driving_side CHAR DEFAULT 'b', | ||
driving_side CHAR DEFAULT 'r', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a tricky change, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue for reminder: squarege#5 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See #300 |
||
details BOOLEAN DEFAULT false, | ||
equicost BOOLEAN DEFAULT false, | ||
|
||
|
@@ -89,7 +90,7 @@ IS 'pgr_withPointsDD(Single Vertex) | |
- Distance | ||
- Optional Parameters | ||
- directed := true | ||
- driving_side := b | ||
- driving_side := r | ||
- details := false | ||
- Documentation: | ||
- ${PROJECT_DOC_LINK}/pgr_withPointsDD.html | ||
|
@@ -106,7 +107,7 @@ IS 'pgr_withPointsDD(Multiple Vertices) | |
- Distance | ||
- Optional Parameters | ||
- directed := true | ||
- driving_side := b | ||
- driving_side := r | ||
- details := false | ||
- equicost := false | ||
- Documentation: | ||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -54,6 +54,9 @@ void process( | |||||||||
Path_rt **result_tuples, | ||||||||||
size_t *result_count) { | ||||||||||
driving_side[0] = estimate_drivingSide(driving_side[0]); | ||||||||||
if (driving_side[0] != 'r' && driving_side[0] != 'l') { | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably not the best place to check, did you analyze what There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I did. GSoC-pgRouting/src/trsp/trsp_withPoints.c Lines 68 to 71 in 81bcd0c
But if the default for versions 3.6 and after is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See #300 |
||||||||||
driving_side[0] = 'r'; | ||||||||||
} | ||||||||||
PGR_DBG("estimated driving side:%c", driving_side[0]); | ||||||||||
|
||||||||||
pgr_SPI_connect(); | ||||||||||
|
@@ -167,7 +170,7 @@ _pgr_withpointsdd(PG_FUNCTION_ARGS) { | |||||||||
// distance FLOAT, | ||||||||||
// | ||||||||||
// directed BOOLEAN -- DEFAULT true, | ||||||||||
// driving_side CHAR -- DEFAULT 'b', | ||||||||||
// driving_side CHAR -- DEFAULT 'r', | ||||||||||
// details BOOLEAN -- DEFAULT false, | ||||||||||
// equicost BOOLEAN -- DEFAULT false, | ||||||||||
|
||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not delete the query its been used in the documentation.
Put it back.