1

我有一个河网 shapefile,我使用 pgRouting 2.0 来路由它。我使用以下 sql 代码使其可路由,

alter table tc_15000_w_area add column source integer;
alter table tc_15000_w_area add column target integer;
select pgr_createTopology('tc_15000_w_area', 0.0001, 'the_geom', 'gid');

我想要的只是一个包含源/目标的可路由表,并且从所有源到目标的方向与河流的方向相同。这是示意图,

在此处输入图像描述

紫色线是河流

红点是节点(顶点)

红色数字是节点数

每个河段都有其源(节点)和目标

但我检查了结果表,我发现 node#11 始终是目标。这将使至少一个边缘具有错误的方向(流向)。

在此处输入图像描述

pgRouting 是否可以分配 source 和 target 的编号,使 source 到 target 的方向与流向相同?如果不能,我该怎么办?</p>

我在 sql 代码中使用了不同的容差,但得到了相同的结果,并且在 PostgreSQL 8.4 下使用 pgRouting 版本 1.x 也得到了相同的结果。

4

1 回答 1

0

Tolerance defines the minimum distance between two points that will get merged into a single point. For example if you have two point and the distance between them in datbase units is less than tolerance then they will be considered the same point and will get assigned the same number.

given an edge segment in your geometry table before you run pgr_createtopology() how do you know the direction of flow? based on the direction of digitization? We do not look at this in assigning numbers. Numbers are assigned on a first come first assigned basis as we process the edges.

To solve your problem, you probably need to write a node renumbering algorithm, that works something like this: 1. run pgr_createtopology() 2. from the network sink (ie: the drain of river network) do a depth first search and assign numbers in reverse order (largest from the drain, smaller as you move upstream).

I would create new node source and target columns for this. There might be a better way to solve this problem but it is not obvious at the moment.

于 2014-05-27T17:54:45.317 回答