@@ -324,9 +324,9 @@ void RgShortestPathWidget::findingPath()
324
324
cost += e.property ( 0 ).toDouble ();
325
325
time += e.property ( 1 ).toDouble ();
326
326
327
- p.push_front ( path.vertex ( e.in () ).point () );
327
+ p.push_front ( path.vertex ( e.inVertex () ).point () );
328
328
329
- stopVertexIdx = e.out ();
329
+ stopVertexIdx = e.outVertex ();
330
330
}
331
331
p.push_front ( p1 );
332
332
QList< QgsPoint>::iterator it;
@@ -357,39 +357,44 @@ void RgShortestPathWidget::clear()
357
357
358
358
void RgShortestPathWidget::exportPath ()
359
359
{
360
- /* RgExportDlg dlg( this );
361
- if ( !dlg.exec() )
362
- return;
360
+ RgExportDlg dlg ( this );
361
+ if ( !dlg.exec () )
362
+ return ;
363
363
364
- QgsPoint p1, p2;
365
- QgsGraph path;
366
- if ( !getPath( path, p1, p2 ) )
367
- return;
364
+ QgsPoint p1, p2;
365
+ QgsGraph path;
366
+ if ( !getPath ( & path, p1, p2 ) )
367
+ return ;
368
368
369
- QgsVectorLayer *vl = dlg.mapLayer();
370
- if ( vl == NULL )
371
- return;
369
+ QgsVectorLayer *vl = dlg.mapLayer ();
370
+ if ( vl == NULL )
371
+ return ;
372
372
373
- QgsCoordinateTransform ct( mPlugin->iface()->mapCanvas()->mapRenderer()->destinationCrs(),
373
+ QgsCoordinateTransform ct ( mPlugin ->iface ()->mapCanvas ()->mapRenderer ()->destinationCrs (),
374
374
vl->crs () );
375
+
376
+ int startVertexIdx = path.findVertex ( p1 );
377
+ int stopVertexIdx = path.findVertex ( p2 );
378
+
379
+ QgsPolyline p;
380
+ while ( startVertexIdx != stopVertexIdx )
381
+ {
382
+ QgsGraphArcIdList l = path.vertex ( stopVertexIdx ).inArc ();
383
+ if ( l.empty () )
384
+ break ;
385
+ const QgsGraphArc& e = path.arc ( l.front () );
386
+ p.push_front ( path.vertex ( e.inVertex () ).point () );
387
+ stopVertexIdx = e.outVertex ();
388
+ }
389
+ p.push_front ( p1 );
375
390
376
- while ( it != path.end() )
377
- {
378
- AdjacencyMatrixString::iterator it2 = it->second.begin();
379
- if ( it2 == it->second.end() )
380
- break;
381
- points.append( ct.transform( it2->first ) );
382
- it = path.find( it2->first );
383
- }
384
-
385
- vl->startEditing();
386
- QgsFeature f;
387
- f.setGeometry( QgsGeometry::fromPolyline( points ) );
388
- vl->addFeature( f );
389
- vl->updateExtents();
391
+ vl->startEditing ();
392
+ QgsFeature f;
393
+ f.setGeometry ( QgsGeometry::fromPolyline ( p ) );
394
+ vl->addFeature ( f );
395
+ vl->updateExtents ();
390
396
391
- mPlugin->iface()->mapCanvas()->update();
392
- */
397
+ mPlugin ->iface ()->mapCanvas ()->update ();
393
398
}
394
399
395
400
void RgShortestPathWidget::helpRequested ()
0 commit comments