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] Modifying - withpointsdd #2544

Merged
merged 7 commits into from
Aug 20, 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
2 changes: 1 addition & 1 deletion doc/driving_distance/pgr_drivingDistance.rst
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ Driving distance optional parameters
* - ``equicost``
- ``BOOLEAN``
- ``true``
- * When ``true`` the node will only appear in the closest ``from_v``
- * When ``true`` the node will only appear in the closest ``start_vid``
list.
* When ``false`` which resembles several calls using the single starting
point signatures. Tie brakes are arbitrary.
Expand Down
75 changes: 75 additions & 0 deletions doc/src/migration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ Migrating functions:
signatures. This section will show how to migrate from the old signatures to the
new replacement functions. This also affects the restrictions.

:doc:`pgr_withPointsDD` signatures have changed, with the addition of new columns
in the new signatures. It works mainly for driving cases, therefore the ``driving side``
parameter changed from optional to compulsory, and its valid values differ for
directed and undirected graphs.

.. warning::
All deprecated functions will be removed on next mayor version 4.0.0

Expand Down Expand Up @@ -239,6 +244,76 @@ Signatures to be migrated:
the function ``my_dijkstra`` returns the new additional columns of
``pgr_dijkstra``.

Migration of ``pgr_withPointsDD``
-------------------------------------------------------------------------------

Starting from `v3.6.0 <https://docs.pgrouting.org/3.6/en/migration.html>`__

Signatures to be migrated:

* ``pgr_withPointsDD`` (`Single vertex`)
* ``pgr_withPointsDD`` (`Multiple vertices`)

:Before Migration:

.. literalinclude:: migration.queries
:start-after: --withpointsdd1
:end-before: --withpointsdd2

* ``driving_side`` parameter is optional.
* Output columns were |result-generic-no-seq|

* Depending on the overload used, the columns ``start_vid`` might be missing:

* ``pgr_withPointsDD`` (`Single vertex`) does not have ``start_vid``

:Migration:

* ``driving side`` parameter is compulsory, and valid values differ for directed
and undirected graphs.

* Does not have a default value.

* In directed graph, valid values are [``r``, ``R``, ``l``, ``L``]

* In undirected graph, valid values are [``b``, ``B``]


* Be aware of the existance of the additional columns.

* In ``pgr_withPointsDD`` (`Single vertex`)

* ``start_vid`` contains the **start vid** parameter value.
* ``depth`` contains the **depth** parameter value.

.. literalinclude:: migration.queries
:start-after: --withpointsdd2
:end-before: --withpointsdd3

* In ``pgr_withPointsDD`` (`Multiple vertices`)

* ``depth`` contains the **depth** parameter value.

.. literalinclude:: migration.queries
:start-after: --withpointsdd3
:end-before: --withpointsdd4

* If needed filter out the added columns, for example:

.. literalinclude:: migration.queries
:start-after: --withpointsdd4
:end-before: --withpointsdd5

* If needed add the new columns, similar to the following example where
``pgr_dijkstra`` is used, and the function had to be modified to be able to
return the new columns:

* In `v3.0 <https://docs.pgrouting.org/3.0/en/contraction-family.html#case-1-both-source-and-target-belong-to-the-contracted-graph>`__
the function ``my_dijkstra`` uses ``pgr_dijkstra``.
* Starting from `v3.5 <https://docs.pgrouting.org/3.5/en/contraction-family.html#case-1-both-source-and-target-belong-to-the-contracted-graph>`__
the function ``my_dijkstra`` returns the new additional columns of
``pgr_dijkstra``.

Migration of functions that change inner query columns names
*******************************************************************************

Expand Down
6 changes: 4 additions & 2 deletions doc/src/pgRouting-introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ Rajat Shinde,
Regina Obe,
Shobhit Chaurasia,
Swapnil Joshi,
Virginia Vergara
Virginia Vergara,
Yige Huang


And all the people that give us a little of their time making comments, finding
Expand Down Expand Up @@ -150,7 +151,8 @@ Sylvain Housseman,
Sylvain Pasche,
Veenit Kumar,
Vidhan Jain,
Virginia Vergara
Virginia Vergara,
Yige Huang

Corporate Sponsors (in alphabetical order)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
83 changes: 83 additions & 0 deletions docqueries/src/migration.result
Original file line number Diff line number Diff line change
Expand Up @@ -785,5 +785,88 @@ SELECT seq, path_seq, node, edge, cost, agg_cost FROM pgr_bdAstar(
(6 rows)

/* --bdastar5 */
/* --withpointsdd1 */
SELECT * FROM pgr_withPointsDD(
$$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$,
$$SELECT pid, edge_id, fraction, side from pointsOfInterest$$,
-5, 2.3,
driving_side => 'r');
WARNING: pgr_withpointsdd(text,text,bigint,double precision,boolean,character,boolean) is been deprecated
seq | node | edge | cost | agg_cost
-----+------+------+------+----------
1 | -5 | -1 | 0 | 0
2 | 11 | 5 | 0.2 | 0.2
3 | 7 | 8 | 1 | 1.2
4 | 12 | 11 | 1 | 1.2
5 | 16 | 9 | 1 | 1.2
6 | 3 | 7 | 1 | 2.2
7 | 6 | 4 | 1 | 2.2
8 | 8 | 10 | 1 | 2.2
9 | 15 | 16 | 1 | 2.2
10 | 17 | 13 | 1 | 2.2
(10 rows)

/* --withpointsdd2 */
SELECT * FROM pgr_withPointsDD(
$$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$,
$$SELECT pid, edge_id, fraction, side from pointsOfInterest$$,
-5, 2.3, 'r');
seq | depth | start_vid | node | edge | cost | agg_cost
-----+-------+-----------+------+------+------+----------
1 | 0 | -5 | -5 | -1 | 0 | 0
2 | 1 | -5 | 11 | 5 | 0.2 | 0.2
3 | 2 | -5 | 7 | 8 | 1 | 1.2
4 | 2 | -5 | 12 | 11 | 1 | 1.2
5 | 2 | -5 | 16 | 9 | 1 | 1.2
6 | 3 | -5 | 3 | 7 | 1 | 2.2
7 | 3 | -5 | 6 | 4 | 1 | 2.2
8 | 3 | -5 | 8 | 10 | 1 | 2.2
9 | 3 | -5 | 15 | 16 | 1 | 2.2
10 | 3 | -5 | 17 | 13 | 1 | 2.2
(10 rows)

/* --withpointsdd3 */
SELECT * FROM pgr_withPointsDD(
$$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$,
$$SELECT pid, edge_id, fraction, side from pointsOfInterest$$,
ARRAY[-3, 16], 3.3, 'r');
seq | depth | start_vid | node | edge | cost | agg_cost
-----+-------+-----------+------+------+------+----------
1 | 0 | -3 | -3 | -1 | 0 | 0
2 | 1 | -3 | 12 | 12 | 0.4 | 0.4
3 | 2 | -3 | 17 | 13 | 1 | 1.4
4 | 3 | -3 | 16 | 15 | 1 | 2.4
5 | 0 | 16 | 16 | -1 | 0 | 0
6 | 1 | 16 | 11 | 9 | 1 | 1
7 | 1 | 16 | 15 | 16 | 1 | 1
8 | 1 | 16 | 17 | 15 | 1 | 1
9 | 2 | 16 | 7 | 8 | 1 | 2
10 | 2 | 16 | 10 | 3 | 1 | 2
11 | 2 | 16 | 12 | 11 | 1 | 2
12 | 3 | 16 | 3 | 7 | 1 | 3
13 | 3 | 16 | 6 | 2 | 1 | 3
14 | 3 | 16 | 8 | 10 | 1 | 3
(14 rows)

/* --withpointsdd4 */
SELECT seq, node, edge, cost, agg_cost FROM pgr_withPointsDD(
$$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$,
$$SELECT pid, edge_id, fraction, side from pointsOfInterest$$,
-5, 2.3, 'r');
seq | node | edge | cost | agg_cost
-----+------+------+------+----------
1 | -5 | -1 | 0 | 0
2 | 11 | 5 | 0.2 | 0.2
3 | 7 | 8 | 1 | 1.2
4 | 12 | 11 | 1 | 1.2
5 | 16 | 9 | 1 | 1.2
6 | 3 | 7 | 1 | 2.2
7 | 6 | 4 | 1 | 2.2
8 | 8 | 10 | 1 | 2.2
9 | 15 | 16 | 1 | 2.2
10 | 17 | 13 | 1 | 2.2
(10 rows)

/* --withpointsdd5 */
ROLLBACK;
ROLLBACK
22 changes: 22 additions & 0 deletions docqueries/src/migration.test.sql
Original file line number Diff line number Diff line change
Expand Up @@ -261,3 +261,25 @@ SELECT seq, path_seq, node, edge, cost, agg_cost FROM pgr_bdAstar(
$$SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edges$$,
6, 10);
/* --bdastar5 */
/* --withpointsdd1 */
SELECT * FROM pgr_withPointsDD(
$$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$,
$$SELECT pid, edge_id, fraction, side from pointsOfInterest$$,
-5, 2.3,
driving_side => 'r');
/* --withpointsdd2 */
SELECT * FROM pgr_withPointsDD(
$$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$,
$$SELECT pid, edge_id, fraction, side from pointsOfInterest$$,
-5, 2.3, 'r');
/* --withpointsdd3 */
SELECT * FROM pgr_withPointsDD(
$$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$,
$$SELECT pid, edge_id, fraction, side from pointsOfInterest$$,
ARRAY[-3, 16], 3.3, 'r');
/* --withpointsdd4 */
SELECT seq, node, edge, cost, agg_cost FROM pgr_withPointsDD(
$$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$,
$$SELECT pid, edge_id, fraction, side from pointsOfInterest$$,
-5, 2.3, 'r');
/* --withpointsdd5 */
130 changes: 65 additions & 65 deletions docqueries/withPoints/doc-pgr_withPointsDD.result
Original file line number Diff line number Diff line change
Expand Up @@ -8,61 +8,62 @@ SET
SELECT * FROM pgr_withPointsDD(
'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id',
'SELECT pid, edge_id, fraction, side from pointsOfInterest',
-1, 3.3,
driving_side => 'r',
-1, 3.3, 'r',
details => true);
seq | node | edge | cost | agg_cost
-----+------+------+------+----------
1 | -1 | -1 | 0 | 0
2 | 5 | 1 | 0.4 | 0.4
3 | 6 | 1 | 1 | 1.4
4 | -6 | 4 | 0.7 | 2.1
5 | 7 | 4 | 0.3 | 2.4
seq | depth | start_vid | node | edge | cost | agg_cost
-----+-------+-----------+------+------+------+----------
1 | 0 | -1 | -1 | -1 | 0 | 0
2 | 1 | -1 | 5 | 1 | 0.4 | 0.4
3 | 2 | -1 | 6 | 1 | 1 | 1.4
4 | 3 | -1 | -6 | 4 | 0.7 | 2.1
5 | 4 | -1 | 7 | 4 | 0.3 | 2.4
(5 rows)

/* -- q3 */
SELECT * FROM pgr_withPointsDD(
'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id',
'SELECT pid, edge_id, fraction, side from pointsOfInterest',
ARRAY[-1, 16], 3.3,
driving_side => 'l',
ARRAY[-1, 16], 3.3, 'l',
equicost => true);
seq | start_vid | node | edge | cost | agg_cost
-----+-----------+------+------+------+----------
1 | -1 | -1 | -1 | 0 | 0
2 | -1 | 6 | 1 | 0.6 | 0.6
3 | -1 | 7 | 4 | 1 | 1.6
4 | -1 | 5 | 1 | 1 | 1.6
5 | -1 | 3 | 7 | 1 | 2.6
6 | -1 | 8 | 10 | 1 | 2.6
7 | 16 | 16 | -1 | 0 | 0
8 | 16 | 11 | 9 | 1 | 1
9 | 16 | 15 | 16 | 1 | 1
10 | 16 | 17 | 15 | 1 | 1
11 | 16 | 10 | 3 | 1 | 2
12 | 16 | 12 | 11 | 1 | 2
seq | depth | start_vid | node | edge | cost | agg_cost
-----+-------+-----------+------+------+------+----------
1 | 0 | -1 | -1 | -1 | 0 | 0
2 | 1 | -1 | 6 | 1 | 0.6 | 0.6
3 | 2 | -1 | 7 | 4 | 1 | 1.6
4 | 2 | -1 | 5 | 1 | 1 | 1.6
5 | 3 | -1 | 3 | 7 | 1 | 2.6
6 | 3 | -1 | 8 | 10 | 1 | 2.6
7 | 0 | 16 | 16 | -1 | 0 | 0
8 | 1 | 16 | 11 | 9 | 1 | 1
9 | 1 | 16 | 15 | 16 | 1 | 1
10 | 1 | 16 | 17 | 15 | 1 | 1
11 | 2 | 16 | 10 | 3 | 1 | 2
12 | 2 | 16 | 12 | 11 | 1 | 2
(12 rows)

/* -- q4 */
SELECT * FROM pgr_withPointsDD(
'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id',
'SELECT pid, edge_id, fraction, side from pointsOfInterest',
-1, 3.3,
driving_side => 'b',
-1, 3.3, 'b',
directed => false,
details => true);
seq | node | edge | cost | agg_cost
-----+------+------+------+----------
1 | -1 | -1 | 0 | 0
2 | 5 | 1 | 0.4 | 0.4
3 | 6 | 1 | 0.6 | 0.6
4 | -6 | 4 | 0.7 | 1.3
5 | 7 | 4 | 0.3 | 1.6
6 | 3 | 7 | 1 | 2.6
7 | 8 | 10 | 1 | 2.6
8 | 11 | 8 | 1 | 2.6
9 | -3 | 12 | 0.6 | 3.2
10 | -4 | 6 | 0.7 | 3.3
(10 rows)
seq | depth | start_vid | node | edge | cost | agg_cost
-----+-------+-----------+------+------+------+----------
1 | 0 | -1 | -1 | -1 | 0 | 0
2 | 1 | -1 | 5 | 1 | 0.4 | 0.4
3 | 1 | -1 | 6 | 1 | 0.6 | 0.6
4 | 2 | -1 | -6 | 4 | 0.7 | 1.3
5 | 3 | -1 | 7 | 4 | 0.3 | 1.6
6 | 2 | -1 | 10 | 2 | 1 | 1.6
7 | 3 | -1 | -5 | 5 | 0.8 | 2.4
8 | 4 | -1 | 3 | 7 | 1 | 2.6
9 | 4 | -1 | 8 | 10 | 1 | 2.6
10 | 4 | -1 | 11 | 8 | 1 | 2.6
11 | 3 | -1 | 15 | 3 | 1 | 2.6
12 | 5 | -1 | -3 | 12 | 0.6 | 3.2
13 | 5 | -1 | -4 | 6 | 0.7 | 3.3
(13 rows)

/* -- q5 */
SELECT * FROM pgr_withPointsDD(
Expand All @@ -73,32 +74,31 @@ SELECT * FROM pgr_withPointsDD(
(SELECT ST_POINT(2.9, 1.8)),
0.5, cap => 2)
$p$,
ARRAY[-1, -2], 2.3,
driving_side => 'r',
ARRAY[-1, -2], 2.3, 'r',
details => true);
seq | start_vid | node | edge | cost | agg_cost
-----+-----------+------+------+------+----------
1 | -1 | -1 | -1 | 0 | 0
2 | -1 | 11 | 5 | 0.2 | 0.2
3 | -1 | 7 | 8 | 1 | 1.2
4 | -1 | 12 | 11 | 1 | 1.2
5 | -1 | 16 | 9 | 1 | 1.2
6 | -1 | -2 | 8 | 0.9 | 2.1
7 | -1 | 3 | 7 | 1 | 2.2
8 | -1 | 6 | 4 | 1 | 2.2
9 | -1 | 8 | 10 | 1 | 2.2
10 | -1 | 15 | 16 | 1 | 2.2
11 | -1 | 17 | 13 | 1 | 2.2
12 | -2 | -2 | -1 | 0 | 0
13 | -2 | 11 | 8 | 0.1 | 0.1
14 | -2 | 7 | 8 | 1 | 1.1
15 | -2 | 12 | 11 | 1 | 1.1
16 | -2 | 16 | 9 | 1 | 1.1
17 | -2 | 3 | 7 | 1 | 2.1
18 | -2 | 6 | 4 | 1 | 2.1
19 | -2 | 8 | 10 | 1 | 2.1
20 | -2 | 15 | 16 | 1 | 2.1
21 | -2 | 17 | 13 | 1 | 2.1
seq | depth | start_vid | node | edge | cost | agg_cost
-----+-------+-----------+------+------+------+----------
1 | 0 | -1 | -1 | -1 | 0 | 0
2 | 1 | -1 | 11 | 5 | 0.2 | 0.2
3 | 2 | -1 | 7 | 8 | 1 | 1.2
4 | 2 | -1 | 12 | 11 | 1 | 1.2
5 | 2 | -1 | 16 | 9 | 1 | 1.2
6 | 3 | -1 | -2 | 8 | 0.9 | 2.1
7 | 3 | -1 | 3 | 7 | 1 | 2.2
8 | 3 | -1 | 6 | 4 | 1 | 2.2
9 | 3 | -1 | 8 | 10 | 1 | 2.2
10 | 3 | -1 | 15 | 16 | 1 | 2.2
11 | 3 | -1 | 17 | 13 | 1 | 2.2
12 | 0 | -2 | -2 | -1 | 0 | 0
13 | 1 | -2 | 11 | 8 | 0.1 | 0.1
14 | 2 | -2 | 7 | 8 | 1 | 1.1
15 | 2 | -2 | 12 | 11 | 1 | 1.1
16 | 2 | -2 | 16 | 9 | 1 | 1.1
17 | 3 | -2 | 3 | 7 | 1 | 2.1
18 | 3 | -2 | 6 | 4 | 1 | 2.1
19 | 3 | -2 | 8 | 10 | 1 | 2.1
20 | 3 | -2 | 15 | 16 | 1 | 2.1
21 | 3 | -2 | 17 | 13 | 1 | 2.1
(21 rows)

/* -- q6 */
Expand Down
Loading