您的位置:首页 > 其它

最短路径分析算法in PgRouting

2011-11-18 16:45 267 查看
最短路径分析算法inPgRouting
wangsh2011-11-18

PgRouting是开源路径分析算法库,其主要功能包含:

基于Dijkstra算法的最短路径(未使用启发式算法);

基于Astar算法最短路径:使用启发式算法求解大数据量路径算法;

基于Shooting-Star算法的最短路径:使用启发式算法接球转向限制;

旅行商算法(TSP):使用遗传算法求解(最多求解40个点);

计算驾车距离(Isolines)(没有找到相关代码)。


编译pgrouting(参考5)


我分析相关代码,并贴出核心部分:pgrouting最短路径核心算法基于bgl实现:

dijkstra.c:


staticintcompute_shortest_path(char*sql,intstart_vertex,intend_vertex,booldirected,boolhas_reverse_cost,path_element_t**path,int*path_count)
{

//此处省略代码n行
ret=boost_dijkstra(edges,total_tuples,start_vertex,end_vertex,
directed,has_reverse_cost,
path,path_count,&err_msg);
//此处省略代码n行

}


astar.c:

staticintcompute_shortest_path_astar(char*sql,intsource_vertex_id,inttarget_vertex_id,booldirected,boolhas_reverse_cost,path_element_t**path,int*path_count)
{

//此处省略代码n行

//callingC++A*function
ret=boost_astar(edges,total_tuples,source_vertex_id-v_min_id,target_vertex_id-v_min_id,directed,has_reverse_cost,path,path_count,&err_msg);
//此处省略代码n行

}


shooting_star.c

staticintcompute_shortest_path_shooting_star(char*sql,intsource_edge_id,inttarget_edge_id,booldirected,boolhas_reverse_cost,path_element_t**path,int*path_count)
{

//此处省略代码n行

ret=boost_shooting_star(edges,total_tuples,source_edge_id,target_edge_id,directed,has_reverse_cost,path,path_count,&err_msg,e_max_id);
//此处省略代码n行

}


tsp.c:

staticintsolve_tsp(char*sql,char*p_ids,
intsource,path_element_t*path)

{
//此处省略代码n行
//使用gaul库解决最多40个网络节点旅行商问题
ret=find_tsp_solution(total_tuples,DISTANCE,ids,
source,&fit,err_msg);
//此处省略代码n行
}

pgrouting是依赖bgl完成路径分析的,这也许就是bgl的强大之处,也许是到了深入学习bgl的时候了。




参考资料

1.PgRouting:http://www.pgrouting.org/
2.PgRouting文档介绍http://www.davidgis.fr/documentation/pgrouting-1.02/
3.使用pgRouting进行路径分析http://blog.csdn.net/warrenwyf/article/details/57033604.OSGEOpgroutinghttp://download.osgeo.org/pgrouting/5.Windows编译http://www.pgrouting.org/docs/howto/build_on_windows.html6.运用pgrouting求解最短路径http://2007.foss4g.org/presentations/view.php?abstract_id=84
7.PostLBShttp://en.giswiki.net/wiki/PostLBS

8.测试数据地址:http://wiki.openstreetmap.org/wiki/Planet.osm
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: