Unsupported versions:2.6 2.5 2.4 2.3 2.2 2.1 2.0
pgr_analyzeOneWay
- Deprecated since 3.8.0¶
pgr_analyzeOneWay
— 分析单向街道并识别翻转路段。
该函数分析图中的单向街道并识别任何翻转的路段。
可用性
Version 3.8.0
Deprecated function.
版本2.0.0
官方 函数
Migration of pgr_analyzeOneWay
¶
Starting from v3.8.0
Before Deprecation: The following was calculated:
Number of potential problems in directionality
WHERE
Directionality problems were calculated based on codes.
Dead ends.
A routing problem can arise when from a vertex there is only a way on or a way out but not both:
Either saving or using directly pgr_extractVertices get the dead ends information and determine if the adjacent edge is one way or not.
In this example pgr_extractVertices has already been applied.
WITH
deadends AS (
SELECT (in_edges || out_edges)[1] as id
FROM vertices where array_length(in_edges || out_edges, 1) = 1)
SELECT * FROM edges JOIN deadends USING (id)
WHERE cost < 0 OR reverse_cost < 0;
id | source | target | cost | reverse_cost | capacity | reverse_capacity | x1 | y1 | x2 | y2 | geom
----+--------+--------+------+--------------+----------+------------------+----+----+----+----+------
(0 rows)
Bridges.
Another routing problem can arise when there is an edge of an undirected graph whose deletion increases its number of connected components, and the bridge is only one way.
To determine if the bridges are or not one way.
SELECT id, cost < 0 OR reverse_cost<0 AS is_OneWway
FROM pgr_bridges('SELECT id, source, target, cost, reverse_cost FROM edges')
JOIN edges ON (edge = id);
id | is_onewway
----+------------
1 | f
6 | f
7 | f
14 | f
17 | f
18 | f
(6 rows)
描述¶
单向路段的分析非常简单,但可以成为一种强大的工具,可以识别由于错误地设置路段方向而产生的一些潜在问题。 如果一个节点有从该节点出口的边并且没有边进入该节点,则该节点是`source` 。 相反,如果所有边都进入该节点但没有一条边退出该节点,则该节点是`sink`。 对于`source` 类型节点来说,逻辑上不可能存在,因为如果没有车辆进入该节点,则任何车辆都无法离开该节点。 同样,如果您有一个`sink`节点,那么您将在该节点上堆积无限数量的车辆,因为您可以进入它但不能离开它。
那么我们为什么要关心这些是否不可行呢? 如果边的方向被错误地反转,我们就可以准确地生成这些条件。 想象一下一条分开的高速公路,在北行车道上,有一个路段输入错误,或者可能是一系列多个路段输入错误,或者这可能发生在环岛上。 结果可能是 source 节点和/或`sink`节点。
因此,通过计算进入和退出每个节点的边数,我们可以识别 source 节点和 sink 节点,以便您可以查看网络的这些区域以进行修复和/或将问题报告给数据供应商。
先决条件
待分析的边表必须包含源列和目标列,其中填充了线段顶点的id以及对应的存储顶点信息的顶点表<edge_table>_vertices_pgr。
签名¶
[oneway, source, target, two_way_if_null]
TEXT
参数¶
- edge_table:
text
网络表的名称(可能包含模式名称)- s_in_rules:
text[]
source节点 输入 规则- s_out_rules:
text[]
source节点 输出 规则- t_in_rules:
text[]
target节点 输入 规则- t_out_rules:
text[]
target节点 输出 规则- oneway:
text``oneway 列名,网络表的名称。 默认值为``oneway
。- source:
text``网络表的Source列名称。 默认值为``source
。- target:
text``网络表的Target列名称。 默认值为 ``target
。- two_way_if_null:
boolean
将单向 NULL 值视为双向的标志。 默认值为true
。
函数返回:
OK
分析完成后。使用这个顶点表:<edge_table>_vertices_pgr。
完全填充顶点表的
ein
和eout
列。
FAIL
当分析因错误而未完成时。未找到顶点表。
未找到网络表所需的列或该列的类型不正确。
source 、 target 或 oneway 的名称相同。
这些规则被定义为文本字符串数组,如果与 oneway
值匹配,则 source或 target 输入 或 输出 条件将被视为 true
。
顶点表
顶点表的结构为:
- id:
bigint
顶点的标识符。- cnt:
integer
edge_table 中引用该顶点的顶点数。- chk:
integer
指示顶点可能有问题。- ein:
integer
edge_table 中引用该顶点作为传入的顶点数。- eout:
integer
Edge_table 中引用该顶点作为传出的顶点数。- the_geom:
geometry
顶点的点几何。
其他示例¶
ALTER TABLE edges ADD COLUMN dir TEXT;
ALTER TABLE
SELECT *, NULL::INTEGER ein, NULL::INTEGER eout INTO edges_vertices_pgr FROM vertices;
SELECT 17
UPDATE edges SET
dir = CASE WHEN (cost>0 AND reverse_cost>0) THEN 'B' /* both ways */
WHEN (cost>0 AND reverse_cost<0) THEN 'FT' /* direction of the LINESSTRING */
WHEN (cost<0 AND reverse_cost>0) THEN 'TF' /* reverse direction of the LINESTRING */
ELSE '' END;
UPDATE 18
/* unknown */
SELECT pgr_analyzeOneWay('edges',
ARRAY['', 'B', 'TF'],
ARRAY['', 'B', 'FT'],
ARRAY['', 'B', 'FT'],
ARRAY['', 'B', 'TF'],
oneway:='dir');
WARNING: pgr_analyzeoneway(text,text[],text[],text[],text[],boolean,text,text,text) deprecated function on v3.8.0
NOTICE: PROCESSING:
NOTICE: pgr_analyzeOneway('edges','{"",B,TF}','{"",B,FT}','{"",B,FT}','{"",B,TF}','dir','source','target',t)
NOTICE: Analyzing graph for one way street errors.
NOTICE: Analysis 25% complete ...
NOTICE: Analysis 50% complete ...
NOTICE: Analysis 75% complete ...
NOTICE: Analysis 100% complete ...
NOTICE: Found 0 potential problems in directionality
pgr_analyzeoneway
-------------------
OK
(1 row)
另请参阅¶
索引和表格