pgr_withPointsDD  Proposed¶
pgr_withPointsDD
 Returns the driving distance from a starting point.
Warning
Proposed functions for next mayor release.
They are not officially in the current release.
They will likely officially be part of the next mayor release:
The functions make use of ANYINTEGER and ANYNUMERICAL
Name might not change. (But still can)
Signature might not change. (But still can)
Functionality might not change. (But still can)
pgTap tests have being done. But might need more.
Documentation might need refinement.
Availability
Version 2.2.0
New proposed function
Description¶
Modify the graph to include points and
using Dijkstra algorithm, extracts all the nodes and points that have costs less
than or equal to the value distance
from the starting point.
The edges extracted will conform the corresponding spanning tree.
Signatures¶
Summary
pgr_withPointsDD(edges_sql, points_sql, from_vids, distance [, directed] [, driving_side] [, details] [, equicost])
RETURNS SET OF (seq, node, edge, cost, agg_cost)
Using defaults
For a directed graph.
The driving side is set as b both. So arriving/departing to/from the point(s) can be in any direction.
No details are given about distance of other points of the query.
pgr_withPointsDD(edges_sql, points_sql, start_vid, distance)
RETURNS SET OF (seq, node, edge, cost, agg_cost)
 Example
From point \(1\) with \(agg\_cost <= 3.8\)
For a directed graph.
The driving side is set as b both. So arriving/departing to/from the point(s) can be in any direction.
No details are given about distance of other points of the query.
SELECT * FROM pgr_withPointsDD(
'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id',
'SELECT pid, edge_id, fraction, side from pointsOfInterest',
1, 3.8);
seq  node  edge  cost  agg_cost
++++
1  1  1  0  0
2  1  1  0.4  0.4
3  2  1  0.6  0.6
4  5  4  1  1.6
5  6  8  1  2.6
6  8  7  1  2.6
7  10  10  1  2.6
8  7  6  1  3.6
9  9  9  1  3.6
10  11  11  1  3.6
11  13  14  1  3.6
(11 rows)
Single vertex¶
Finds the driving distance depending on the optional parameters setup.
pgr_withPointsDD(edges_sql, points_sql, from_vid, distance [, directed] [, driving_side] [, details])
RETURNS SET OF (seq, node, edge, cost, agg_cost)
 Example
Right side driving topology, from point \(1\) with \(agg\_cost <= 3.8\)
SELECT * FROM pgr_withPointsDD(
'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id',
'SELECT pid, edge_id, fraction, side from pointsOfInterest',
1, 3.8,
driving_side := 'r',
details := true);
seq  node  edge  cost  agg_cost
++++
1  1  1  0  0
2  1  1  0.4  0.4
3  2  1  1  1.4
4  6  4  0.7  2.1
5  5  4  0.3  2.4
6  6  8  1  3.4
7  8  7  1  3.4
8  10  10  1  3.4
(8 rows)
Multiple vertices¶
Finds the driving distance depending on the optional parameters setup.
pgr_withPointsDD(edges_sql, points_sql, from_vids, distance [, directed] [, driving_side] [, details] [, equicost])
RETURNS SET OF (seq, node, edge, cost, agg_cost)
Parameters¶
Parameter 
Type 
Description 

edges_sql 

Edges SQL query as described above. 
points_sql 

Points SQL query as described above. 
start_vid 

Starting point id 
distance 

Distance from the start_pid 
directed 

(optional). When 
driving_side 


details 

(optional). When 
equicost 

(optional). When 
Inner query¶
Column 
Type 
Default 
Description 

id 

Identifier of the edge. 

source 

Identifier of the first end point vertex of the edge. 

target 

Identifier of the second end point vertex of the edge. 

cost 

Weight of the edge (source, target)


reverse_cost 

1 
Weight of the edge (target, source),

Where:
 ANYINTEGER
SMALLINT, INTEGER, BIGINT
 ANYNUMERICAL
SMALLINT, INTEGER, BIGINT, REAL, FLOAT
Description of the Points SQL query
 points_sql
an SQL query, which should return a set of rows with the following columns:
Column 
Type 
Description 

pid 

(optional) Identifier of the point.

edge_id 

Identifier of the “closest” edge to the point. 
fraction 

Value in <0,1> that indicates the relative postition from the first end point of the edge. 
side 

(optional) Value in [‘b’, ‘r’, ‘l’, NULL] indicating if the point is:

Where:
 ANYINTEGER
smallint, int, bigint
 ANYNUMERICAL
smallint, int, bigint, real, float
Result Columns¶
Column 
Type 
Description 

seq 

row sequence. 
node 

Identifier of the node within the Distance from 
edge 


cost 


agg_cost 


Additional Examples¶
Examples for queries marked as directed
with cost
and reverse_cost
columns.
The examples in this section use the following Network for queries marked as directed and cost and reverse_cost columns are used
 Example
Left side driving topology from point \(1\) with \(agg\_cost <= 3.8\), with details
SELECT * FROM pgr_withPointsDD(
'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id',
'SELECT pid, edge_id, fraction, side from pointsOfInterest',
1, 3.8,
driving_side := 'l',
details := true);
seq  node  edge  cost  agg_cost
++++
1  1  1  0  0
2  2  1  0.6  0.6
3  6  4  0.7  1.3
4  5  4  0.3  1.6
5  1  1  1  1.6
6  6  8  1  2.6
7  8  7  1  2.6
8  10  10  1  2.6
9  3  12  0.6  3.2
10  4  6  0.7  3.3
11  7  6  0.3  3.6
12  9  9  1  3.6
13  11  11  1  3.6
14  13  14  1  3.6
(14 rows)
 Example
From point \(1\) with \(agg\_cost <= 3.8\), does not matter driving side, with details
SELECT * FROM pgr_withPointsDD(
'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id',
'SELECT pid, edge_id, fraction, side from pointsOfInterest',
1, 3.8,
driving_side := 'b',
details := true);
seq  node  edge  cost  agg_cost
++++
1  1  1  0  0
2  1  1  0.4  0.4
3  2  1  0.6  0.6
4  6  4  0.7  1.3
5  5  4  0.3  1.6
6  6  8  1  2.6
7  8  7  1  2.6
8  10  10  1  2.6
9  3  12  0.6  3.2
10  4  6  0.7  3.3
11  7  6  0.3  3.6
12  9  9  1  3.6
13  11  11  1  3.6
14  13  14  1  3.6
(14 rows)
The queries use the Sample Data network.
See Also¶
pgr_drivingDistance  Driving distance using dijkstra.
pgr_alphaShape  Alpha shape computation.
Indices and tables