pgr_astar和可能的边缘(例如,锁着的门) [英] pgr_astar and impossible edges (e.g., locked doors)

查看:268
本文介绍了pgr_astar和可能的边缘(例如,锁着的门)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将postgresql/PostGIS与灌浆一起使用,我需要计算最短路径.在先前的pgrouting版本中,我使用的是shortest_path_astar.在我的路线图中,我有不可能的部分,例如上锁的门.我用过:

I'm using postgresql / PostGIS with pgrouting and I need to compute the shortest path. In a previous version of pgrouting, I was using shortest_path_astar. In my routing graph I had impossible segments, such as locked doors. I used:

SELECT id FROM shortest_path_astar('SELECT edge_id AS id, vertex_id1 AS source, vertex_id2 AS target, ' || '(CASE WHEN door = ''S'' THEN -1.0  ELSE  (length)  )  END)::float8 AS cost, ' || '(CASE WHEN door_rev = ''S'' THEN -1.0  ELSE  (length)  )  END )::float8 AS reverse_cost, ' || 'x1, y1, x2, y2 FROM edges', origin_node, destination_node, TRUE, TRUE)

基本上:当门关闭时(door ="S"),我将成本固定为-1.在该函数的新版本pgr_astar之前,它都可以正常工作.使用pgr_astar而不是shortest_path_astar,此查询会使服务器崩溃.

Basically: when door is closed (door = ''S''), I fixed the cost to -1. It worked fine till the new version of this function, pgr_astar. With pgr_astar instead of shortest_path_astar, this query crashes the server.

如何更改功能以避免崩溃?

How can I change my function to avoid the crash?

推荐答案

我最终使用了双向A *最短路径pgr_bdAstar.

I finally used pgr_bdAstar, bi-directional A* Shortest Path.

这篇关于pgr_astar和可能的边缘(例如,锁着的门)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆