我面临一个子问题,我在其中获得了我所在城市的数据库(使用 postgis、pgrouting)。
我需要制作一条从 A 点到 B 点的路径/路线。如果这条路径长于 xx 公里,那么这条路径必须访问给定的“停止点”之一(我们称之为 C)。如果从 C 到 B 的路径长于 xx 公里,那么我们必须访问 C 和 B 之间某处的另一个中间“停止点”等。
最佳答案
这听起来像是伪代码这样的循环,我会将其转换为 plpgsql 存储过程:
A = start
S = stop
B = S
while true {
r = getRoute(A, B)
if length(r) > limit then
B = selectIntermediatepoint(A, B)
else if B == S then
break
else
A = B
B = S
}
关于algorithm - pgrouting/postgis - 搜索中间点的算法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44205016/