Skip to content
Permalink
Browse files

Road graph plugin: don't crash with 25D input layers

Fix #9174
  • Loading branch information
m-kuhn committed Dec 9, 2013
1 parent c610f37 commit 758f5e5df9b31f9586af24f152a4dfefba1784ef
@@ -166,9 +166,11 @@ void QgsLineVectorLayerDirector::makeGraph( QgsGraphBuilderInterface *builder, c
while ( fit.nextFeature( feature ) )
{
QgsMultiPolyline mpl;
if ( feature.geometry()->wkbType() == QGis::WKBMultiLineString )
if ( feature.geometry()->wkbType() == QGis::WKBMultiLineString
|| feature.geometry()->wkbType() == QGis::WKBMultiLineString25D )
mpl = feature.geometry()->asMultiPolyline();
else if ( feature.geometry()->wkbType() == QGis::WKBLineString )
else if ( feature.geometry()->wkbType() == QGis::WKBLineString
|| feature.geometry()->wkbType() == QGis::WKBLineString25D )
mpl.push_back( feature.geometry()->asPolyline() );

QgsMultiPolyline::iterator mplIt;
@@ -37,6 +37,7 @@
#include <qgsfeature.h>
#include <qgsapplication.h>
#include <qgsvectorlayer.h>
#include <qgsmessagebar.h>

#include <qgsgraphdirector.h>
#include <qgsgraphbuilder.h>
@@ -278,17 +279,27 @@ QgsGraph* RgShortestPathWidget::getPath( QgsPoint& p1, QgsPoint& p2 )

QgsGraph *graph = builder.graph();

QVector< int > pointIdx( 0, 0 );
QVector< double > pointCost( 0, 0.0 );

int startVertexIdx = graph->findVertex( p1 );

int criterionNum = 0;
if ( mCriterionName->currentIndex() > 0 )
criterionNum = 1;

QgsGraph* shortestpathTree = QgsGraphAnalyzer::shortestTree( graph, startVertexIdx, criterionNum );
if ( graph->vertexCount() == 0 )
{
mPlugin->iface()->messageBar()->pushMessage(
tr( "Cannot calculate path" ),
tr( "The graph is empty. Does the layer have a supported geometry type?" ),
QgsMessageBar::WARNING,
mPlugin->iface()->messageTimeout()
);

delete graph;
return NULL;
}


QgsGraph* shortestpathTree = QgsGraphAnalyzer::shortestTree( graph, startVertexIdx, criterionNum );
delete graph;

if ( shortestpathTree->findVertex( p2 ) == -1 )

0 comments on commit 758f5e5

Please sign in to comment.
You can’t perform that action at this time.