Skip to content

Commit

Permalink
Merge pull request #2686 from cvvergara/issue-2681-Remove-deprecated-…
Browse files Browse the repository at this point in the history
…pgr_trspViaEdges

Remove deprecated pgr_trspViaEdges
  • Loading branch information
cvvergara authored Dec 11, 2024
2 parents b9e41cc + 92647d5 commit 858b385
Show file tree
Hide file tree
Showing 19 changed files with 154 additions and 1,075 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ include(pgr/BuildType)

project(PGROUTING VERSION 4.0.0
LANGUAGES C CXX )
set(PROJECT_VERSION_DEV "")
set(PROJECT_VERSION_DEV "-dev")
string(TOLOWER "${PROJECT_NAME}" PROJECT_NAME_LOWER)

include(pgr/GitInfo)
Expand Down
5 changes: 4 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@

### pgRouting 4.0.0 Release Notes

No Changes Yet
**Removal of deprecated functions and signatures**

* ``pgr_trspviaedges(text,integer[],double precision[],boolean,boolean,text)``



# pgRouting 3
Expand Down
2 changes: 1 addition & 1 deletion doc/src/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Available Functions but not official pgRouting functions

.. include:: release_notes.rst
:start-after: current
:end-before: pgRouting 3.6
:end-before: pgRouting 3

All releases
-------------------------------------------------------------------------------
Expand Down
124 changes: 19 additions & 105 deletions doc/src/migration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1291,145 +1291,59 @@ function been migrated then:
* ``id2`` is the node
* ``id3`` is the edge

Migration of ``pgr_trspViaEdges``
Migration of pgr_trspViaEdges
-------------------------------------------------------------------------------

Signature to be migrated:

.. parsed-literal::
pgr_trspViaEdges(sql text, eids integer[], pcts float8[],
directed boolean, has_rcost boolean
[, turn_restrict_sql text]);
RETURNS SETOF (seq, id1, id2, id3, cost)
* The integral types of the ``Edges SQL`` can only be ``INTEGER``.
* The floating point type of the ``Edges SQL`` can only be ``FLOAT``.
* ``directed`` flag is compulsory.

* Does not have a default value.

* Does not autodetect if ``reverse_cost`` column exist.

* User must be careful to match the existence of the column with the value of
``has_rcost`` parameter.

* The restrictions inner query is optional.

For these migration guide the following points will be used:

.. literalinclude:: migration.queries
:start-after: --viav7
:end-before: --edgesvia1

And will travel thru the following Via points :math:`4\rightarrow3\rightarrow6`

Migrate by using:

* :doc:`pgr_withPointsVia` when there are no restrictions,
* :doc:`pgr_trspVia_withPoints` when there are restrictions.
.. contents::
:local:
:depth: 1

Migrating ``pgr_trspViaEdges`` using ``pgr_withPointsVia``
...............................................................................

The following query does not have restrictions.
In this section this set of points is going to be used:

.. literalinclude:: migration.queries
:start-after: --edgesvia1
:end-before: --edgesvia2

* A message about deprecation is shown

* Deprecated functions will be removed on the next mayor version 4.0.0
Migrating pgr_trspViaEdges using pgr_withPointsVia
...............................................................................

Use :doc:`pgr_withPointsVia` instead.
Using :doc:`pgr_withPointsVia`.

.. literalinclude:: migration.queries
:start-after: --edgesvia2
:end-before: --edgesvia3

* The types casting has been removed.
* Do not show details, as the deprecated function does not show details.
* :doc:`pgr_withPointsVia`:

* Autodetects if ``reverse_cost`` column is in the edges
SQL.
* Accepts ``ANY-INTEGER`` on integral types
* Accepts ``ANY-NUMERICAL`` on floating point types
* ``directed`` flag has a default value of ``true``.

* Use the same value that on the original query.
* In this example it is ``true`` which is the default value.

* The flag has been omitted and the default is been used.
* On the points query do not include the ``side`` column.

When the need of using strictly the same (meaningless) names and types, and node
values of the function been migrated then:

.. literalinclude:: migration.queries
:start-after: --edgesvia3
:end-before: --edgesvia4
When the need of using the same (meaningless) names and and strict types then
convert the result to the deprecated function columns:

* ``id1`` is the path identifier
* ``id2`` is the node
* ``id3`` is the edge

Migrating ``pgr_trspViaEdges`` using ``pgr_trspVia_withPoints``
...............................................................................

The following query has restrictions.

.. literalinclude:: migration.queries
:start-after: --edgesvia4
:end-before: --edgesvia5

* A message about deprecation is shown

* Deprecated functions will be removed on the next mayor version 4.0.0

* The restrictions are the last parameter of the function
:start-after: --edgesvia3
:end-before: --edgesvia4

* Using the old structure of restrictions
Migrating pgr_trspViaEdges using pgr_trspVia_withPoints
...............................................................................

Use :doc:`pgr_trspVia_withPoints` instead.

.. literalinclude:: migration.queries
:start-after: --edgesvia5
:end-before: --edgesvia6

* The new structure of restrictions is been used.

* It is the second parameter.
When the need of using the same (meaningless) names and and strict types then
convert the result to the deprecated function columns:

* The types casting has been removed.
* Do not show details, as the deprecated function does not show details.
* :doc:`pgr_trspVia_withPoints`:

* Autodetects if ``reverse_cost`` column is in the edges
SQL.
* Accepts ``ANY-INTEGER`` on integral types
* Accepts ``ANY-NUMERICAL`` on floating point types
* ``directed`` flag has a default value of ``true``.

* Use the same value that on the original query.
* In this example it is ``true`` which is the default value.

* The flag has been omitted and the default is been used.
* On the points query do not include the ``side`` column.

When the need of using strictly the same (meaningless) names and types, and node
values of the function been migrated then:
* ``id1`` is the path identifier
* ``id2`` is the node
* ``id3`` is the edge

.. literalinclude:: migration.queries
:start-after: --edgesvia6
:end-before: --edgesvia7

* ``id1`` is the path identifier
* ``id2`` is the node
* ``id3`` is the edge


See Also
-------------------------------------------------------------------------------
Expand Down
5 changes: 4 additions & 1 deletion doc/src/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ pgRouting 4.0
pgRouting 4.0.0 Release Notes
-------------------------------------------------------------------------------

No Changes Yet
.. rubric:: Removal of deprecated functions and signatures

* ``pgr_trspviaedges(text,integer[],double precision[],boolean,boolean,text)``



pgRouting 3
Expand Down
16 changes: 4 additions & 12 deletions docqueries/src/migration.pg
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,7 @@ WHERE edge != -1;
SELECT pid, edge_id, fraction, side FROM pointsOfInterest
WHERE pid IN (3, 4, 6);
/* --edgesvia1 */
SELECT * FROM pgr_trspViaEdges(
$$SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost, reverse_cost FROM edges$$,
ARRAY[6, 12, 4], ARRAY[0.3, 0.6, 0.7],
true, true);
SELECT pid, edge_id, fraction FROM pointsOfInterest WHERE pid IN (3, 4, 6);
/* --edgesvia2 */
SELECT * FROM pgr_withPointsVia(
$$SELECT id, source, target, cost, reverse_cost FROM edges$$,
Expand All @@ -172,15 +169,10 @@ path_id::INTEGER AS id1, node::INTEGER AS id2,
CASE WHEN edge >= 0 THEN edge::INTEGER ELSE -1 END AS id3, cost::FLOAT
FROM pgr_withPointsVia(
$$SELECT id, source, target, cost, reverse_cost FROM edges$$,
$$SELECT * FROM (VALUES (1, 6, 0.3),(2, 12, 0.6),(3, 4, 0.7)) AS t(pid, edge_id, fraction)$$,
ARRAY[-1, -2, -3],
details=> false);
$$SELECT pid, edge_id, fraction FROM pointsOfInterest WHERE pid IN (3, 4, 6)$$,
ARRAY[-4, -3, -6],
details => false);
/* --edgesvia4 */
SELECT * FROM pgr_trspViaEdges(
$$SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost, reverse_cost FROM edges$$,
ARRAY[6, 12, 4], ARRAY[0.3, 0.6, 0.7],
true, true,
$$SELECT to_cost, target_id::INTEGER, via_path FROM old_restrictions$$);
/* --edgesvia5 */
SELECT * FROM pgr_trspVia_withPoints(
$$SELECT id, source, target, cost, reverse_cost FROM edges$$,
Expand Down
68 changes: 14 additions & 54 deletions docqueries/src/migration.result
Original file line number Diff line number Diff line change
Expand Up @@ -404,26 +404,13 @@ WHERE pid IN (3, 4, 6);
(3 rows)

/* --edgesvia1 */
SELECT * FROM pgr_trspViaEdges(
$$SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost, reverse_cost FROM edges$$,
ARRAY[6, 12, 4], ARRAY[0.3, 0.6, 0.7],
true, true);
WARNING: pgr_trspViaEdges(text,integer[],float[],boolean,boolean,text) deprecated function on v3.4.0
seq | id1 | id2 | id3 | cost
-----+-----+-----+-----+------
1 | 1 | -1 | 6 | 0.7
2 | 1 | 3 | 7 | 1
3 | 1 | 7 | 10 | 1
4 | 1 | 8 | 12 | 0.6
5 | 1 | -2 | -1 | 0
6 | 2 | -2 | 12 | 0.4
7 | 2 | 12 | 13 | 1
8 | 2 | 17 | 15 | 1
9 | 2 | 16 | 9 | 1
10 | 2 | 11 | 8 | 1
11 | 2 | 7 | 4 | 0.7
12 | 2 | -3 | -2 | 0
(12 rows)
SELECT pid, edge_id, fraction FROM pointsOfInterest WHERE pid IN (3, 4, 6);
pid | edge_id | fraction
-----+---------+----------
3 | 12 | 0.6
4 | 6 | 0.3
6 | 4 | 0.7
(3 rows)

/* --edgesvia2 */
SELECT * FROM pgr_withPointsVia(
Expand Down Expand Up @@ -453,53 +440,26 @@ path_id::INTEGER AS id1, node::INTEGER AS id2,
CASE WHEN edge >= 0 THEN edge::INTEGER ELSE -1 END AS id3, cost::FLOAT
FROM pgr_withPointsVia(
$$SELECT id, source, target, cost, reverse_cost FROM edges$$,
$$SELECT * FROM (VALUES (1, 6, 0.3),(2, 12, 0.6),(3, 4, 0.7)) AS t(pid, edge_id, fraction)$$,
ARRAY[-1, -2, -3],
details=> false);
$$SELECT pid, edge_id, fraction FROM pointsOfInterest WHERE pid IN (3, 4, 6)$$,
ARRAY[-4, -3, -6],
details => false);
seq | id1 | id2 | id3 | cost
-----+-----+-----+-----+------
1 | 1 | -1 | 6 | 0.7
1 | 1 | -4 | 6 | 0.7
2 | 1 | 3 | 7 | 1
3 | 1 | 7 | 10 | 1
4 | 1 | 8 | 12 | 0.6
5 | 1 | -2 | -1 | 0
6 | 2 | -2 | 12 | 0.4
5 | 1 | -3 | -1 | 0
6 | 2 | -3 | 12 | 0.4
7 | 2 | 12 | 13 | 1
8 | 2 | 17 | 15 | 1
9 | 2 | 16 | 9 | 1
10 | 2 | 11 | 8 | 1
11 | 2 | 7 | 4 | 0.3
12 | 2 | -3 | -1 | 0
12 | 2 | -6 | -1 | 0
(12 rows)

/* --edgesvia4 */
SELECT * FROM pgr_trspViaEdges(
$$SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost, reverse_cost FROM edges$$,
ARRAY[6, 12, 4], ARRAY[0.3, 0.6, 0.7],
true, true,
$$SELECT to_cost, target_id::INTEGER, via_path FROM old_restrictions$$);
WARNING: pgr_trspViaEdges(text,integer[],float[],boolean,boolean,text) deprecated function on v3.4.0
WARNING: pgr_trsp(text,integer,float,integer,float,boolean,boolean) deprecated signature on v3.4.0
WARNING: pgr_trsp(text,integer,float,integer,float,boolean,boolean) deprecated signature on v3.4.0
seq | id1 | id2 | id3 | cost
-----+-----+-----+-----+------
1 | 1 | -1 | 6 | 0.7
2 | 1 | 3 | 7 | 1
3 | 1 | 7 | 8 | 1
4 | 1 | 11 | 9 | 1
5 | 1 | 16 | 16 | 1
6 | 1 | 15 | 3 | 1
7 | 1 | 10 | 2 | 1
8 | 1 | 6 | 4 | 1
9 | 1 | 7 | 10 | 1
10 | 1 | 8 | 12 | 1
11 | 2 | 12 | 13 | 1
12 | 2 | 17 | 15 | 1
13 | 2 | 16 | 9 | 1
14 | 2 | 11 | 8 | 1
15 | 2 | 7 | 4 | 0.3
(15 rows)

/* --edgesvia5 */
SELECT * FROM pgr_trspVia_withPoints(
$$SELECT id, source, target, cost, reverse_cost FROM edges$$,
Expand Down
Loading

0 comments on commit 858b385

Please sign in to comment.