From 94c8c61a05c05d1709983ded3562047d8acb2180 Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Tue, 14 Sep 2010 16:40:11 +0000 Subject: [PATCH] New auxiliary method --- Contractor/SearchEngine.h | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/Contractor/SearchEngine.h b/Contractor/SearchEngine.h index b51d004a7..51acf6479 100644 --- a/Contractor/SearchEngine.h +++ b/Contractor/SearchEngine.h @@ -73,7 +73,7 @@ public: currentEdge = _graph->FindEdge( phantomNodes->startNode2, phantomNodes->startNode1 ); if(currentEdge != UINT_MAX && _graph->GetEdgeData(currentEdge).forward && phantomNodes->startRatio < phantomNodes->targetRatio) { //upperbound auf kantenlänge setzen -// cout << "start and target on same edge" << endl; + // cout << "start and target on same edge" << endl; onSameEdge = true; _upperbound = 10 * ApproximateDistance(phantomNodes->startCoord.lat, phantomNodes->startCoord.lon, phantomNodes->targetCoord.lat, phantomNodes->targetCoord.lon); } else if (currentEdge != UINT_MAX && !_graph->GetEdgeData(currentEdge).backward) { @@ -170,6 +170,30 @@ public: return _upperbound/10; } + unsigned int ComputeDistanceBetweenNodes(NodeID start, NodeID target) + { + _Heap * _forwardHeap = new _Heap(_graph->GetNumberOfNodes()); + _Heap * _backwardHeap = new _Heap(_graph->GetNumberOfNodes()); + NodeID middle = ( NodeID ) 0; + unsigned int _upperbound = std::numeric_limits::max(); + + _forwardHeap->Insert(start, 0, start); + _backwardHeap->Insert(target, 0, target); + + while(_forwardHeap->Size() + _backwardHeap->Size() > 0) + { + if ( _forwardHeap->Size() > 0 ) { + _RoutingStep( _forwardHeap, _backwardHeap, true, &middle, &_upperbound ); + } + if ( _backwardHeap->Size() > 0 ) { + _RoutingStep( _backwardHeap, _forwardHeap, false, &middle, &_upperbound ); + } + } + delete _forwardHeap; + delete _backwardHeap; + return _upperbound; + } + inline unsigned int findNearestNodeForLatLon(const _Coordinate& coord, _Coordinate& result) const { nodeHelpDesk->findNearestNodeIDForLatLon( coord, result );