From 83fca53d0483849d92c73faafd38e8ce786d1174 Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Thu, 21 Jul 2011 14:30:36 +0000 Subject: [PATCH] Making via routes more stable --- DataStructures/BinaryHeap.h | 1 + DataStructures/PhantomNodes.h | 2 +- DataStructures/SearchEngine.h | 246 ++++++++++++-------------------- DataStructures/StaticGraph.h | 5 + DataStructures/XMLParser.h | 2 +- Plugins/ObjectForPluginStruct.h | 19 +-- Plugins/RoutePlugin.h | 2 +- Plugins/ViaRoutePlugin.h | 4 +- Util/GraphLoader.h | 5 +- createHierarchy.cpp | 2 +- typedefs.h | 5 + 11 files changed, 124 insertions(+), 169 deletions(-) diff --git a/DataStructures/BinaryHeap.h b/DataStructures/BinaryHeap.h index 62dea7910..0a01baba4 100644 --- a/DataStructures/BinaryHeap.h +++ b/DataStructures/BinaryHeap.h @@ -209,6 +209,7 @@ public: } void DecreaseKey( NodeID node, Weight weight ) { + assert( UINT_MAX != node ); const Key index = nodeIndex[node]; Key key = insertedNodes[index].key; assert ( key != 0 ); diff --git a/DataStructures/PhantomNodes.h b/DataStructures/PhantomNodes.h index 5a4e0c364..b498da167 100644 --- a/DataStructures/PhantomNodes.h +++ b/DataStructures/PhantomNodes.h @@ -48,7 +48,7 @@ struct PhantomNodes { } bool PhantomsAreOnSameEdge() const { - return ((startPhantom.startNode == startPhantom.targetNode && targetPhantom.startNode == targetPhantom.targetNode ) || (startPhantom.startNode == targetPhantom.targetNode && targetPhantom.startNode == startPhantom.targetNode)); + return ((startPhantom.startNode == targetPhantom.startNode && startPhantom.targetNode == targetPhantom.targetNode ) || (startPhantom.startNode == targetPhantom.targetNode && targetPhantom.startNode == startPhantom.targetNode)); } bool AtLeastOnePhantomNodeIsUINTMAX() const { diff --git a/DataStructures/SearchEngine.h b/DataStructures/SearchEngine.h index c4a9522e9..e02402462 100644 --- a/DataStructures/SearchEngine.h +++ b/DataStructures/SearchEngine.h @@ -85,7 +85,7 @@ struct _InsertedNodes { }; -typedef BinaryHeap< NodeID, int, int, _HeapData, ArrayStorage > _Heap; +typedef BinaryHeap< NodeID, int, int, _HeapData, DenseStorage > _Heap; template class SearchEngine { @@ -108,102 +108,78 @@ public: } unsigned int ComputeRoute(PhantomNodes &phantomNodes, vector<_PathData > & path) { - bool onSameEdge = false; - bool onSameEdgeReversed = false; - bool startReverse = false; - bool targetReverse = false; + bool startEdgeIsReversedInGraph = false; + bool targetEdgeIsReversed = false; + + unsigned int _upperbound = UINT_MAX; + + if(!phantomNodes.AtLeastOnePhantomNodeIsUINTMAX()) + return _upperbound; + + EdgeID sourceEdgeID = _graph->FindEdgeIndicateIfReverse( phantomNodes.startPhantom.startNode, phantomNodes.startPhantom.targetNode, startEdgeIsReversedInGraph); + if(sourceEdgeID == UINT_MAX){ + return _upperbound; + } + + EdgeID targetEdgeID = _graph->FindEdgeIndicateIfReverse( phantomNodes.targetPhantom.startNode, phantomNodes.targetPhantom.targetNode, targetEdgeIsReversed); + if(targetEdgeID == UINT_MAX){ + return _upperbound; + } + _InsertedNodes _insertedNodes; _Heap _forwardHeap(nodeHelpDesk->getNumberOfNodes()); _Heap _backwardHeap(nodeHelpDesk->getNumberOfNodes()); NodeID middle = ( NodeID ) 0; - unsigned int _upperbound = std::numeric_limits::max(); - if(phantomNodes.startPhantom.startNode == UINT_MAX || phantomNodes.startPhantom.targetNode == UINT_MAX || phantomNodes.targetPhantom.startNode == UINT_MAX || phantomNodes.targetPhantom.targetNode == UINT_MAX) - return _upperbound; + if( phantomNodes.PhantomsAreOnSameEdge() ) { + const EdgeData& currentEdgeData = _graph->GetEdgeData(sourceEdgeID); + EdgeWeight w = currentEdgeData.distance; - if( (phantomNodes.startPhantom.startNode == phantomNodes.startPhantom.targetNode && phantomNodes.targetPhantom.startNode == phantomNodes.targetPhantom.targetNode ) || - (phantomNodes.startPhantom.startNode == phantomNodes.targetPhantom.targetNode && phantomNodes.targetPhantom.startNode == phantomNodes.startPhantom.targetNode) ) - { - bool reverse = false; - EdgeID currentEdge = _graph->FindEdge( phantomNodes.startPhantom.startNode, phantomNodes.startPhantom.targetNode ); - if(currentEdge == UINT_MAX){ - currentEdge = _graph->FindEdge( phantomNodes.startPhantom.targetNode, phantomNodes.startPhantom.startNode ); - reverse = true; - } - - if(currentEdge == UINT_MAX){ - return _upperbound; - } - - if(phantomNodes.startPhantom.ratio < phantomNodes.targetPhantom.ratio && _graph->GetEdgeData(currentEdge).forward) { - onSameEdge = true; - _upperbound = 10 * ApproximateDistance(phantomNodes.startPhantom.location.lat, phantomNodes.startPhantom.location.lon, phantomNodes.targetPhantom.location.lat, phantomNodes.targetPhantom.location.lon); - } else if(phantomNodes.startPhantom.ratio > phantomNodes.targetPhantom.ratio && _graph->GetEdgeData(currentEdge).backward && !reverse) - { - onSameEdge = true; - _upperbound = 10 * ApproximateDistance(phantomNodes.startPhantom.location.lat, phantomNodes.startPhantom.location.lon, phantomNodes.targetPhantom.location.lat, phantomNodes.targetPhantom.location.lon); - } else if(phantomNodes.startPhantom.ratio < phantomNodes.targetPhantom.ratio && _graph->GetEdgeData(currentEdge).backward) { - onSameEdge = true; - _upperbound = 10 * ApproximateDistance(phantomNodes.startPhantom.location.lat, phantomNodes.startPhantom.location.lon, phantomNodes.targetPhantom.location.lat, phantomNodes.targetPhantom.location.lon); - } else if(phantomNodes.startPhantom.ratio > phantomNodes.targetPhantom.ratio && _graph->GetEdgeData(currentEdge).forward && _graph->GetEdgeData(currentEdge).backward) { - onSameEdge = true; - _upperbound = 10 * ApproximateDistance(phantomNodes.startPhantom.location.lat, phantomNodes.startPhantom.location.lon, phantomNodes.targetPhantom.location.lat, phantomNodes.targetPhantom.location.lon); - } else if(phantomNodes.startPhantom.ratio > phantomNodes.targetPhantom.ratio) { - onSameEdgeReversed = true; - - EdgeWeight w = _graph->GetEdgeData( currentEdge ).distance; - _forwardHeap.Insert(phantomNodes.targetPhantom.startNode, absDouble( w*phantomNodes.startPhantom.ratio), phantomNodes.targetPhantom.startNode); - _insertedNodes.ForwInsert(phantomNodes.targetPhantom.startNode); - _backwardHeap.Insert(phantomNodes.startPhantom.startNode, absDouble( w-w*phantomNodes.targetPhantom.ratio), phantomNodes.startPhantom.startNode); - _insertedNodes.BackInsert(phantomNodes.startPhantom.startNode); - } - } - - if(phantomNodes.startPhantom.startNode != UINT_MAX) { - EdgeID edge = _graph->FindEdge( phantomNodes.startPhantom.startNode, phantomNodes.startPhantom.targetNode); - if(edge == UINT_MAX){ - edge = _graph->FindEdge( phantomNodes.startPhantom.targetNode, phantomNodes.startPhantom.startNode ); - if(edge == UINT_MAX){ - return _upperbound; + //check if target is reachable from start on same edge + if(currentEdgeData.forward && currentEdgeData.backward) { + _upperbound = absDouble( w*phantomNodes.targetPhantom.ratio); + return _upperbound/10; + } else { + if((startEdgeIsReversedInGraph && (phantomNodes.startPhantom.ratio > phantomNodes.targetPhantom.ratio)) || (!startEdgeIsReversedInGraph && (phantomNodes.startPhantom.ratio < phantomNodes.targetPhantom.ratio))) { + _backwardHeap.Insert(phantomNodes.startPhantom.startNode, absDouble( w*phantomNodes.startPhantom.ratio), phantomNodes.startPhantom.startNode); + _insertedNodes.BackInsert(phantomNodes.startPhantom.startNode); + _forwardHeap.Insert(phantomNodes.startPhantom.targetNode, absDouble( w-w*phantomNodes.startPhantom.ratio), phantomNodes.startPhantom.targetNode); + _insertedNodes.ForwInsert(phantomNodes.startPhantom.targetNode); + } else { + _upperbound = absDouble( w*phantomNodes.targetPhantom.ratio); + return _upperbound/10; } - startReverse = true; - } - const EdgeData& ed = _graph->GetEdgeData(edge); - EdgeWeight w = ed.distance; - - if( (ed.backward && !startReverse) || (ed.forward && startReverse) ){ - _forwardHeap.Insert(phantomNodes.startPhantom.startNode, absDouble( w*phantomNodes.startPhantom.ratio), phantomNodes.startPhantom.startNode); - _insertedNodes.ForwInsert(phantomNodes.startPhantom.startNode); - } - if( (ed.backward && startReverse) || (ed.forward && !startReverse) ) { - _forwardHeap.Insert(phantomNodes.startPhantom.targetNode, absDouble(w-w*phantomNodes.startPhantom.ratio), phantomNodes.startPhantom.targetNode); - _insertedNodes.ForwInsert(phantomNodes.startPhantom.targetNode); } } - if(phantomNodes.startPhantom.targetNode!= UINT_MAX && !onSameEdgeReversed) { - EdgeID edge = _graph->FindEdge( phantomNodes.targetPhantom.startNode, phantomNodes.targetPhantom.targetNode); - if(edge == UINT_MAX){ - edge = _graph->FindEdge( phantomNodes.targetPhantom.targetNode, phantomNodes.targetPhantom.startNode); - targetReverse = true; - } - if(edge == UINT_MAX){ - return _upperbound; - } - const EdgeData& ed = _graph->GetEdgeData(edge); - EdgeWeight w = ed.distance; + //insert start and/or target node of start edge + const EdgeData& sourceEdgeData = _graph->GetEdgeData(sourceEdgeID); + EdgeWeight sw = sourceEdgeData.distance; - if( (ed.backward && !targetReverse) || (ed.forward && targetReverse) ) { - _backwardHeap.Insert(phantomNodes.targetPhantom.targetNode, absDouble( w*phantomNodes.targetPhantom.ratio), phantomNodes.targetPhantom.targetNode); - _insertedNodes.BackInsert(phantomNodes.targetPhantom.targetNode); - } - if( (ed.backward && targetReverse) || (ed.forward && !targetReverse) ) { - _backwardHeap.Insert(phantomNodes.targetPhantom.startNode, absDouble(w-w*phantomNodes.targetPhantom.ratio), phantomNodes.targetPhantom.startNode); - _insertedNodes.BackInsert(phantomNodes.targetPhantom.startNode); - } + if( (sourceEdgeData.backward && !startEdgeIsReversedInGraph) || (sourceEdgeData.forward && startEdgeIsReversedInGraph) ){ + _forwardHeap.Insert(phantomNodes.startPhantom.startNode, absDouble( sw*phantomNodes.startPhantom.ratio), phantomNodes.startPhantom.startNode); + _insertedNodes.ForwInsert(phantomNodes.startPhantom.startNode); } + if( (sourceEdgeData.backward && startEdgeIsReversedInGraph) || (sourceEdgeData.forward && !startEdgeIsReversedInGraph) ) { + _forwardHeap.Insert(phantomNodes.startPhantom.targetNode, absDouble(sw-sw*phantomNodes.startPhantom.ratio), phantomNodes.startPhantom.targetNode); + _insertedNodes.ForwInsert(phantomNodes.startPhantom.targetNode); + } + + //insert start and/or target node of target edge id + const EdgeData& targetEdgeData = _graph->GetEdgeData(targetEdgeID); + EdgeWeight tw = targetEdgeData.distance; + + if( (targetEdgeData.backward && !targetEdgeIsReversed) || (targetEdgeData.forward && targetEdgeIsReversed) ) { + _backwardHeap.Insert(phantomNodes.targetPhantom.targetNode, absDouble( tw*phantomNodes.targetPhantom.ratio), phantomNodes.targetPhantom.targetNode); + _insertedNodes.BackInsert(phantomNodes.targetPhantom.targetNode); + } + if( (targetEdgeData.backward && targetEdgeIsReversed) || (targetEdgeData.forward && !targetEdgeIsReversed) ) { + _backwardHeap.Insert(phantomNodes.targetPhantom.startNode, absDouble(tw-tw*phantomNodes.targetPhantom.ratio), phantomNodes.targetPhantom.startNode); + _insertedNodes.BackInsert(phantomNodes.targetPhantom.startNode); + } + while(_forwardHeap.Size() + _backwardHeap.Size() > 0) { if ( _forwardHeap.Size() > 0 ) { @@ -214,8 +190,7 @@ public: } } - - if ( _upperbound == std::numeric_limits< unsigned int >::max() || onSameEdge ) { + if ( _upperbound == UINT_MAX ) { return _upperbound; } @@ -226,7 +201,7 @@ public: pathNode = _forwardHeap.GetData( pathNode ).parent; packedPath.push_front( pathNode ); } - // NodeID realStart = pathNode; + packedPath.push_back( middle ); pathNode = middle; @@ -241,54 +216,47 @@ public: } packedPath.clear(); - 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(); + _Heap _forwardHeap(_graph->GetNumberOfNodes()); + _Heap _backwardHeap(_graph->GetNumberOfNodes()); + NodeID middle(UINT_MAX); + unsigned int _upperbound = UINT_MAX; - _forwardHeap->Insert(start, 0, start); - _backwardHeap->Insert(target, 0, target); + _forwardHeap.Insert(start, 0, start); + _backwardHeap.Insert(target, 0, target); - while(_forwardHeap->Size() + _backwardHeap->Size() > 0) - { - if ( _forwardHeap->Size() > 0 ) { + while(_forwardHeap.Size() + _backwardHeap.Size() > 0) { + if ( _forwardHeap.Size() > 0 ) { _RoutingStep( _forwardHeap, _backwardHeap, true, &middle, &_upperbound ); } - if ( _backwardHeap->Size() > 0 ) { + if ( _backwardHeap.Size() > 0 ) { _RoutingStep( _backwardHeap, _forwardHeap, false, &middle, &_upperbound ); } } - delete _forwardHeap; - delete _backwardHeap; return _upperbound; } unsigned int ComputeDistanceBetweenNodesWithStats(NodeID start, NodeID target, _Statistics& stats) { - _Heap * _forwardHeap = new _Heap(_graph->GetNumberOfNodes()); - _Heap * _backwardHeap = new _Heap(_graph->GetNumberOfNodes()); - NodeID middle = ( NodeID ) 0; - unsigned int _upperbound = std::numeric_limits::max(); + _Heap _forwardHeap(_graph->GetNumberOfNodes()); + _Heap _backwardHeap(_graph->GetNumberOfNodes()); + NodeID middle(UINT_MAX); + unsigned int _upperbound = UINT_MAX; - _forwardHeap->Insert(start, 0, start); - _backwardHeap->Insert(target, 0, target); + _forwardHeap.Insert(start, 0, start); + _backwardHeap.Insert(target, 0, target); stats.insertedNodes += 2; - while(_forwardHeap->Size() + _backwardHeap->Size() > 0) - { - if ( _forwardHeap->Size() > 0 ) { + while(_forwardHeap.Size() + _backwardHeap.Size() > 0) { + if ( _forwardHeap.Size() > 0 ) { _RoutingStepWithStats( _forwardHeap, _backwardHeap, true, &middle, &_upperbound, stats ); } - if ( _backwardHeap->Size() > 0 ) { + if ( _backwardHeap.Size() > 0 ) { _RoutingStepWithStats( _backwardHeap, _forwardHeap, false, &middle, &_upperbound, stats ); } } - delete _forwardHeap; - delete _backwardHeap; return _upperbound; } @@ -309,13 +277,14 @@ public: } inline NodeID GetNameIDForOriginDestinationNodeID(NodeID s, NodeID t) const { + //INFO("Getting nameID for s=" << s << " and t=" << t); if(s==t) return 0; EdgeID e = _graph->FindEdge( s, t ); if(e == UINT_MAX) e = _graph->FindEdge( t, s ); if(UINT_MAX == e) { - INFO("edge not found for start " << s << ", target " << t) + // INFO("edge not found for start " << s << ", target " << t) return 0; } assert(e != UINT_MAX); @@ -342,7 +311,6 @@ public: return ( GetEscapedNameForNameID(nameID) ); } - inline std::string GetEscapedNameForNameID(const NodeID nameID) const { return ( (nameID >= _names->size() || nameID == 0) ? std::string("") : HTMLEntitize(_names->at(nameID)) ); } @@ -357,9 +325,9 @@ public: return ed.type; } - inline void RegisterThread(const unsigned k, const unsigned v) { - nodeHelpDesk->RegisterThread(k,v); - } + // inline void RegisterThread(const unsigned k, const unsigned v) { + // nodeHelpDesk->RegisterThread(k,v); + // } private: inline void _RoutingStep(_Heap& _forwardHeap, _Heap &_backwardHeap, const bool& forwardDirection, NodeID * middle, unsigned int * _upperbound) { @@ -379,14 +347,10 @@ private: for ( typename GraphT::EdgeIterator edge = _graph->BeginEdges( node ); edge < _graph->EndEdges(node); edge++ ) { - //const EdgeData& ed = _graph->GetEdgeData(edge); - // if(!ed.shortcut) - // continue; const NodeID to = _graph->GetTarget(edge); const EdgeWeight edgeWeight = _graph->GetEdgeData(edge).distance; assert( edgeWeight > 0 ); - //const int toDistance = distance + edgeWeight; //Stalling bool backwardDirectionFlag = (!forwardDirection) ? _graph->GetEdgeData(edge).forward : _graph->GetEdgeData(edge).backward; @@ -419,18 +383,6 @@ private: //new parent } } - // if(forwardDirection ? ed.forward : ed.backward ) { - // //New Node discovered -> Add to Heap + Node Info Storage - // if ( !_forwardHeap->WasInserted( to ) ) { - // _forwardHeap->Insert( to, toDistance, node ); - // } - // //Found a shorter Path -> Update distance - // else if ( toDistance < _forwardHeap->GetKey( to ) ) { - // _forwardHeap->GetData( to ).parent = node; - // _forwardHeap->DecreaseKey( to, toDistance ); - // //new parent - // } - // } } } @@ -487,33 +439,24 @@ private: } } - bool _UnpackEdge( const NodeID source, const NodeID target, std::vector< _PathData >& path ) { + inline bool _UnpackEdge( const NodeID source, const NodeID target, std::vector< _PathData >& path ) { assert(source != target); //find edge first. bool forward = true; typename GraphT::EdgeIterator smallestEdge = SPECIAL_EDGEID; EdgeWeight smallestWeight = UINT_MAX; - for(typename GraphT::EdgeIterator eit = _graph->BeginEdges(source); eit < _graph->EndEdges(source); eit++) - { + for(typename GraphT::EdgeIterator eit = _graph->BeginEdges(source); eit < _graph->EndEdges(source); eit++) { const EdgeWeight weight = _graph->GetEdgeData(eit).distance; - { - if(_graph->GetTarget(eit) == target && weight < smallestWeight && _graph->GetEdgeData(eit).forward) - { - smallestEdge = eit; smallestWeight = weight; - } + if(_graph->GetTarget(eit) == target && weight < smallestWeight && _graph->GetEdgeData(eit).forward) { + smallestEdge = eit; smallestWeight = weight; } } - if(smallestEdge == SPECIAL_EDGEID) - { - for(typename GraphT::EdgeIterator eit = _graph->BeginEdges(target); eit < _graph->EndEdges(target); eit++) - { + if(smallestEdge == SPECIAL_EDGEID) { + for(typename GraphT::EdgeIterator eit = _graph->BeginEdges(target); eit < _graph->EndEdges(target); eit++) { const EdgeWeight weight = _graph->GetEdgeData(eit).distance; - { - if(_graph->GetTarget(eit) == source && weight < smallestWeight && _graph->GetEdgeData(eit).backward) - { - smallestEdge = eit; smallestWeight = weight; - forward = false; - } + if(_graph->GetTarget(eit) == source && weight < smallestWeight && _graph->GetEdgeData(eit).backward) { + smallestEdge = eit; smallestWeight = weight; + forward = false; } } } @@ -521,8 +464,7 @@ private: assert(smallestWeight != SPECIAL_EDGEID); //no edge found. This should not happen at all! const EdgeData& ed = _graph->GetEdgeData(smallestEdge); - if(ed.shortcut) - {//unpack + if(ed.shortcut) {//unpack const NodeID middle = ed.middleName.middle; _UnpackEdge(source, middle, path); _UnpackEdge(middle, target, path); diff --git a/DataStructures/StaticGraph.h b/DataStructures/StaticGraph.h index 158864f42..fd4f92018 100644 --- a/DataStructures/StaticGraph.h +++ b/DataStructures/StaticGraph.h @@ -126,6 +126,11 @@ public: return smallestEdge; } + EdgeIterator FindEdgeInEitherDirection( const NodeIterator &from, const NodeIterator &to ) const { + EdgeIterator tmp = FindEdge( from, to ); + return (UINT_MAX != tmp ? tmp : FindEdge( to, from )); + } + EdgeIterator FindEdgeIndicateIfReverse( const NodeIterator &from, const NodeIterator &to, bool & result ) const { EdgeIterator tmp = FindEdge( from, to ); if(UINT_MAX == tmp) { diff --git a/DataStructures/XMLParser.h b/DataStructures/XMLParser.h index a65e4edf9..a0f3b3df9 100644 --- a/DataStructures/XMLParser.h +++ b/DataStructures/XMLParser.h @@ -35,7 +35,7 @@ public: WARN("Parsing plain .osm/.osm.bz2 is deprecated. Switch to .pbf"); inputReader = inputReaderFactory(filename); } - ~XMLParser() {} + virtual ~XMLParser() {} bool RegisterCallbacks(bool (*nodeCallbackPointer)(_Node), bool (*restrictionCallbackPointer)(_RawRestrictionContainer), bool (*wayCallbackPointer)(_Way), bool (*addressCallbackPointer)(_Node, HashTable) ) { nodeCallback = *nodeCallbackPointer; diff --git a/Plugins/ObjectForPluginStruct.h b/Plugins/ObjectForPluginStruct.h index 6b6efd347..c425eae68 100644 --- a/Plugins/ObjectForPluginStruct.h +++ b/Plugins/ObjectForPluginStruct.h @@ -25,9 +25,14 @@ or see http://www.gnu.org/licenses/agpl.txt. #include "../DataStructures/StaticGraph.h" #include "../Util/GraphLoader.h" -typedef StaticGraph::InputEdge InputEdge; +typedef StaticGraph QueryGraph; +typedef QueryGraph::InputEdge InputEdge; struct ObjectsForQueryStruct { + NodeInformationHelpDesk * nodeHelpDesk; + std::vector * names; + QueryGraph * graph; + ObjectsForQueryStruct(std::string hsgrPath, std::string ramIndexPath, std::string fileIndexPath, std::string nodesPath, std::string namesPath, std::string psd = "route") { std::cout << "[objects] loading query data structures ..." << std::flush; //Init nearest neighbor data structure @@ -37,14 +42,14 @@ struct ObjectsForQueryStruct { ifstream hsgrInStream(hsgrPath.c_str(), ios::binary); //Deserialize road network graph - std::vector< InputEdge> * edgeList = new std::vector< InputEdge>(); + std::vector< InputEdge> edgeList; readHSGRFromStream(hsgrInStream, edgeList); - graph = new StaticGraph(nodeHelpDesk->getNumberOfNodes()-1, *edgeList); - delete edgeList; + graph = new QueryGraph(nodeHelpDesk->getNumberOfNodes()-1, edgeList); + std::vector< InputEdge >().swap( edgeList ); //free memory //deserialize street name list ifstream namesInStream(namesPath.c_str(), ios::binary); - unsigned size = 0; + unsigned size(0); namesInStream.read((char *)&size, sizeof(unsigned)); names = new std::vector(); @@ -67,10 +72,6 @@ struct ObjectsForQueryStruct { delete graph; delete nodeHelpDesk; } - - NodeInformationHelpDesk * nodeHelpDesk; - std::vector * names; - StaticGraph * graph; }; #endif /* OBJECTFORPLUGINSTRUCT_H_ */ diff --git a/Plugins/RoutePlugin.h b/Plugins/RoutePlugin.h index ff6d0809d..c0092c384 100644 --- a/Plugins/RoutePlugin.h +++ b/Plugins/RoutePlugin.h @@ -57,7 +57,7 @@ public: descriptorTable.Set("gpx", 2); } - ~RoutePlugin() { + virtual ~RoutePlugin() { DELETE(sEngine); } diff --git a/Plugins/ViaRoutePlugin.h b/Plugins/ViaRoutePlugin.h index 0cefd3eb4..a4bb8b6d5 100644 --- a/Plugins/ViaRoutePlugin.h +++ b/Plugins/ViaRoutePlugin.h @@ -84,7 +84,7 @@ public: descriptorTable.Set("gpx", 2); } - ~ViaRoutePlugin() { + virtual ~ViaRoutePlugin() { for ( unsigned threadNum = 0; threadNum < threadData.size(); threadNum++ ) { DELETE( threadData[threadNum] ); } @@ -160,7 +160,7 @@ public: std::vector< _PathData > path; int distanceOfSegment = threadData[omp_get_thread_num()]->sEngine->ComputeRoute(segmentPhantomNodes, path); - if(UINT_MAX == threadData[omp_get_thread_num()]->distanceOfSegment || path.empty()) { + if(UINT_MAX == threadData[omp_get_thread_num()]->distanceOfSegment ) { errorOccurredFlag = true; cout << "Error occurred, path not found" << endl; distance = UINT_MAX; diff --git a/Util/GraphLoader.h b/Util/GraphLoader.h index dbcebf6b0..831ac2cb2 100644 --- a/Util/GraphLoader.h +++ b/Util/GraphLoader.h @@ -247,6 +247,7 @@ NodeID readDTMPGraphFromStream(istream &in, vector& edgeList, vector& edgeList, vector -unsigned readHSGRFromStream(istream &in, vector * edgeList) { +unsigned readHSGRFromStream(istream &in, vector & edgeList) { unsigned numberOfNodes = 0; ExternalNodeMap nodeMap; nodeMap.set_empty_key(UINT_MAX); while(!in.eof()) { @@ -384,7 +385,7 @@ unsigned readHSGRFromStream(istream &in, vector * edgeList) { if(middle > numberOfNodes) numberOfNodes = middle; - edgeList->push_back(g); + edgeList.push_back(g); } return numberOfNodes+1; } diff --git a/createHierarchy.cpp b/createHierarchy.cpp index f9acb3082..77b418d94 100644 --- a/createHierarchy.cpp +++ b/createHierarchy.cpp @@ -52,7 +52,6 @@ or see http://www.gnu.org/licenses/agpl.txt. using namespace std; -typedef ContractionCleanup::Edge::EdgeData EdgeData; typedef DynamicGraph::InputEdge InputEdge; typedef StaticGraph::InputEdge StaticEdge; typedef BaseConfiguration ContractorConfiguration; @@ -195,4 +194,5 @@ int main (int argc, char *argv[]) { delete int2ExtNodeMap; cout << "finished" << endl; + return 0; } diff --git a/typedefs.h b/typedefs.h index dcf98f18c..48cea13a5 100644 --- a/typedefs.h +++ b/typedefs.h @@ -67,4 +67,9 @@ typedef NodeCoords NodeInfo; typedef ContractionCleanup::Edge::EdgeData EdgeData; #include "DataStructures/DynamicGraph.h" +//Fix to make Eclipse 3.7 happy +#ifndef __TIMESTAMP__ +#define __TIMESTAMP__ "unknown date" +#endif + #endif /* TYPEDEFS_H_ */