pgRouting 测试手记

pgrouting 测试手记

一、测试环境
postgresql 9.2
postgis 2.0.3
pgrouting pg92-binaries-2.0.0devw32
特别注意:pgrouting的函数每一个版本的名称都是不同的,如shortest_path在其它版本中的命名不同,查找方式是在share的语句中搜索关键字path,此时就可以看到当关命名说明。
二、测试步骤
1、使用mapinfo pro整理有向数据
有向数据表中必须包含字段\
source
target
cost–设置几何长度
x1,x2,y1,y2

reverse–设置1000000
2、导入到数据库中

3、实验
SELECT * FROM shortest_path(‘SELECT objid as id, source::integer, target::integer, cost::double precision as cost

FROM mainroad_polyline’, 11, 18, false, false);

4、加反向
select a.seq, b.name, ST_AsText(b.geom) as geom,round(a.cost*1000) as cost, ‘1’ as directionid from (SELECT * FROM pgr_astar(‘SELECT

gid as id, source::integer, target::integer, cost::double precision as cost,x1, y1, x2, y2,reversecos as reverse_cost FROM path_polyline’,28,

33, false, false))as a,(select * from path_polyline) as b where a.id2=b.gid

转载自:https://blog.csdn.net/boy20000/article/details/9364059

You may also like...