Skip to content

Commit

Permalink
Making via routes more stable
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis Luxen committed Jul 21, 2011
1 parent e937359 commit 83fca53
Show file tree
Hide file tree
Showing 11 changed files with 123 additions and 168 deletions.
1 change: 1 addition & 0 deletions DataStructures/BinaryHeap.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ class BinaryHeap {
}

void DecreaseKey( NodeID node, Weight weight ) {
assert( UINT_MAX != node );
const Key index = nodeIndex[node];
Key key = insertedNodes[index].key;
assert ( key != 0 );
Expand Down
2 changes: 1 addition & 1 deletion DataStructures/PhantomNodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
244 changes: 93 additions & 151 deletions DataStructures/SearchEngine.h

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions DataStructures/StaticGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ class StaticGraph {
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) {
Expand Down
2 changes: 1 addition & 1 deletion DataStructures/XMLParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class XMLParser : public BaseParser<_Node, _RawRestrictionContainer, _Way> {
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<std::string, std::string>) ) {
nodeCallback = *nodeCallbackPointer;
Expand Down
19 changes: 10 additions & 9 deletions Plugins/ObjectForPluginStruct.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,14 @@ or see http://www.gnu.org/licenses/agpl.txt.
#include "../DataStructures/StaticGraph.h"
#include "../Util/GraphLoader.h"

typedef StaticGraph<EdgeData>::InputEdge InputEdge;
typedef StaticGraph<EdgeData> QueryGraph;
typedef QueryGraph::InputEdge InputEdge;

struct ObjectsForQueryStruct {
NodeInformationHelpDesk * nodeHelpDesk;
std::vector<std::string> * 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
Expand All @@ -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<EdgeData>(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<std::string>();

Expand All @@ -67,10 +72,6 @@ struct ObjectsForQueryStruct {
delete graph;
delete nodeHelpDesk;
}

NodeInformationHelpDesk * nodeHelpDesk;
std::vector<std::string> * names;
StaticGraph<EdgeData> * graph;
};

#endif /* OBJECTFORPLUGINSTRUCT_H_ */
2 changes: 1 addition & 1 deletion Plugins/RoutePlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class RoutePlugin : public BasePlugin {
descriptorTable.Set("gpx", 2);
}

~RoutePlugin() {
virtual ~RoutePlugin() {
DELETE(sEngine);
}

Expand Down
4 changes: 2 additions & 2 deletions Plugins/ViaRoutePlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class ViaRoutePlugin : public BasePlugin {
descriptorTable.Set("gpx", 2);
}

~ViaRoutePlugin() {
virtual ~ViaRoutePlugin() {
for ( unsigned threadNum = 0; threadNum < threadData.size(); threadNum++ ) {
DELETE( threadData[threadNum] );
}
Expand Down Expand Up @@ -160,7 +160,7 @@ class ViaRoutePlugin : public BasePlugin {
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;
Expand Down
5 changes: 3 additions & 2 deletions Util/GraphLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ NodeID readDTMPGraphFromStream(istream &in, vector<EdgeT>& edgeList, vector<Node
break;
default:
weight = 0;
break;
}

weight = length*weight/3.6;
Expand Down Expand Up @@ -348,7 +349,7 @@ NodeID readDDSGGraphFromStream(istream &in, vector<EdgeT>& edgeList, vector<Node
}

template<typename EdgeT>
unsigned readHSGRFromStream(istream &in, vector<EdgeT> * edgeList) {
unsigned readHSGRFromStream(istream &in, vector<EdgeT> & edgeList) {
unsigned numberOfNodes = 0;
ExternalNodeMap nodeMap; nodeMap.set_empty_key(UINT_MAX);
while(!in.eof()) {
Expand Down Expand Up @@ -384,7 +385,7 @@ unsigned readHSGRFromStream(istream &in, vector<EdgeT> * edgeList) {
if(middle > numberOfNodes)
numberOfNodes = middle;

edgeList->push_back(g);
edgeList.push_back(g);
}
return numberOfNodes+1;
}
Expand Down
2 changes: 1 addition & 1 deletion createHierarchy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ or see http://www.gnu.org/licenses/agpl.txt.

using namespace std;

typedef ContractionCleanup::Edge::EdgeData EdgeData;
typedef DynamicGraph<EdgeData>::InputEdge InputEdge;
typedef StaticGraph<EdgeData>::InputEdge StaticEdge;
typedef BaseConfiguration ContractorConfiguration;
Expand Down Expand Up @@ -195,4 +194,5 @@ int main (int argc, char *argv[]) {
delete int2ExtNodeMap;

cout << "finished" << endl;
return 0;
}
5 changes: 5 additions & 0 deletions typedefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,9 @@ typedef NodeCoords<NodeID> 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_ */

0 comments on commit 83fca53

Please sign in to comment.