Guía de migración

Varias funciones están teniendo cambios en las firmas, y/o han sido remplazadas por nuevas funciones.

Resultados pueden ser diferentes dado los cambios.

Advertencia

Todas las funciones obsoletas serán removidas en las siguiente versión mayor 4.0.0

Migration of functions

Migration of pgr_aStar

Starting from v3.6.0

Firmas que serán migradas:

  • pgr_aStar (One to One)

  • pgr_aStar (One to Many)

  • pgr_aStar (Many to One)

Antes de la migración:

  • Output columns were (seq, path_seq, [start_vid], [end_vid], node, edge, cost, agg_cost)

    • Depending on the overload used, the columns start_vid and end_vid might be missing:

      • pgr_aStar (One to One) does not have start_vid and end_vid.

      • pgr_aStar (One to Many) does not have start_vid.

      • pgr_aStar (Many to One) does not have end_vid.

Migración:

  • Be aware of the existance of the additional columns.

  • In pgr_aStar (One to One)

    • start_vid contains the start vid parameter value.

    • end_vid contains the end vid parameter value.

SELECT * FROM pgr_aStar(
  $$SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edges$$,
  6, 10);
 seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost
-----+----------+-----------+---------+------+------+------+----------
   1 |        1 |         6 |      10 |    6 |    4 |    1 |        0
   2 |        2 |         6 |      10 |    7 |    8 |    1 |        1
   3 |        3 |         6 |      10 |   11 |    9 |    1 |        2
   4 |        4 |         6 |      10 |   16 |   16 |    1 |        3
   5 |        5 |         6 |      10 |   15 |    3 |    1 |        4
   6 |        6 |         6 |      10 |   10 |   -1 |    0 |        5
(6 rows)

  • In pgr_aStar (One to Many)

    • start_vid contains the start vid parameter value.

SELECT * FROM pgr_aStar(
  $$SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edges$$,
  6, ARRAY[3, 10]);
 seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost
-----+----------+-----------+---------+------+------+------+----------
   1 |        1 |         6 |       3 |    6 |    4 |    1 |        0
   2 |        2 |         6 |       3 |    7 |    7 |    1 |        1
   3 |        3 |         6 |       3 |    3 |   -1 |    0 |        2
   4 |        1 |         6 |      10 |    6 |    4 |    1 |        0
   5 |        2 |         6 |      10 |    7 |    8 |    1 |        1
   6 |        3 |         6 |      10 |   11 |    9 |    1 |        2
   7 |        4 |         6 |      10 |   16 |   16 |    1 |        3
   8 |        5 |         6 |      10 |   15 |    3 |    1 |        4
   9 |        6 |         6 |      10 |   10 |   -1 |    0 |        5
(9 rows)

  • In pgr_aStar (Many to One)

    • end_vid contains the end vid parameter value.

SELECT * FROM pgr_aStar(
  $$SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edges$$,
  ARRAY[3, 6], 10);
 seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost
-----+----------+-----------+---------+------+------+------+----------
   1 |        1 |         3 |      10 |    3 |    7 |    1 |        0
   2 |        2 |         3 |      10 |    7 |    8 |    1 |        1
   3 |        3 |         3 |      10 |   11 |    9 |    1 |        2
   4 |        4 |         3 |      10 |   16 |   16 |    1 |        3
   5 |        5 |         3 |      10 |   15 |    3 |    1 |        4
   6 |        6 |         3 |      10 |   10 |   -1 |    0 |        5
   7 |        1 |         6 |      10 |    6 |    4 |    1 |        0
   8 |        2 |         6 |      10 |    7 |    8 |    1 |        1
   9 |        3 |         6 |      10 |   11 |    9 |    1 |        2
  10 |        4 |         6 |      10 |   16 |   16 |    1 |        3
  11 |        5 |         6 |      10 |   15 |    3 |    1 |        4
  12 |        6 |         6 |      10 |   10 |   -1 |    0 |        5
(12 rows)

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

SELECT seq, path_seq, node, edge, cost, agg_cost FROM pgr_aStar(
  $$SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edges$$,
  6, 10);
 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)

  • 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 the function my_dijkstra uses pgr_dijkstra.

    • Starting from v3.5 the function my_dijkstra returns the new additional columns of pgr_dijkstra.

Migration of pgr_bdAstar

Starting from v3.6.0

Firmas que serán migradas:

  • pgr_bdAstar (One to One)

  • pgr_bdAstar (One to Many)

  • pgr_bdAstar (Many to One)

Antes de la migración:

  • Output columns were (seq, path_seq, [start_vid], [end_vid], node, edge, cost, agg_cost)

    • Depending on the overload used, the columns start_vid and end_vid might be missing:

      • pgr_bdAstar (One to One) does not have start_vid and end_vid.

      • pgr_bdAstar (One to Many) does not have start_vid.

      • pgr_bdAstar (Many to One) does not have end_vid.

Migración:

  • Be aware of the existance of the additional columns.

  • In pgr_bdAstar (One to One)

    • start_vid contains the start vid parameter value.

    • end_vid contains the end vid parameter value.

SELECT * FROM pgr_bdAstar(
  $$SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edges$$,
  6, 10);
 seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost
-----+----------+-----------+---------+------+------+------+----------
   1 |        1 |         6 |      10 |    6 |    4 |    1 |        0
   2 |        2 |         6 |      10 |    7 |    8 |    1 |        1
   3 |        3 |         6 |      10 |   11 |    9 |    1 |        2
   4 |        4 |         6 |      10 |   16 |   16 |    1 |        3
   5 |        5 |         6 |      10 |   15 |    3 |    1 |        4
   6 |        6 |         6 |      10 |   10 |   -1 |    0 |        5
(6 rows)

  • In pgr_bdAstar (One to Many)

    • start_vid contains the start vid parameter value.

SELECT * FROM pgr_bdAstar(
  $$SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edges$$,
  6, ARRAY[3, 10]);
 seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost
-----+----------+-----------+---------+------+------+------+----------
   1 |        1 |         6 |       3 |    6 |    4 |    1 |        0
   2 |        2 |         6 |       3 |    7 |    7 |    1 |        1
   3 |        3 |         6 |       3 |    3 |   -1 |    0 |        2
   4 |        1 |         6 |      10 |    6 |    4 |    1 |        0
   5 |        2 |         6 |      10 |    7 |    8 |    1 |        1
   6 |        3 |         6 |      10 |   11 |    9 |    1 |        2
   7 |        4 |         6 |      10 |   16 |   16 |    1 |        3
   8 |        5 |         6 |      10 |   15 |    3 |    1 |        4
   9 |        6 |         6 |      10 |   10 |   -1 |    0 |        5
(9 rows)

  • In pgr_bdAstar (Many to One)

    • end_vid contains the end vid parameter value.

SELECT * FROM pgr_bdAstar(
  $$SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edges$$,
  ARRAY[3, 6], 10);
 seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost
-----+----------+-----------+---------+------+------+------+----------
   1 |        1 |         3 |      10 |    3 |    7 |    1 |        0
   2 |        2 |         3 |      10 |    7 |    8 |    1 |        1
   3 |        3 |         3 |      10 |   11 |    9 |    1 |        2
   4 |        4 |         3 |      10 |   16 |   16 |    1 |        3
   5 |        5 |         3 |      10 |   15 |    3 |    1 |        4
   6 |        6 |         3 |      10 |   10 |   -1 |    0 |        5
   7 |        1 |         6 |      10 |    6 |    4 |    1 |        0
   8 |        2 |         6 |      10 |    7 |    8 |    1 |        1
   9 |        3 |         6 |      10 |   11 |    9 |    1 |        2
  10 |        4 |         6 |      10 |   16 |   16 |    1 |        3
  11 |        5 |         6 |      10 |   15 |    3 |    1 |        4
  12 |        6 |         6 |      10 |   10 |   -1 |    0 |        5
(12 rows)

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

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);
 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)

  • 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 the function my_dijkstra uses pgr_dijkstra.

    • Starting from v3.5 the function my_dijkstra returns the new additional columns of pgr_dijkstra.

Migración de pgr_dijkstra

Comenzando en v3.5.0

Firmas que serán migradas:

  • pgr_dijkstra (Uno a Uno)

  • pgr_dijkstra (Uno a Muchos)

  • pgr_dijkstra (Muchos a Uno)

Antes de la migración:

  • Output columns were (seq, path_seq, [start_vid], [end_vid], node, edge, cost, agg_cost)

    • Depending on the overload used, the columns start_vid and end_vid might be missing:

      • pgr_dijkstra (Uno to Uno) no tiene start_vid ni end_vid.

      • pgr_dijkstra (Uno a Muchos) no tiene start_vid.

      • pgr_dijkstra (Muchos a Uno) no tiene end_vid.

Migración:

  • Be aware of the existance of the additional columns.

  • En pgr_dijkstra (Uno a Muchos)

    • start_vid contains the start vid parameter value.

    • end_vid contains the end vid parameter value.

SELECT * FROM pgr_dijkstra(
  $$SELECT id, source, target, cost, reverse_cost FROM edges$$,
  6, 10);
 seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost
-----+----------+-----------+---------+------+------+------+----------
   1 |        1 |         6 |      10 |    6 |    4 |    1 |        0
   2 |        2 |         6 |      10 |    7 |    8 |    1 |        1
   3 |        3 |         6 |      10 |   11 |    9 |    1 |        2
   4 |        4 |         6 |      10 |   16 |   16 |    1 |        3
   5 |        5 |         6 |      10 |   15 |    3 |    1 |        4
   6 |        6 |         6 |      10 |   10 |   -1 |    0 |        5
(6 rows)

  • En pgr_dijkstra (Uno a Muchos)

    • start_vid contains the start vid parameter value.

SELECT * FROM pgr_dijkstra(
  $$SELECT id, source, target, cost, reverse_cost FROM edges$$,
  6, ARRAY[3, 10]);
 seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost
-----+----------+-----------+---------+------+------+------+----------
   1 |        1 |         6 |       3 |    6 |    4 |    1 |        0
   2 |        2 |         6 |       3 |    7 |    7 |    1 |        1
   3 |        3 |         6 |       3 |    3 |   -1 |    0 |        2
   4 |        1 |         6 |      10 |    6 |    4 |    1 |        0
   5 |        2 |         6 |      10 |    7 |    8 |    1 |        1
   6 |        3 |         6 |      10 |   11 |    9 |    1 |        2
   7 |        4 |         6 |      10 |   16 |   16 |    1 |        3
   8 |        5 |         6 |      10 |   15 |    3 |    1 |        4
   9 |        6 |         6 |      10 |   10 |   -1 |    0 |        5
(9 rows)

  • En pgr_dijkstra (Muchos a Uno)

    • end_vid contains the end vid parameter value.

SELECT * FROM pgr_dijkstra(
  $$SELECT id, source, target, cost, reverse_cost FROM edges$$,
  ARRAY[3, 6], 10);
 seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost
-----+----------+-----------+---------+------+------+------+----------
   1 |        1 |         3 |      10 |    3 |    7 |    1 |        0
   2 |        2 |         3 |      10 |    7 |    8 |    1 |        1
   3 |        3 |         3 |      10 |   11 |    9 |    1 |        2
   4 |        4 |         3 |      10 |   16 |   16 |    1 |        3
   5 |        5 |         3 |      10 |   15 |    3 |    1 |        4
   6 |        6 |         3 |      10 |   10 |   -1 |    0 |        5
   7 |        1 |         6 |      10 |    6 |    4 |    1 |        0
   8 |        2 |         6 |      10 |    7 |    8 |    1 |        1
   9 |        3 |         6 |      10 |   11 |    9 |    1 |        2
  10 |        4 |         6 |      10 |   16 |   16 |    1 |        3
  11 |        5 |         6 |      10 |   15 |    3 |    1 |        4
  12 |        6 |         6 |      10 |   10 |   -1 |    0 |        5
(12 rows)

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

SELECT seq, path_seq, node, edge, cost, agg_cost FROM pgr_dijkstra(
  $$SELECT id, source, target, cost, reverse_cost FROM edges$$,
  6, 10);
 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)

  • If needed add the new columns, for example:

    • In v3.0 the function my_dijkstra uses pgr_dijkstra.

    • Starting from v3.5 the function my_dijkstra returns the new additional columns of pgr_dijkstra.

Migration of pgr_drivingdistance

Starting from v3.6.0 pgr_drivingDistance result columns are being standarized.

from:

(seq, [from_v,] node, edge, cost, agg_cost)

to:

(seq, depth, start_vid, node, edge, cost, agg_cost)

Firmas que serán migradas:

  • pgr_drivingdistance (Single vertex)

  • pgr_drivingdistance (Multiple vertices)

Antes de la migración:

Output columns were (seq, [from_v,] node, edge, cost, agg_cost)

  • pgr_drivingdistance (Single vertex)

    • Does not have start_vid and depth result columns.

  • pgr_drivingdistance (Multiple vertices)

    • Has from_v instead of start_vid result column.

    • does not have depth result column.

Migración:

  • Be aware of the existance and name change of the result columns.

pgr_drivingdistance (Single vertex)

Using this example.

  • start_vid contains the start vid parameter value.

  • depth contains the depth of the node.

    SELECT * FROM pgr_drivingDistance(
      $$SELECT id, source, target, cost, reverse_cost FROM edges$$,
      11, 3.0);
     seq | depth | start_vid | node | edge | cost | agg_cost
    -----+-------+-----------+------+------+------+----------
       1 |     0 |        11 |   11 |   -1 |    0 |        0
       2 |     1 |        11 |    7 |    8 |    1 |        1
       3 |     1 |        11 |   12 |   11 |    1 |        1
       4 |     1 |        11 |   16 |    9 |    1 |        1
       5 |     2 |        11 |    3 |    7 |    1 |        2
       6 |     2 |        11 |    6 |    4 |    1 |        2
       7 |     2 |        11 |    8 |   10 |    1 |        2
       8 |     2 |        11 |   15 |   16 |    1 |        2
       9 |     2 |        11 |   17 |   15 |    1 |        2
      10 |     3 |        11 |    1 |    6 |    1 |        3
      11 |     3 |        11 |    5 |    1 |    1 |        3
      12 |     3 |        11 |    9 |   14 |    1 |        3
      13 |     3 |        11 |   10 |    3 |    1 |        3
    (13 rows)
    
    

If needed filter out the added columns, for example, to return the original columns

SELECT seq, node, edge, cost, agg_cost
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
(13 rows)

pgr_drivingdistance (Multiple vertices)

Using this example.

  • The from_v result column name changes to start_vid.

  • depth contains the depth of the node.

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

If needed filter out and rename colums, for example, to return the original columns:

SELECT seq, start_vid AS from_v, node, edge, cost, agg_cost
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
(13 rows)

Migration of pgr_KSP

Starting from v3.6.0 pgr_KSP result columns are being standarized.

from:

(seq, path_id, path_seq, node, edge, cost, agg_cost)

from:

(seq, path_id, path_seq, start_vid, end_vid, node, edge, cost, agg_cost)

Firmas que serán migradas:

  • pgr_KSP (One to One)

Antes de la migración:

  • Output columns were (seq, path_id, path_seq, node, edge, cost, agg_cost)

    • the columns start_vid and end_vid do not exist.

      • pgr_KSP (One to One) does not have start_vid and end_vid.

Migración:

  • Be aware of the existance of the additional columns.

pgr_KSP (One to One)

Using this example.

  • start_vid contains the start vid parameter value.

  • end_vid contains the end vid parameter value.

SELECT * FROM pgr_KSP(
  $$SELECT id, source, target, cost, reverse_cost FROM edges$$,
  6, 17, 2);
 seq | path_id | path_seq | start_vid | end_vid | node | edge | cost | agg_cost
-----+---------+----------+-----------+---------+------+------+------+----------
   1 |       1 |        1 |         6 |      17 |    6 |    4 |    1 |        0
   2 |       1 |        2 |         6 |      17 |    7 |   10 |    1 |        1
   3 |       1 |        3 |         6 |      17 |    8 |   12 |    1 |        2
   4 |       1 |        4 |         6 |      17 |   12 |   13 |    1 |        3
   5 |       1 |        5 |         6 |      17 |   17 |   -1 |    0 |        4
   6 |       2 |        1 |         6 |      17 |    6 |    4 |    1 |        0
   7 |       2 |        2 |         6 |      17 |    7 |    8 |    1 |        1
   8 |       2 |        3 |         6 |      17 |   11 |    9 |    1 |        2
   9 |       2 |        4 |         6 |      17 |   16 |   15 |    1 |        3
  10 |       2 |        5 |         6 |      17 |   17 |   -1 |    0 |        4
(10 rows)

If needed filter out the added columns, for example, to return the original columns:

SELECT seq, path_id, path_seq, node, edge, cost, agg_cost FROM pgr_KSP(
  $$SELECT id, source, target, cost, reverse_cost FROM edges$$,
  6, 17, 2);
 seq | path_id | path_seq | node | edge | cost | agg_cost
-----+---------+----------+------+------+------+----------
   1 |       1 |        1 |    6 |    4 |    1 |        0
   2 |       1 |        2 |    7 |   10 |    1 |        1
   3 |       1 |        3 |    8 |   12 |    1 |        2
   4 |       1 |        4 |   12 |   13 |    1 |        3
   5 |       1 |        5 |   17 |   -1 |    0 |        4
   6 |       2 |        1 |    6 |    4 |    1 |        0
   7 |       2 |        2 |    7 |    8 |    1 |        1
   8 |       2 |        3 |   11 |    9 |    1 |        2
   9 |       2 |        4 |   16 |   15 |    1 |        3
  10 |       2 |        5 |   17 |   -1 |    0 |        4
(10 rows)

Migración de pgr_maxCardinalityMatch

pgr_maxCardinalityMatch funciona solamente para grafos no dirigidos, entonces la bandera directed ha sido removida.

A partir de v3.4.0 <https://docs.pgrouting.org/3.4/es/migration.html>`__

Firmas que serán migradas:

pgr_maxCardinalityMatch(Edges SQL, [directed])
 RETURNS SETOF (seq, edge, source, target)

Migración es necesaria, porque:

  • Usa cost y reverse_cost en la consulta interna

  • Los resultados son ordenados

  • Funciona para grafos no dirigidos.

  • Nueva firma

    • pgr_maxCardinalityMatch(text) regresa solamente la columna edge.

    • La bandera opcional directed es removida.

Antes de migración:

SELECT * FROM pgr_maxCardinalityMatch(
  $$SELECT id, source, target, cost AS going, reverse_cost AS coming FROM edges$$,
  directed => true
);
WARNING:  pgr_maxCardinalityMatch(text,boolean) deprecated signature on v3.4.0
 seq | edge | source | target
-----+------+--------+--------
   1 |    1 |      5 |      6
   2 |    5 |     10 |     11
   3 |    6 |      1 |      3
   4 |   13 |     12 |     17
   5 |   14 |      8 |      9
   6 |   16 |     15 |     16
   7 |   17 |      2 |      4
   8 |   18 |     13 |     14
(8 rows)

  • Las columnas usadas son going y coming para representar la existencia de la arista.

  • La flag directed es usada para indicar si fue para un grafo dirigido or no dirigido.

    • La bandera directed es ignorada.

      • Independiente de su valor, da el resultado considerando el grafo como no dirigido.

Migración:

  • Usa las columnas cost y reverse_cost para representar la existenica de una arista.

  • No use la bandera directed.

  • En la consulta solo devuelve la columna edge.

SELECT * FROM pgr_maxCardinalityMatch(
  $$SELECT id, source, target, cost, reverse_cost FROM edges$$
);
 edge
------
    1
    5
    6
   13
   14
   16
   17
   18
(8 rows)

Migration of pgr_withPointsDD

Starting from v3.6.0 pgr_withPointsDD - Propuesto result columns are being standarized.

from:

(seq, [start_vid], node, edge, cost, agg_cost)

to:

(seq, depth, start_vid, node, edge, cost, agg_cost)

And driving_side parameter changed from named optional to unnamed compulsory driving side and its validity differ for directed and undirected graphs.

Firmas que serán migradas:

  • pgr_withPointsDD (Single vertex)

  • pgr_withPointsDD (Multiple vertices)

Antes de la migración:

  • pgr_withPointsDD (Single vertex)

    • Output columns were (seq, node, edge, cost, agg_cost)

    • Does not have start_vid and depth result columns.

    • driving_side parameter was named optional now it is compulsory unamed.

  • pgr_withPointsDD (Multiple vertices)

    • Output columns were (seq, start_vid, node, edge, cost, agg_cost)

    • Does not have depth result column.

    • driving_side parameter was named optional now it is compulsory unamed.

Driving side was optional

The default values on this query are:

directed:

true

driving_side:

“b”

details:

false

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);
WARNING:  pgr_withpointsdd(text,text,bigint,double precision,boolean,character,boolean) deprecated signature on 3.6.0
 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 |    7 |    4 |    1 |      1.6
   5 |    3 |    7 |    1 |      2.6
   6 |    8 |   10 |    1 |      2.6
   7 |   11 |    8 |    1 |      2.6
   8 |   -3 |   12 |  0.6 |      3.2
   9 |   -4 |    6 |  0.7 |      3.3
(9 rows)

Driving side was named optional

The default values on this query are:

directed:

true

details:

false

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');
WARNING:  pgr_withpointsdd(text,text,bigint,double precision,boolean,character,boolean) deprecated signature on 3.6.0
 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 |    7 |    4 |    1 |      2.4
(4 rows)

On directed graph b could be used as driving side

The default values on this query are:

details:

false

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, directed => true, driving_side => 'b');
WARNING:  pgr_withpointsdd(text,text,bigint,double precision,boolean,character,boolean) deprecated signature on 3.6.0
 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 |    7 |    4 |    1 |      1.6
   5 |    3 |    7 |    1 |      2.6
   6 |    8 |   10 |    1 |      2.6
   7 |   11 |    8 |    1 |      2.6
   8 |   -3 |   12 |  0.6 |      3.2
   9 |   -4 |    6 |  0.7 |      3.3
(9 rows)

On undirected graph r could be used as driving side

Also l could be used as driving side

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, 'r', directed => true);
 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 |    7 |    4 |    1 |      2.4
(4 rows)

After Migration:

  • Be aware of the existance of the additional return columns.

  • New output columns are (seq, depth, start_vid, node, edge, cost, agg_cost)

  • driving side parameter is unnamed compulsory, and valid values differ for directed and undirected graphs.

    • No tiene un valor de facto.

    • In directed graph: valid values are [r, R, l, L]

    • In undirected graph: valid values are [b, B]

    • Using an invalid value throws an ERROR.

pgr_withPointsDD (Single vertex)

Using this example.

  • (seq, depth, start_vid, node, edge, cost, agg_cost)

  • start_vid contains the start vid parameter value.

  • depth contains the depth from the start_vid vertex to the node.

To migrate, use an unnamed valid value for driving side after the distance parameter:

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, 'r', directed => true);
 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 |    7 |    4 |    1 |      2.4
(4 rows)

To get results from previous versions:

  • filter out the additional columns, for example;

  • When details => false to remove the points use WHERE node >= 0 OR cost = 0

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$$,
  -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
(5 rows)

pgr_withPointsDD (Multiple vertices)

Using this example.

  • (seq, depth, start_vid, node, edge, cost, agg_cost)

  • depth contains the depth from the start_vid vertex to the node.

SELECT * FROM pgr_withPointsDD(
  $$SELECT * FROM edges ORDER BY id$$,
  $$SELECT pid, edge_id, fraction, side from pointsOfInterest$$,
  ARRAY[-1, 16], 3.3, 'l', equicost => true);
 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 |     4 |        -1 |   -3 |   12 |  0.6 |      3.2
   8 |     4 |        -1 |   -4 |    6 |  0.7 |      3.3
   9 |     0 |        16 |   16 |   -1 |    0 |        0
  10 |     1 |        16 |   11 |    9 |    1 |        1
  11 |     1 |        16 |   15 |   16 |    1 |        1
  12 |     1 |        16 |   17 |   15 |    1 |        1
  13 |     2 |        16 |   10 |    3 |    1 |        2
  14 |     2 |        16 |   12 |   11 |    1 |        2
(14 rows)

To get results from previous versions:

  • Filter out the additional columns

  • When details => false to remove the points use WHERE node >= 0 OR cost = 0

SELECT seq, start_vid, 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$$,
  ARRAY[-1, 16], 3.3, 'l', equicost => true) WHERE node >= 0 OR cost = 0;
 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
   9 |        16 |   16 |   -1 |    0 |        0
  10 |        16 |   11 |    9 |    1 |        1
  11 |        16 |   15 |   16 |    1 |        1
  12 |        16 |   17 |   15 |    1 |        1
  13 |        16 |   10 |    3 |    1 |        2
  14 |        16 |   12 |   11 |    1 |        2
(12 rows)

Migration of pgr_withPointsKSP

Starting from v3.6.0 pgr_withPointsKSP - Propuesto result columns are being standarized.

from:

(seq, path_id, path_seq, node, edge, cost, agg_cost)

from:

(seq, path_id, path_seq, start_vid, end_vid, node, edge, cost, agg_cost)

And driving side parameter changed from named optional to unnamed compulsory driving side and its validity differ for directed and undirected graphs.

Firmas que serán migradas:

  • pgr_withPointsKSP (One to One)

Antes de la migración:

  • Output columns were (seq, path_seq, [start_pid], [end_pid], node, edge, cost, agg_cost)

    • the columns start_vid and end_vid do not exist.

Migración:

  • Be aware of the existance of the additional return columns.

  • New output columns are (seq, path_id, path_seq, start_vid, end_vid, node, edge, cost, agg_cost)

  • driving side parameter is unnamed compulsory, and valid values differ for directed and undirected graphs.

    • No tiene un valor de facto.

    • In directed graph: valid values are [r, R, l, L]

    • In undirected graph: valid values are [b, B]

    • Using an invalid value throws an ERROR.

pgr_withPointsKSP (One to One)

Using this example.

  • start_vid contains the start vid parameter value.

  • end_vid contains the end vid parameter value.

SELECT * FROM pgr_withPointsKSP(
  $$SELECT id, source, target, cost, reverse_cost FROM edges$$,
  $$SELECT pid, edge_id, fraction, side from pointsOfInterest$$,
  -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)

If needed filter out the additional columns, for example, to return the original columns:

SELECT seq, path_id, 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$$,
  -1, -2, 2, 'l');
 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 |   11 |    1 |      2.6
   5 |       1 |        5 |   12 |   13 |    1 |      3.6
   6 |       1 |        6 |   17 |   15 |  0.6 |      4.6
   7 |       1 |        7 |   -2 |   -1 |    0 |      5.2
   8 |       2 |        1 |   -1 |    1 |  0.6 |        0
   9 |       2 |        2 |    6 |    4 |    1 |      0.6
  10 |       2 |        3 |    7 |    8 |    1 |      1.6
  11 |       2 |        4 |   11 |    9 |    1 |      2.6
  12 |       2 |        5 |   16 |   15 |  1.6 |      3.6
  13 |       2 |        6 |   -2 |   -1 |    0 |      5.2
(13 rows)

Migration of turn restrictions

Migración de restricciones

A partir de v3.4.0 <https://docs.pgrouting.org/3.4/es/migration.html>`__

La estructura de las restricciones ha cambiado:

Estructura de restricciones vieja

Sobre las firmas obsoletas:

  • La columna rid es ignorada

  • via_path

    • Debe de estar en orden reverso.

    • Es de tipo TEXT.

    • Cuando hay más de una arista debe de ser separada con ,.

  • target_id

    • Es la última arista del camino prohibido.

    • Es de tipo de INTEGER.

  • to_cost

    • Es de tipo FLOAT.

Creación de la vieja table de restricciones

CREATE TABLE old_restrictions (
    rid BIGINT NOT NULL,
    to_cost FLOAT,
    target_id BIGINT,
    via_path TEXT
);
CREATE TABLE

Las viejas restricciones se llenan

INSERT INTO old_restrictions (rid, to_cost, target_id, via_path) VALUES
(1, 100,  7,  '4'),
(1, 100, 11,  '8'),
(1, 100, 10,  '7'),
(2,   4,  9,  '5, 3'),
(3, 100,  9, '16');
INSERT 0 5
Contenido de viejas restricciones
SELECT * FROM old_restrictions;
 rid | to_cost | target_id | via_path
-----+---------+-----------+----------
   1 |     100 |         7 | 4
   1 |     100 |        11 | 8
   1 |     100 |        10 | 7
   2 |       4 |         9 | 5, 3
   3 |     100 |         9 | 16
(5 rows)

La restricción con rid = 2 representa \(3 \rightarrow 5 \rightarrow9\)

  • \(3\rightarrow5\)

    • esta en la columna via_path en orden reverso

    • es de tipo TEXT

  • \(9\)

    • está en la columna target_id

    • es de tipo INTEGER

Estructura de nuevas restricciones

  • La columna id es ignorada

  • Columna path

    • Es de tipo ARRAY[ANY-INTEGER].

    • Contiene todas las aristas involucradas con la restricción

    • El conjunto tiene las aristas ordenadas de la restricción.

  • Columna cost

    • Es de tipo``ANY-NUMERICAL``

La creación de la tabla de restricciones

CREATE TABLE restrictions (
    id SERIAL PRIMARY KEY,
    path BIGINT[],
    cost FLOAT
);
CREATE TABLE

Agregando las restricciones

INSERT INTO restrictions (path, cost) VALUES
(ARRAY[4, 7], 100),
(ARRAY[8, 11], 100),
(ARRAY[7, 10], 100),
(ARRAY[3, 5, 9], 4),
(ARRAY[9, 16], 100);
INSERT 0 5
Datos de restricciones
SELECT * FROM restrictions;
 id |  path   | cost
----+---------+------
  1 | {4,7}   |  100
  2 | {8,11}  |  100
  3 | {7,10}  |  100
  4 | {3,5,9} |    4
  5 | {9,16}  |  100
(5 rows)

La restricción con``rid = 2`` representa el camino \(3 \rightarrow5 \rightarrow9\).

  • El camino es claro por inspección.

Migración

Para transformar la antigua tabla de restricciones a la nueva estructura de restricciones,

  • Crea una nueva tabla con la nueva estructura de restricciones.

    • En esta guía de migración new_restrictions está siendo usada.

  • Para esta migración pgRouting proporciona una función auxiliar para la inversión de un conjunto _pgr_array_reverse necesaria para la migración.

    • _pgr_array_reverse:

      • Se creo temporalmente para esta migración

      • No está documentado.

      • Se eliminara en la próxima versión mayor 4.0.0

SELECT rid AS id,
  _pgr_array_reverse(
    array_prepend(target_id, string_to_array(via_path::text, ',')::BIGINT[])) AS path,
  to_cost AS cost
  INTO new_restrictions
FROM old_restrictions;
SELECT 5

El contenido de la tabla de migración:

SELECT * FROM new_restrictions;
 id |  path   | cost
----+---------+------
  1 | {4,7}   |  100
  1 | {8,11}  |  100
  1 | {7,10}  |  100
  2 | {3,5,9} |    4
  3 | {16,9}  |  100
(5 rows)

Migración de pgr_trsp` (Vértices)

pgr_trsp - Proposed firmas han cambiando y varios problemas han sido arreglados en las nuevas firmas. Esta sección enseñara como migrar las viejas firmas a la nueva función de reemplazo. Esto también afecta las restricciones .

A partir de v3.4.0 <https://docs.pgrouting.org/3.4/es/migration.html>`__

Firmas que serán migradas:

pgr_trsp(Edges SQL, source, target,
         directed boolean, has_rcost boolean
         [,restrict_sql text]);
 RETURNS SETOF (seq, id1, id2, cost)
  • El tipo integral de Edges SQL sólo puede ser INTEGER.

  • El tipo de punto flotante del Edges SQL solo puede ser FLOAT.

  • La bandera directed es obligatoria.

    • No tiene un valor de facto.

  • No auto-detecta si la columna``reverse_cost`` existe.

    • El usuario debe de tener cuidado al coincidir la existencia de la columna con el valor del parámetro has_rcost.

  • Las restricciones de consulta interna son opcionales.

  • Los nombres de la columna de salida no tienen importancia

Migra al user:

Migrar pgr_trsp (Vértices) usando pgr_dijkstra

La siguiente consulta no tiene restricciones.

SELECT * FROM pgr_trsp(
  $$SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost, reverse_cost
    FROM edges WHERE id != 16$$,
  15, 16,
  true, true);
WARNING:  pgr_trsp(text,integer,integer,boolean,boolean) deprecated signature on v3.4.0
 seq | id1 | id2 | cost
-----+-----+-----+------
   0 |  15 |   3 |    1
   1 |  10 |   5 |    1
   2 |  11 |   9 |    1
   3 |  16 |  -1 |    0
(4 rows)

  • Un mensaje sobre lo obsoleto se enseña

    • Funciones obsoletas se eliminaran en la siguiente versión mayor 4.0.0

Usa en vez pgr_dijkstra.

SELECT * FROM pgr_dijkstra(
  $$SELECT id, source, target, cost, reverse_cost
    FROM edges WHERE id != 16$$,
  15, 16);
 seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost
-----+----------+-----------+---------+------+------+------+----------
   1 |        1 |        15 |      16 |   15 |    3 |    1 |        0
   2 |        2 |        15 |      16 |   10 |    5 |    1 |        1
   3 |        3 |        15 |      16 |   11 |    9 |    1 |        2
   4 |        4 |        15 |      16 |   16 |   -1 |    0 |        3
(4 rows)

  • Se han eliminado la fundición de tipos.

  • pgr_dijkstra:

    • Auto-detecta si la columna``reverse_cost`` está en la SQL de aristas.

    • Acepta ANY-INTEGER sobre tipos integrales

    • Acepta ANY-NUMERICAL sobre tipos de puntos flotantes

    • La bandera directed tiene valor de facto de true.

      • Usa el mismo valor de la consulta original.

      • En este ejemplo true que es el valor de facto.

        • Se ha omitido la bandera y se ha utilizado el valor por defecto.

Cuando la necesidad de utilizar estrictamente los mismos nombres (sin importancia) y los tipos de la función han sido migradas entonces:

SELECT seq, node::INTEGER AS id1, edge::INTEGER AS id2, cost
FROM pgr_dijkstra(
  $$SELECT id, source, target, cost, reverse_cost
    FROM edges WHERE id != 16$$,
  15, 16);
 seq | id1 | id2 | cost
-----+-----+-----+------
   1 |  15 |   3 |    1
   2 |  10 |   5 |    1
   3 |  11 |   9 |    1
   4 |  16 |  -1 |    0
(4 rows)

  • id1 es el nodo

  • id2 es la arista

Migrando pgr_trsp (Vértices) usando pgr_trsp

La siguiente consulta tiene restricciones.

SELECT * FROM pgr_trsp(
  $$SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost, reverse_cost
    FROM edges WHERE id != 16$$,
  15, 16,
  true, true,
  $$SELECT to_cost, target_id::INTEGER, via_path
    FROM old_restrictions$$);
WARNING:  pgr_trsp(text,integer,integer,boolean,boolean) deprecated signature on v3.4.0
 seq | id1 | id2 | cost
-----+-----+-----+------
   0 |  15 |   3 |    1
   1 |  10 |   5 |    1
   2 |  11 |  11 |    1
   3 |  12 |  13 |    1
   4 |  17 |  15 |    1
   5 |  16 |  -1 |    0
(6 rows)

  • Un mensaje sobre lo obsoleto se enseña

    • Funciones obsoletas se eliminaran en la siguiente versión mayor 4.0.0

  • Las restricciones son el último parámetro de la función

    • Usando la antigua estructura de restricciones

Utilice en su lugar pgr_trsp - Proposed (Uno a uno).

SELECT * FROM pgr_trsp(
  $$SELECT id, source, target, cost, reverse_cost
    FROM edges WHERE id != 16$$,
  $$SELECT * FROM new_restrictions$$,
  15, 16);
 seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost
-----+----------+-----------+---------+------+------+------+----------
   1 |        1 |        15 |      16 |   15 |    3 |    1 |        0
   2 |        2 |        15 |      16 |   10 |    5 |    1 |        1
   3 |        3 |        15 |      16 |   11 |   11 |    1 |        2
   4 |        4 |        15 |      16 |   12 |   13 |    1 |        3
   5 |        5 |        15 |      16 |   17 |   15 |    1 |        4
   6 |        6 |        15 |      16 |   16 |   -1 |    0 |        5
(6 rows)

  • La nueva estructura de restricciones han sido utilizados.

    • Es el segundo parámetro.

  • Se han eliminado la fundición de tipos.

  • pgr_trsp - Proposed:

    • Auto-detecta si la columna``reverse_cost`` está en la SQL de aristas.

    • Acepta ANY-INTEGER sobre tipos integrales

    • Acepta ANY-NUMERICAL sobre tipos de puntos flotantes

    • La bandera directed tiene valor de facto de true.

      • Usa el mismo valor de la consulta original.

      • En este ejemplo true que es el valor de facto.

        • Se ha omitido la bandera y se ha utilizado el valor por defecto.

Cuando la necesidad de utilizar estrictamente los mismos nombres (sin importancia) y los tipos de la función han sido migradas entonces:

SELECT seq, node::INTEGER AS id1, edge::INTEGER AS id2, cost
FROM pgr_trsp(
  $$SELECT id, source, target, cost, reverse_cost
    FROM edges WHERE id != 16$$,
  $$SELECT * FROM new_restrictions$$,
  15, 16);
 seq | id1 | id2 | cost
-----+-----+-----+------
   1 |  15 |   3 |    1
   2 |  10 |   5 |    1
   3 |  11 |  11 |    1
   4 |  12 |  13 |    1
   5 |  17 |  15 |    1
   6 |  16 |  -1 |    0
(6 rows)

  • id1 es el nodo

  • id2 es la arista

Migración de pgr_trsp (Aristas)

Firmas que serán migradas:

pgr_trsp(sql text, source_edge integer, source_pos float8,
                 target_edge integer, target_pos float8,
                 directed boolean, has_rcost boolean
                 [,restrict_sql text]);
RETURNS SETOF (seq, id1, id2, cost)
  • Los tipos integrales de sql solo pueden ser INTEGER.

  • El tipo de punto flotante del sql solo pueden ser FLOAT.

  • La bandera directed es obligatoria.

    • No tiene un valor de facto.

  • No auto-detecta si la columna``reverse_cost`` existe.

    • El usuario debe de tener cuidado al coincidir la existencia de la columna con el valor del parámetro has_rcost.

  • Las restricciones de consulta interna son opcionales.

Para los siguientes puntos la guía de migración se utilizara:

SELECT pid, edge_id, fraction, side FROM pointsOfInterest
WHERE pid IN (3, 4);
 pid | edge_id | fraction | side
-----+---------+----------+------
   3 |      12 |      0.6 | l
   4 |       6 |      0.3 | r
(2 rows)

Migra al user:

Migrando pgr_trsp (Aristas) usando pgr_withPoints

La siguiente consulta no tiene restricciones.

SELECT * FROM pgr_trsp(
  $$SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost, reverse_cost
    FROM edges$$,
  6, 0.3, 12, 0.6,
  true, true);
WARNING:  pgr_trsp(text,integer,float,integer,float,boolean,boolean) deprecated signature on v3.4.0
 seq | id1 | id2 | cost
-----+-----+-----+------
   0 |  -1 |   6 |  0.7
   1 |   3 |   7 |    1
   2 |   7 |  10 |    1
   3 |   8 |  12 |  0.6
   4 |  -2 |  -1 |    0
(5 rows)

  • Un mensaje sobre lo obsoleto se enseña

    • Funciones obsoletas se eliminaran en la siguiente versión mayor 4.0.0

Utiliza en su lugar pgr_withPoints - Propuesto.

SELECT * FROM pgr_withPoints(
  $$SELECT id, source, target, cost, reverse_cost FROM edges$$,
  $$SELECT pid, edge_id, fraction FROM pointsOfInterest WHERE pid IN (4, 3)$$,
  -4, -3,
  details => false);
 seq | path_seq | node | edge | cost | agg_cost
-----+----------+------+------+------+----------
   1 |        1 |   -4 |    6 |  0.7 |        0
   2 |        2 |    3 |    7 |    1 |      0.7
   3 |        3 |    7 |   10 |    1 |      1.7
   4 |        4 |    8 |   12 |  0.6 |      2.7
   5 |        5 |   -3 |   -1 |    0 |      3.3
(5 rows)

  • Se han eliminado la fundición de tipos.

  • No enseña detalles, pues las funciones obsoletas no enseñan detalles.

  • pgr_withPoints - Propuesto:

    • Auto-detecta si la columna``reverse_cost`` está en la SQL de aristas.

    • Acepta ANY-INTEGER sobre tipos integrales

    • Acepta ANY-NUMERICAL sobre tipos de puntos flotantes

    • La bandera directed tiene valor de facto de true.

      • Usa el mismo valor de la consulta original.

      • En este ejemplo true que es el valor de facto.

        • Se ha omitido la bandera y se ha utilizado el valor por defecto.

    • La consulta de puntos con incluye la columna side.

Cuando la necesidad de utilizar estrictamente los mismos nombres (sin importancia) y tipos , y los valores de nodo de la función han sido migradas entonces:

SELECT seq, node::INTEGER AS id1, edge::INTEGER AS id2, cost
FROM pgr_withPoints(
  $$SELECT id, source, target, cost, reverse_cost FROM edges$$,
  $$SELECT * FROM (VALUES (1, 6, 0.3),(2, 12, 0.6)) AS t(pid, edge_id, fraction)$$,
  -1, -2,
  details => false);
 seq | id1 | id2 | cost
-----+-----+-----+------
   1 |  -1 |   6 |  0.7
   2 |   3 |   7 |    1
   3 |   7 |  10 |    1
   4 |   8 |  12 |  0.6
   5 |  -2 |  -1 |    0
(5 rows)

  • id1 es el nodo

  • id2 es la arista

Migrando``pgr_trsp`` (Aristas) utilizando pgr_trsp_withPoints

La siguiente consulta tiene restricciones.

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

  • Un mensaje sobre lo obsoleto se enseña

    • Funciones obsoletas se eliminaran en la siguiente versión mayor 4.0.0

  • Las restricciones son el último parámetro de la función

    • Usando la antigua estructura de restricciones

Utilizar en su lugar pgr_trsp_withPoints - Proposed.

SELECT * FROM pgr_trsp_withPoints(
  $$SELECT id, source, target, cost, reverse_cost FROM edges$$,
  $$SELECT * FROM new_restrictions$$,
  $$SELECT pid, edge_id, fraction FROM pointsOfInterest WHERE pid IN (4, 3)$$,
  -4, -3,
  details => false);
 seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost
-----+----------+-----------+---------+------+------+------+----------
   1 |        1 |        -4 |      -3 |   -4 |    6 |  0.7 |        0
   2 |        2 |        -4 |      -3 |    3 |    7 |    1 |      0.7
   3 |        3 |        -4 |      -3 |    7 |    8 |    1 |      1.7
   4 |        4 |        -4 |      -3 |   11 |    9 |    1 |      2.7
   5 |        5 |        -4 |      -3 |   16 |   16 |    1 |      3.7
   6 |        6 |        -4 |      -3 |   15 |    3 |    1 |      4.7
   7 |        7 |        -4 |      -3 |   10 |    2 |    1 |      5.7
   8 |        8 |        -4 |      -3 |    6 |    4 |    1 |      6.7
   9 |        9 |        -4 |      -3 |    7 |   10 |    1 |      7.7
  10 |       10 |        -4 |      -3 |    8 |   12 |  0.6 |      8.7
  11 |       11 |        -4 |      -3 |   -3 |   -1 |    0 |      9.3
(11 rows)

  • La nueva estructura de restricciones han sido utilizados.

    • Es el segundo parámetro.

  • Se han eliminado la fundición de tipos.

  • No enseña detalles, pues las funciones obsoletas no enseñan detalles.

  • pgr_trsp_withPoints - Proposed:

    • Auto-detecta si la columna``reverse_cost`` está en la SQL de aristas.

    • Acepta ANY-INTEGER sobre tipos integrales

    • Acepta ANY-NUMERICAL sobre tipos de puntos flotantes

    • La bandera directed tiene valor de facto de true.

      • Usa el mismo valor de la consulta original.

      • En este ejemplo true que es el valor de facto.

        • Se ha omitido la bandera y se ha utilizado el valor por defecto.

    • La consulta de puntos con incluye la columna side.

Cuando la necesidad de utilizar estrictamente los mismos nombres (sin importancia) y tipos , y los valores de nodo de la función han sido migradas entonces:

SELECT seq, node::INTEGER AS id1, edge::INTEGER AS id2, cost
FROM pgr_trsp_withPoints(
  $$SELECT id, source, target, cost, reverse_cost FROM edges$$,
  $$SELECT * FROM new_restrictions$$,
  $$SELECT * FROM (VALUES (1, 6, 0.3),(2, 12, 0.6)) AS t(pid, edge_id, fraction)$$,
  -1, -2,
  details => false)
WHERE edge != -1;
 seq | id1 | id2 | cost
-----+-----+-----+------
   1 |  -1 |   6 |  0.7
   2 |   3 |   7 |    1
   3 |   7 |   8 |    1
   4 |  11 |   9 |    1
   5 |  16 |  16 |    1
   6 |  15 |   3 |    1
   7 |  10 |   2 |    1
   8 |   6 |   4 |    1
   9 |   7 |  10 |    1
  10 |   8 |  12 |  0.6
(10 rows)

  • id1 es el nodo

  • id2 es la arista

Migraciones de pgr_trspViaVertices

Firmas que serán migradas:

pgr_trspViaVertices(sql text, vids integer[],
                  directed boolean, has_rcost boolean
                  [, turn_restrict_sql text]);
RETURNS SETOF (seq, id1, id2, id3, cost)
  • Los tipos enteros de las Consultas de Aristas solo pueden ser ENTEROS.

  • El tipo de punto flotante del Edges SQL solo puede ser FLOAT.

  • La bandera directed es obligatoria.

    • No tiene un valor de facto.

  • No auto-detecta si la columna``reverse_cost`` existe.

    • El usuario debe de tener cuidado al coincidir la existencia de la columna con el valor del parámetro has_rcost.

  • Las restricciones de consulta interna son opcionales.

Migra al user:

Migrando pgr_trspViaVertices usando pgr_dijkstraVia

La siguiente consulta no tiene restricciones.

SELECT * FROM pgr_trspViaVertices(
  $$SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost, reverse_cost FROM edges$$,
  ARRAY[6, 3, 6],
  true, true);
WARNING:  pgr_trspViaVertices(text,anyarray,boolean,boolean,text) deprecated function on v3.4.0
 seq | id1 | id2 | id3 | cost
-----+-----+-----+-----+------
   1 |   1 |   6 |   4 |    1
   2 |   1 |   7 |   7 |    1
   3 |   2 |   3 |   7 |    1
   4 |   2 |   7 |   4 |    1
   5 |   2 |   6 |  -1 |    0
(5 rows)

  • Un mensaje sobre lo obsoleto se enseña

    • Funciones obsoletas se eliminaran en la siguiente versión mayor 4.0.0

Usar pgr_dijkstraVia - Propuesto en su lugar.

SELECT * FROM pgr_dijkstraVia(
  $$SELECT id, source, target, cost, reverse_cost FROM edges$$,
  ARRAY[6, 3, 6]);
 seq | path_id | path_seq | start_vid | end_vid | node | edge | cost | agg_cost | route_agg_cost
-----+---------+----------+-----------+---------+------+------+------+----------+----------------
   1 |       1 |        1 |         6 |       3 |    6 |    4 |    1 |        0 |              0
   2 |       1 |        2 |         6 |       3 |    7 |    7 |    1 |        1 |              1
   3 |       1 |        3 |         6 |       3 |    3 |   -1 |    0 |        2 |              2
   4 |       2 |        1 |         3 |       6 |    3 |    7 |    1 |        0 |              2
   5 |       2 |        2 |         3 |       6 |    7 |    4 |    1 |        1 |              3
   6 |       2 |        3 |         3 |       6 |    6 |   -2 |    0 |        2 |              4
(6 rows)

  • Se han eliminado la fundición de tipos.

  • pgr_dijkstraVia - Propuesto:

    • Auto-detecta si la columna``reverse_cost`` está en la SQL de aristas.

    • Acepta ANY-INTEGER sobre tipos integrales

    • Acepta ANY-NUMERICAL sobre tipos de puntos flotantes

    • La bandera directed tiene valor de facto de true.

      • Usa el mismo valor de la consulta original.

      • En este ejemplo true que es el valor de facto.

        • Se ha omitido la bandera y se ha utilizado el valor por defecto.

    • La consulta de puntos con incluye la columna side.

Cuando la necesidad de utilizar estrictamente los mismos nombres (sin importancia) y los tipos de la función han sido migradas entonces:

SELECT row_number() over(ORDER BY seq) AS seq,
  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_dijkstraVia(
  $$SELECT id, source, target, cost, reverse_cost FROM edges$$,
  ARRAY[6, 3, 6])
WHERE edge != -1;
 seq | id1 | id2 | id3 | cost
-----+-----+-----+-----+------
   1 |   1 |   6 |   4 |    1
   2 |   1 |   7 |   7 |    1
   3 |   2 |   3 |   7 |    1
   4 |   2 |   7 |   4 |    1
   5 |   2 |   6 |  -1 |    0
(5 rows)

  • id1 es el identificador de camino

  • id2 es el nodo

  • id3 es la arista

Migrando pgr_trspViaVertices usando pgr_trspVia

La siguiente consulta tiene restricciones.

SELECT * FROM pgr_trspViaVertices(
  $$SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost, reverse_cost FROM edges$$,
  ARRAY[6, 3, 6],
  true, true,
  $$SELECT to_cost, target_id::INTEGER, via_path FROM old_restrictions$$);
WARNING:  pgr_trspViaVertices(text,anyarray,boolean,boolean,text) deprecated function on v3.4.0
 seq | id1 | id2 | id3 | cost
-----+-----+-----+-----+------
   1 |   1 |   6 |   4 |    1
   2 |   1 |   7 |   8 |    1
   3 |   1 |  11 |   9 |    1
   4 |   1 |  16 |  16 |    1
   5 |   1 |  15 |   3 |    1
   6 |   1 |  10 |   5 |    1
   7 |   1 |  11 |   8 |    1
   8 |   1 |   7 |   7 |    1
   9 |   2 |   3 |   7 |    1
  10 |   2 |   7 |   4 |    1
  11 |   2 |   6 |  -1 |    0
(11 rows)

  • Un mensaje sobre lo obsoleto se enseña

    • Funciones obsoletas se eliminaran en la siguiente versión mayor 4.0.0

  • Las restricciones son el último parámetro de la función

    • Usando la antigua estructura de restricciones

Usar pgr_trspVia - Proposed en su lugar.

SELECT * FROM pgr_trspVia(
  $$SELECT id, source, target, cost, reverse_cost FROM edges$$,
  $$SELECT * FROM new_restrictions$$,
  ARRAY[6, 3, 6]);
 seq | path_id | path_seq | start_vid | end_vid | node | edge | cost | agg_cost | route_agg_cost
-----+---------+----------+-----------+---------+------+------+------+----------+----------------
   1 |       1 |        1 |         6 |       3 |    6 |    4 |    1 |        0 |              0
   2 |       1 |        2 |         6 |       3 |    7 |    8 |    1 |        1 |              1
   3 |       1 |        3 |         6 |       3 |   11 |    9 |    1 |        2 |              2
   4 |       1 |        4 |         6 |       3 |   16 |   16 |    1 |        3 |              3
   5 |       1 |        5 |         6 |       3 |   15 |    3 |    1 |        4 |              4
   6 |       1 |        6 |         6 |       3 |   10 |    5 |    1 |        5 |              5
   7 |       1 |        7 |         6 |       3 |   11 |    8 |    1 |        6 |              6
   8 |       1 |        8 |         6 |       3 |    7 |    7 |    1 |        7 |              7
   9 |       1 |        9 |         6 |       3 |    3 |   -1 |    0 |        8 |              8
  10 |       2 |        1 |         3 |       6 |    3 |    7 |    1 |        0 |              8
  11 |       2 |        2 |         3 |       6 |    7 |    4 |    1 |        1 |              9
  12 |       2 |        3 |         3 |       6 |    6 |   -2 |    0 |        2 |             10
(12 rows)

  • La nueva estructura de restricciones han sido utilizados.

    • Es el segundo parámetro.

  • Se han eliminado la fundición de tipos.

  • pgr_trspVia - Proposed:

    • Auto-detecta si la columna``reverse_cost`` está en la SQL de aristas.

    • Acepta ANY-INTEGER sobre tipos integrales

    • Acepta ANY-NUMERICAL sobre tipos de puntos flotantes

    • La bandera directed tiene valor de facto de true.

      • Usa el mismo valor de la consulta original.

      • En este ejemplo true que es el valor de facto.

        • Se ha omitido la bandera y se ha utilizado el valor por defecto.

    • La consulta de puntos con incluye la columna side.

Cuando la necesidad de utilizar estrictamente los mismos nombres (sin importancia) y los tipos de la función han sido migradas entonces:

SELECT row_number() over(ORDER BY seq) AS seq,
  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_trspVia(
  $$SELECT id, source, target, cost, reverse_cost FROM edges$$,
  $$SELECT * FROM new_restrictions$$,
  ARRAY[6, 3, 6])
WHERE edge != -1;
 seq | id1 | id2 | id3 | cost
-----+-----+-----+-----+------
   1 |   1 |   6 |   4 |    1
   2 |   1 |   7 |   8 |    1
   3 |   1 |  11 |   9 |    1
   4 |   1 |  16 |  16 |    1
   5 |   1 |  15 |   3 |    1
   6 |   1 |  10 |   5 |    1
   7 |   1 |  11 |   8 |    1
   8 |   1 |   7 |   7 |    1
   9 |   2 |   3 |   7 |    1
  10 |   2 |   7 |   4 |    1
  11 |   2 |   6 |  -1 |    0
(11 rows)

  • id1 es el identificador de camino

  • id2 es el nodo

  • id3 es la arista

Migración de pgr_trspViaEdges

Firmas que serán migradas:

pgr_trspViaEdges(sql text, eids integer[], pcts float8[],
                  directed boolean, has_rcost boolean
                  [, turn_restrict_sql text]);
RETURNS SETOF (seq, id1, id2, id3, cost)
  • Los tipos enteros de las Consultas de Aristas solo pueden ser ENTEROS.

  • El tipo de punto flotante del Edges SQL solo puede ser FLOAT.

  • La bandera directed es obligatoria.

    • No tiene un valor de facto.

  • No auto-detecta si la columna``reverse_cost`` existe.

    • El usuario debe de tener cuidado al coincidir la existencia de la columna con el valor del parámetro has_rcost.

  • Las restricciones de consulta interna son opcionales.

Para los siguientes puntos la guía de migración se utilizara:

SELECT pid, edge_id, fraction, side FROM pointsOfInterest
WHERE pid IN (3, 4, 6);
 pid | edge_id | fraction | side
-----+---------+----------+------
   3 |      12 |      0.6 | l
   4 |       6 |      0.3 | r
   6 |       4 |      0.7 | b
(3 rows)

Viajará a travez de los siguientes puntos de la vía \(4\rightarrow3\rightarrow6\)

Migra al user:

Migrando pgr_trspViaEdges usando pgr_withPointsVia

La siguiente consulta no tiene restricciones.

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)

  • Un mensaje sobre lo obsoleto se enseña

    • Funciones obsoletas se eliminaran en la siguiente versión mayor 4.0.0

Usar pgr_withPointsVia - Proposed en su lugar.

SELECT * FROM pgr_withPointsVia(
  $$SELECT id, source, target, cost, reverse_cost FROM edges$$,
  $$SELECT pid, edge_id, fraction FROM pointsOfInterest WHERE pid IN (3, 4, 6)$$,
  ARRAY[-4, -3, -6],
  details => false);
 seq | path_id | path_seq | start_vid | end_vid | node | edge | cost | agg_cost | route_agg_cost
-----+---------+----------+-----------+---------+------+------+------+----------+----------------
   1 |       1 |        1 |        -4 |      -3 |   -4 |    6 |  0.7 |        0 |              0
   2 |       1 |        2 |        -4 |      -3 |    3 |    7 |    1 |      0.7 |            0.7
   3 |       1 |        3 |        -4 |      -3 |    7 |   10 |    1 |      1.7 |            1.7
   4 |       1 |        4 |        -4 |      -3 |    8 |   12 |  0.6 |      2.7 |            2.7
   5 |       1 |        5 |        -4 |      -3 |   -3 |   -1 |    0 |      3.3 |            3.3
   6 |       2 |        1 |        -3 |      -6 |   -3 |   12 |  0.4 |        0 |            3.3
   7 |       2 |        2 |        -3 |      -6 |   12 |   13 |    1 |      0.4 |            3.7
   8 |       2 |        3 |        -3 |      -6 |   17 |   15 |    1 |      1.4 |            4.7
   9 |       2 |        4 |        -3 |      -6 |   16 |    9 |    1 |      2.4 |            5.7
  10 |       2 |        5 |        -3 |      -6 |   11 |    8 |    1 |      3.4 |            6.7
  11 |       2 |        6 |        -3 |      -6 |    7 |    4 |  0.3 |      4.4 |            7.7
  12 |       2 |        7 |        -3 |      -6 |   -6 |   -2 |    0 |      4.7 |              8
(12 rows)

  • Se han eliminado la fundición de tipos.

  • No enseña detalles, pues las funciones obsoletas no enseñan detalles.

  • pgr_withPointsVia - Proposed:

    • Auto-detecta si la columna``reverse_cost`` está en la SQL de aristas.

    • Acepta ANY-INTEGER sobre tipos integrales

    • Acepta ANY-NUMERICAL sobre tipos de puntos flotantes

    • La bandera directed tiene valor de facto de true.

      • Usa el mismo valor de la consulta original.

      • En este ejemplo true que es el valor de facto.

        • Se ha omitido la bandera y se ha utilizado el valor por defecto.

    • La consulta de puntos con incluye la columna side.

Cuando la necesidad de utilizar estrictamente los mismos nombres (sin importancia) y tipos , y los valores de nodo de la función han sido migradas entonces:

SELECT row_number() over(ORDER BY seq) AS seq,
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);
 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.3
  12 |   2 |  -3 |  -1 |    0
(12 rows)

  • id1 es el identificador de camino

  • id2 es el nodo

  • id3 es la arista

Migrando pgr_trspViaEdges usando pgr_trspVia_withPoints

La siguiente consulta tiene restricciones.

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)

  • Un mensaje sobre lo obsoleto se enseña

    • Funciones obsoletas se eliminaran en la siguiente versión mayor 4.0.0

  • Las restricciones son el último parámetro de la función

    • Usando la antigua estructura de restricciones

Usar pgr_trspVia_withPoints - Proposed en su lugar.

SELECT * FROM pgr_trspVia_withPoints(
  $$SELECT id, source, target, cost, reverse_cost FROM edges$$,
  $$SELECT * FROM new_restrictions$$,
  $$SELECT pid, edge_id, fraction FROM pointsOfInterest WHERE pid IN (3, 4, 6)$$,
  ARRAY[-4, -3, -6],
  details => false);
 seq | path_id | path_seq | start_vid | end_vid | node | edge | cost | agg_cost | route_agg_cost
-----+---------+----------+-----------+---------+------+------+------+----------+----------------
   1 |       1 |        1 |        -4 |      -3 |   -4 |    6 |  0.7 |        0 |              0
   2 |       1 |        2 |        -4 |      -3 |    3 |    7 |    1 |      0.7 |            0.7
   3 |       1 |        3 |        -4 |      -3 |    7 |    4 |  0.6 |      1.7 |            1.7
   4 |       1 |        4 |        -4 |      -3 |    7 |   10 |    1 |      2.3 |            2.3
   5 |       1 |        5 |        -4 |      -3 |    8 |   12 |  0.6 |      3.3 |            3.3
   6 |       1 |        6 |        -4 |      -3 |   -3 |   -1 |    0 |      3.9 |            3.9
   7 |       2 |        1 |        -3 |      -6 |   -3 |   12 |  0.4 |        0 |            3.9
   8 |       2 |        2 |        -3 |      -6 |   12 |   13 |    1 |      0.4 |            4.3
   9 |       2 |        3 |        -3 |      -6 |   17 |   15 |    1 |      1.4 |            5.3
  10 |       2 |        4 |        -3 |      -6 |   16 |    9 |    1 |      2.4 |            6.3
  11 |       2 |        5 |        -3 |      -6 |   11 |    8 |    1 |      3.4 |            7.3
  12 |       2 |        6 |        -3 |      -6 |    7 |    4 |  0.3 |      4.4 |            8.3
  13 |       2 |        7 |        -3 |      -6 |   -6 |   -2 |    0 |      4.7 |            8.6
(13 rows)

  • La nueva estructura de restricciones han sido utilizados.

    • Es el segundo parámetro.

  • Se han eliminado la fundición de tipos.

  • No enseña detalles, pues las funciones obsoletas no enseñan detalles.

  • pgr_trspVia_withPoints - Proposed:

    • Auto-detecta si la columna``reverse_cost`` está en la SQL de aristas.

    • Acepta ANY-INTEGER sobre tipos integrales

    • Acepta ANY-NUMERICAL sobre tipos de puntos flotantes

    • La bandera directed tiene valor de facto de true.

      • Usa el mismo valor de la consulta original.

      • En este ejemplo true que es el valor de facto.

        • Se ha omitido la bandera y se ha utilizado el valor por defecto.

    • La consulta de puntos con incluye la columna side.

Cuando la necesidad de utilizar estrictamente los mismos nombres (sin importancia) y tipos , y los valores de nodo de la función han sido migradas entonces:

SELECT row_number() over(ORDER BY seq) AS seq,
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_trspVia_withPoints(
  $$SELECT id, source, target, cost, reverse_cost FROM edges$$,
  $$SELECT * FROM new_restrictions$$,
  $$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);
 seq | id1 | id2 | id3 | cost
-----+-----+-----+-----+------
   1 |   1 |  -1 |   6 |  0.7
   2 |   1 |   3 |   7 |    1
   3 |   1 |   7 |   4 |  0.6
   4 |   1 |   7 |  10 |    1
   5 |   1 |   8 |  12 |  0.6
   6 |   1 |  -2 |  -1 |    0
   7 |   2 |  -2 |  12 |  0.4
   8 |   2 |  12 |  13 |    1
   9 |   2 |  17 |  15 |    1
  10 |   2 |  16 |   9 |    1
  11 |   2 |  11 |   8 |    1
  12 |   2 |   7 |   4 |  0.3
  13 |   2 |  -3 |  -1 |    0
(13 rows)

  • id1 es el identificador de camino

  • id2 es el nodo

  • id3 es la arista

Ver también

Índices y tablas