最短路径分析算法in QGIS
wangsh 2011-11-20
qgis是一款稳定高效的gis桌面产品(参考1),而开发者提供了最短路径功能(参考2),其主要功能为:
两点间的最短路径;
最短路径Tree。
首先编译qgis(参考链接)
最短路径核心代码:代码位置:QGIS\src\analysis\network\qgsgraphanalyzer.cpp
void QgsGraphAnalyzer::shortestpath( const QgsGraph* source, int startPointIdx, int criterionNum, const QVector& destPointCost, QVector& cost, QgsGraph* treeResult )
{
// QMap< cost, vertexIdx > not_begin
// I use it and not create any struct or class.
QMap< double, int > not_begin;
QMap< double, int >::iterator it;
// QVector< QPair< cost, arc id > result
QVector< QPair< double, int > > result;
result.reserve( source->vertexCount() );
int i;
for ( i = 0; i < source->vertexCount(); ++i )
{ <