withPoints- Categoría¶
Cuando los puntos se agregan al grafo.
Advertencia
Funciones propuestas para la próxima versión mayor.
No están oficialmente en la versión actual.
Es probable que oficialmente formen parte del próximo lanzamiento:
Las funciones hacen uso de ENTEROS y FLOTANTES
Es posible que el nombre no cambie. (Pero todavía puede)
Es posible que la firma no cambie. (Pero todavía puede)
Es posible que la funcionalidad no cambie. (Pero todavía puede)
Se han hecho pruebas con pgTap. Pero tal vez se necesiten más.
Es posible que la documentación necesite un refinamiento.
withPoints - Familia de funciones - Funciones que se basan en el algoritmo Dijkstra.
Desde TRSP - Familia de funciones :
pgr_trsp_withPoints - Proposed - Ruteo de Punto/Vértice con restricciones.
pgr_trspVia_withPoints - Proposed - Via Ruteo de Punto/Vértice con restricciones.
Introducción¶
La categoría with points modifica el grafo continuamente al agregar puntos en las aristas, como es requerido por la consulta Points SQL .
Las funciones en esta categoría otorgan la habilidad de procesar entre puntos arbitrarios ubicados afuera del grafo original.
Esta categoría de funciones se origino para el ruteo de vehículos, pero bien puede funcionar si se aplica en algo que no incluya vehículos.
Cuando se da un identificador de punto pid
que esta siendo mapeado a una arista con un identificador``edge_id``, con una fracción de la fuente al objetivo a lo largo de la arista fraction
y existe información adicional sobre de que lado de la arista el punto está side
, entonces el procesos desde puntos arbitrarios se puede hacer en redes fijas.
Todas estas funciones consideran el mayor numero características posibles del «mundo real»:
Tipo de grafo:
grafo dirigido
grafo no dirigido
Llegando al punto:
Llegada obligatoria en el lado del segmento donde se ubica el punto.
En cualquier lado del segmento.
Países con:
Manejando del lado derecho
Manejando del lado izquierdo
Algunos puntos son:
Permanente: por ejemplo el grupo de puntos de clientes guardados en una table en la base de datos.
El grafo fue modificado para que tenga esos puntos como vértices de manera permanente.
Hay una table en la base de datos que describe los puntos
Temporal: por ejemplo los puntos dados por una aplicación en la web
Usa pgr_findCloseEdges en el Points SQL.
La numeración de los puntos se marca con signo negativo.
El cambio de signo es para evitar confusión cuando hay un vértice con el mismo identificador de un identificador de punto.
Identificadores del punto original deben ser positivos.
Transformación a un negativo se hace internamente.
Interpretation of the sign on the node information of the output
positive sign is a vertex of the original graph
negative sign is a point of the Points SQL
Parámetros¶
Columna |
Tipo |
Descripción |
---|---|---|
|
Consulta de aristas como se describe a continuación |
|
|
Points SQL as described below |
|
|
SQL Combinaciones como se describe a abajo |
|
vid de salida |
|
Identifier of the starting vertex of the path. Negative value is for point’s identifier. |
vid salidas |
|
Array of identifiers of starting vertices. Negative values are for point’s identifiers. |
vid destino |
|
Identifier of the ending vertex of the path. Negative value is for point’s identifier. |
vids destinos |
|
Array of identifiers of ending vertices. Negative values are for point’s identifiers. |
Parámetros opcionales¶
Parámetro |
Tipo |
x Defecto |
Descripción |
---|---|---|---|
|
|
|
Value in [
|
|
|
|
|
Consultas internas¶
SQL de aristas¶
Columna |
Tipo |
x Defecto |
Descripción |
---|---|---|---|
|
ENTEROS |
Identificador de la arista. |
|
|
ENTEROS |
Identificador del primer vértice de la arista. |
|
|
ENTEROS |
Identificador del segundo vértice de la arista. |
|
|
FLOTANTES |
Peso de la arista ( |
|
|
FLOTANTES |
-1 |
Peso de la arista (
|
Donde:
- ENTEROS:
SMALLINT
,INTEGER
,BIGINT
- FLOTANTES:
SMALLINT
,INTEGER
,BIGINT
,REAL
,FLOAT
Puntos SQL¶
Parámetro |
Tipo |
x Defecto |
Descripción |
---|---|---|---|
|
ENTEROS |
valor |
Identificador del punto.
|
|
ENTEROS |
Identificador de la arista «más cercana» al punto. |
|
|
FLOTANTES |
El valor en <0,1> que indica la posición relativa desde el primer punto de la arista. |
|
|
|
|
Valor en [
|
Donde:
- ENTEROS:
SMALLINT
,INTEGER
,BIGINT
- FLOTANTES:
SMALLINT
,INTEGER
,BIGINT
,REAL
,FLOAT
SQL Combinaciones¶
Parámetro |
Tipo |
Descripción |
---|---|---|
|
ENTEROS |
Identificador del vértice de salida. |
|
ENTEROS |
Identificador del vértice de llegada. |
Donde:
- ENTEROS:
SMALLINT
,INTEGER
,BIGINT
Documentación avanzada¶
About points¶
For this section the following city (see Datos Muestra) some interesing points such as restaurant, supermarket, post office, etc. will be used as example.

The graph is directed
Red arrows show the
(source, target)
of the edge on the edge tableBlue arrows show the
(target, source)
of the edge on the edge tableEach point location shows where it is located with relation of the edge
(source, target)
On the right for points 2 and 4.
On the left for points 1, 3 and 5.
On both sides for point 6.
The representation on the data base follows the Points SQL description, and for this example:
SELECT pid, edge_id, fraction, side FROM pointsOfInterest;
pid | edge_id | fraction | side
-----+---------+--------------------+------
1 | 1 | 0.4 | l
4 | 6 | 0.3 | r
3 | 12 | 0.6000000000000001 | l
2 | 15 | 0.3999999999999999 | r
5 | 5 | 0.8 | l
6 | 4 | 0.7 | b
(6 rows)
Driving side¶
In the the folowwing images:
The squared vertices are the temporary vertices,
The temporary vertices are added according to the driving side,
visually showing the differences on how depending on the driving side the data is interpreted.
Lado de conducción derecho¶

Point 1 located on edge
(6, 5)
Point 2 located on edge
(16, 17)
Point 3 located on edge
(8, 12)
Point 4 located on edge
(1, 3)
Point 5 located on edge
(10, 11)
Point 6 located on edges
(6, 7)
and(7, 6)
Lado de conducción izquierdo¶

Point 1 located on edge
(5, 6)
Point 2 located on edge
(17, 16)
Point 3 located on edge
(8, 12)
Point 4 located on edge
(3, 1)
Point 5 located on edge
(10, 11)
Point 6 located on edges
(6, 7)
and(7, 6)
Driving side does not matter¶
Like having all points to be considered in both sides
b
Prefered usage on undirected graphs
On the TRSP - Familia de funciones this option is not valid

Point 1 located on edge
(5, 6)
and(6, 5)
Point 2 located on edge
(17, 16)``and ``16, 17
Point 3 located on edge
(8, 12)
Point 4 located on edge
(3, 1)
and(1, 3)
Point 5 located on edge
(10, 11)
Point 6 located on edges
(6, 7)
and(7, 6)
Creating temporary vertices¶
This section will demonstrate how a temporary vertex is created internally on the graph.
Problem
For edge:
SELECT id, source, target, cost, reverse_cost
FROM edges WHERE id = 15;
id | source | target | cost | reverse_cost
----+--------+--------+------+--------------
15 | 16 | 17 | 1 | 1
(1 row)
insert point:
SELECT pid, edge_id, fraction, side
FROM pointsOfInterest WHERE pid = 2;
pid | edge_id | fraction | side
-----+---------+--------------------+------
2 | 15 | 0.3999999999999999 | r
(1 row)
En una red de conducción del lado derecho¶
Lado de conducción derecho

Arrival to point
-2
can be achived only via vertex 16.Does not affects edge
(17, 16)
, therefore the edge is kept.It only affects the edge
(16, 17)
, therefore the edge is removed.Create two new edges:
Edge
(16, -2)
with cost0.4
(original cost * fraction == \(1 * 0.4\))Edge
(-2, 17)
with cost0.6
(the remaing cost)
The total cost of the additional edges is equal to the original cost.
If more points are on the same edge, the process is repeated recursevly.
En una red de conducción del lado izquierdo¶
Lado de conducción izquierdo

Arrival to point
-2
can be achived only via vertex 17.Does not affects edge
(16, 17)
, therefore the edge is kept.It only affects the edge
(17, 16)
, therefore the edge is removed.Create two new edges:
Work with the original edge
(16, 17)
as the fraction is a fraction of the original:Edge
(16, -2)
with cost0.4
(original cost * fraction == \(1 * 0.4\))Edge
(-2, 17)
with cost0.6
(the remaing cost)If more points are on the same edge, the process is repeated recursevly.
Flip the Edges and add them to the graph:
Edge
(17, -2)
becomes(-2, 16)
with cost0.4
and is added to the graph.Edge
(-2, 16)
becomes(17, -2)
with cost0.6
and is added to the graph.
The total cost of the additional edges is equal to the original cost.
Cuando el lado de conducción no importa¶

Arrival to point
-2
can be achived via vertices 16 or 17.Affects the edges
(16, 17)
and(17, 16)
, therefore the edges are removed.Create four new edges:
Work with the original edge
(16, 17)
as the fraction is a fraction of the original:Edge
(16, -2)
with cost0.4
(original cost * fraction == \(1 * 0.4\))Edge
(-2, 17)
with cost0.6
(the remaing cost)If more points are on the same edge, the process is repeated recursevly.
Flip the Edges and add all the edges to the graph:
Edge
(16, -2)
is added to the graph.Edge
(-2, 17)
is added to the graph.Edge
(16, -2)
becomes(-2, 16)
with cost0.4
and is added to the graph.Edge
(-2, 17)
becomes(17, -2)
with cost0.6
and is added to the graph.
Ver también¶
Índices y tablas