diff --git a/Contractor/ContractionCleanup.h b/Contractor/ContractionCleanup.h index 2486a8e40..bc9f9c4e4 100644 --- a/Contractor/ContractionCleanup.h +++ b/Contractor/ContractionCleanup.h @@ -66,8 +66,7 @@ public: NodeID target; struct EdgeData { NodeID via; - unsigned nameID1; - unsigned nameID2; + unsigned nameID; int distance; bool shortcut; bool forward; @@ -91,7 +90,7 @@ public: bool operator== ( const Edge& right ) const { return ( source == right.source && target == right.target && data.distance == right.data.distance && data.shortcut == right.data.shortcut && data.forward == right.data.forward && data.backward == right.data.backward - && data.via == right.data.via && data.nameID1 == right.data.nameID1 && data.nameID2 == right.data.nameID2 + && data.via == right.data.via && data.nameID == right.data.nameID ); } }; diff --git a/Contractor/Contractor.h b/Contractor/Contractor.h index 9daa36865..c8d9568e8 100644 --- a/Contractor/Contractor.h +++ b/Contractor/Contractor.h @@ -304,7 +304,7 @@ public: newEdge.data.distance = data.distance; newEdge.data.shortcut = data.shortcut; newEdge.data.via = data.via; - newEdge.data.nameID1 = data.nameID; + newEdge.data.nameID = data.nameID; newEdge.data.turnInstruction = data.turnInstruction; newEdge.data.forward = data.forward; newEdge.data.backward = data.backward; @@ -495,6 +495,7 @@ private: bool _UpdateNeighbours( std::vector< double >* priorities, std::vector< _PriorityData >* const nodeData, _ThreadData* const data, NodeID node ) { std::vector< NodeID >& neighbours = data->neighbours; neighbours.clear(); + std::vector< NodeID>().swap(neighbours); //find all neighbours for ( _DynamicGraph::EdgeIterator e = _graph->BeginEdges( node ) ; e < _graph->EndEdges( node ) ; ++e ) { @@ -521,6 +522,7 @@ private: std::vector< NodeID >& neighbours = data->neighbours; neighbours.clear(); + std::vector< NodeID>().swap(neighbours); for ( _DynamicGraph::EdgeIterator e = _graph->BeginEdges( node ) ; e < _graph->EndEdges( node ) ; ++e ) { const NodeID target = _graph->GetTarget( e ); diff --git a/Contractor/EdgeBasedGraphFactory.cpp b/Contractor/EdgeBasedGraphFactory.cpp index e7499c722..b461ddf24 100644 --- a/Contractor/EdgeBasedGraphFactory.cpp +++ b/Contractor/EdgeBasedGraphFactory.cpp @@ -103,7 +103,7 @@ void EdgeBasedGraphFactory::Run() { //Loop over all nodes u. Three nested loop look super-linear, but we are dealing with a number linear in the turns only. for(_NodeBasedDynamicGraph::NodeIterator u = 0; u < _nodeBasedGraph->GetNumberOfNodes(); ++u ) { //loop over all adjacent edge (u,v) - while(restrictionIterator->fromNode < u && inputRestrictions.end() != restrictionIterator) { + while(inputRestrictions.end() != restrictionIterator && restrictionIterator->fromNode < u) { ++restrictionIterator; } for(_NodeBasedDynamicGraph::EdgeIterator e1 = _nodeBasedGraph->BeginEdges(u); e1 < _nodeBasedGraph->EndEdges(u); ++e1) { @@ -115,7 +115,7 @@ void EdgeBasedGraphFactory::Run() { //if (u,v,w) is a forbidden turn, continue bool isTurnProhibited = false; if( u != w ) { //only add an edge if turn is not a U-turn - if(u == restrictionIterator->fromNode) { + if(restrictionIterator != inputRestrictions.end() && u == restrictionIterator->fromNode) { std::vector<_Restriction>::iterator secondRestrictionIterator = restrictionIterator; do { if( v == secondRestrictionIterator->viaNode && w == secondRestrictionIterator->toNode) { diff --git a/DataStructures/ExtractorCallBacks.h b/DataStructures/ExtractorCallBacks.h index 5dfc69d96..6d2c5442b 100644 --- a/DataStructures/ExtractorCallBacks.h +++ b/DataStructures/ExtractorCallBacks.h @@ -135,7 +135,7 @@ public: } } - if("yes" == accessClass) + if("yes" == accessClass || "designated" == accessClass) w.access = true; else if("no" == accessClass) w.access = false; @@ -164,7 +164,7 @@ public: w.type = 1; //Get the unique identifier for the street name - StringMap::const_iterator strit = stringMap->find(w.name); + const StringMap::const_iterator strit = stringMap->find(w.name); if(strit == stringMap->end()) { w.nameID = externalMemory->nameVector.size(); externalMemory->nameVector.push_back(w.name); diff --git a/DataStructures/SearchEngine.h b/DataStructures/SearchEngine.h index 26da8fc28..c26eff91d 100644 --- a/DataStructures/SearchEngine.h +++ b/DataStructures/SearchEngine.h @@ -256,7 +256,7 @@ private: return false; } else { assert(!ed.shortcut); - path.push_back(_PathData(ed.via, ed.nameID1, ed.turnInstruction, ed.distance) ); + path.push_back(_PathData(ed.via, ed.nameID, ed.turnInstruction, ed.distance) ); return true; } } diff --git a/Plugins/ObjectForPluginStruct.h b/Plugins/ObjectForPluginStruct.h index a6c05c17b..945ae7fc8 100644 --- a/Plugins/ObjectForPluginStruct.h +++ b/Plugins/ObjectForPluginStruct.h @@ -58,7 +58,7 @@ struct ObjectsForQueryStruct { names = new std::vector(); char buf[1024]; - for(unsigned i = 0; i < size; i++) { + for(unsigned i = 0; i < size; ++i) { unsigned sizeOfString = 0; namesInStream.read((char *)&sizeOfString, sizeof(unsigned)); memset(buf, 0, 1024*sizeof(char)); diff --git a/README.TXT b/README.TXT index a6f940396..e909f5a65 100644 --- a/README.TXT +++ b/README.TXT @@ -6,7 +6,7 @@ installing dependencies and running make should suffice. Make sure the following dependencies are installed: - Boost 1.41+ - - sparsehash 1.4+ + - sparsehash 1.4+ - g++ 4.2+ - libxml2 2.7+ - scons 2.10+ @@ -77,11 +77,12 @@ preprocessing runs in three steps, all done by seperate programs. necessary, because the osm data is not made to support fast routing out of the box. The output of the step is a file called 'file.osrm' -'osrm-prepare file.osrm' preprocesses the road network and computes additional -information that is exploited later to speed up the path computation. The output -of this step consists of two file 'file.osrm.hsgr' and 'file.osrm.nodes'. The first -file is the so-called hierarchy that speeds up the path computation while the -latter one carries (among other things) geographical information. +'osrm-prepare file.osrm file.restrictions' preprocesses the road network and +computes additional information that is exploited later to speed up the path +computation. The output of this step consists of two file 'file.osrm.hsgr' and +'file.osrm.nodes'. The first file is the so-called hierarchy that speeds up the +path computation while the latter one carries (among other things) geographical +information. 'osrm-routed' starts the server on TCP Port 5000. The server communicates over http and can be queried by any browser or http-capable diff --git a/Util/GraphLoader.h b/Util/GraphLoader.h index e1d4d9464..30074d577 100644 --- a/Util/GraphLoader.h +++ b/Util/GraphLoader.h @@ -48,17 +48,17 @@ NodeID readOSRMGraphFromStream(istream &in, vector& edgeList, vector> n; - VERBOSE(cout << "Importing n = " << n << " nodes ..." << flush;) - for (NodeID i=0; i> id >> ycoord >> xcoord; int2ExtNodeMap->push_back(NodeInfo(xcoord, ycoord, id)); ext2IntNodeMap.insert(make_pair(id, i)); } in >> m; - VERBOSE(cout << " and " << m << " edges ..." << flush;) + DEBUG(" and " << m << " edges ..."); edgeList.reserve(m); - for (EdgeID i=0; i& edgeList, vector" << source << "," << target << "," << length << "," << dir << "," << weight << endl; - cerr << "unresolved source NodeID: " << source << endl; exit(0); + if( ext2IntNodeMap.find(source) == ext2IntNodeMap.end()) { + ERR("after " << edgeList.size() << " edges" << "\n->" << source << "," << target << "," << length << "," << dir << "," << weight << "\n->unresolved source NodeID: " << source ); } source = intNodeID->second; intNodeID = ext2IntNodeMap.find(target); - if(ext2IntNodeMap.find(target) == ext2IntNodeMap.end()) { cerr << "unresolved target NodeID : " << target << endl; exit(0); } + if(ext2IntNodeMap.find(target) == ext2IntNodeMap.end()) { ERR("unresolved target NodeID : " << target); } target = intNodeID->second; - if(source == UINT_MAX || target == UINT_MAX) { cerr << "nonexisting source or target" << endl; exit(0); } + if(source == UINT_MAX || target == UINT_MAX) { ERR( "nonexisting source or target" ); } EdgeT inputEdge(source, target, nameID, weight, forward, backward, type ); edgeList.push_back(inputEdge); @@ -107,8 +103,8 @@ NodeID readBinaryOSRMGraphFromStream(istream &in, vector& edgeList, vecto int xcoord, ycoord;// direction (0 = open, 1 = forward, 2+ = open) ExternalNodeMap ext2IntNodeMap; in.read((char*)&n, sizeof(NodeID)); - VERBOSE(cout << "Importing n = " << n << " nodes ..." << flush;) - for (NodeID i=0; i& edgeList, vecto ext2IntNodeMap.insert(make_pair(id, i)); } in.read((char*)&m, sizeof(unsigned)); - VERBOSE(cout << " and " << m << " edges ..." << flush;) - + DEBUG(" and " << m << " edges "); for(unsigned i = 0; i < inputRestrictions.size(); ++i) { ExternalNodeMap::iterator intNodeID = ext2IntNodeMap.find(inputRestrictions[i].fromNode); if( intNodeID == ext2IntNodeMap.end()) { - DEBUG("Unmapped restriction") - continue; + DEBUG("Unmapped from Node of restriction"); + continue; + } inputRestrictions[i].fromNode = intNodeID->second; intNodeID = ext2IntNodeMap.find(inputRestrictions[i].viaNode); if( intNodeID == ext2IntNodeMap.end()) { - DEBUG("Unmapped restriction") - continue; + DEBUG("Unmapped via node of restriction"); + continue; } inputRestrictions[i].viaNode = intNodeID->second; intNodeID = ext2IntNodeMap.find(inputRestrictions[i].toNode); if( intNodeID == ext2IntNodeMap.end()) { - DEBUG("Unmapped restriction") - continue; + DEBUG("Unmapped to node of restriction"); + continue; } inputRestrictions[i].toNode = intNodeID->second; } @@ -148,7 +144,7 @@ NodeID readBinaryOSRMGraphFromStream(istream &in, vector& edgeList, vecto int length; bool isRoundabout; - for (EdgeID i=0; i& edgeList, vecto in.read((char*)&nameID, sizeof(unsigned)); in.read((char*)&isRoundabout, sizeof(bool)); - assert(length > 0); - assert(weight > 0); - assert(0<=dir && dir<=2); + GUARANTEE(length > 0, "loaded null length edge" ); + GUARANTEE(weight > 0, "loaded null weight"); + GUARANTEE(0<=dir && dir<=2, "loaded bogus direction"); bool forward = true; bool backward = true; if (1 == dir) { backward = false; } if (2 == dir) { forward = false; } - if(length == 0) { cerr << "loaded null length edge" << endl; exit(1); } - // translate the external NodeIDs to internal IDs ExternalNodeMap::iterator intNodeID = ext2IntNodeMap.find(source); if( ext2IntNodeMap.find(source) == ext2IntNodeMap.end()) { #ifndef NDEBUG - cerr << "[warning] unresolved source NodeID: " << source << endl; + WARN(" unresolved source NodeID: " << source ); #endif continue; } @@ -181,20 +175,19 @@ NodeID readBinaryOSRMGraphFromStream(istream &in, vector& edgeList, vecto intNodeID = ext2IntNodeMap.find(target); if(ext2IntNodeMap.find(target) == ext2IntNodeMap.end()) { #ifndef NDEBUG - cerr << "unresolved target NodeID : " << target << endl; + WARN("unresolved target NodeID : " << target ); #endif continue; } target = intNodeID->second; - - if(source == UINT_MAX || target == UINT_MAX) { cerr << "nonexisting source or target" << endl; exit(0); } + GUARANTEE(source != UINT_MAX && target != UINT_MAX, "nonexisting source or target"); EdgeT inputEdge(source, target, nameID, weight, forward, backward, type, isRoundabout ); edgeList.push_back(inputEdge); } ext2IntNodeMap.clear(); vector(edgeList.begin(), edgeList.end()).swap(edgeList); //remove excess candidates. - cout << "ok" << endl; + INFO("Graph loaded ok"); return n; } template @@ -204,17 +197,17 @@ NodeID readDTMPGraphFromStream(istream &in, vector& edgeList, vector> n; - VERBOSE(cout << "Importing n = " << n << " nodes ..." << flush;) - for (NodeID i=0; i> id >> ycoord >> xcoord; int2ExtNodeMap->push_back(NodeInfo(xcoord, ycoord, id)); ext2IntNodeMap.insert(make_pair(id, i)); } in >> m; - VERBOSE(cout << " and " << m << " edges ..." << flush;) + DEBUG(" and " << m << " edges"); edgeList.reserve(m); - for (EdgeID i=0; i& edgeList, vector 0); assert(weight > 0); if(dir <0 || dir > 2) - std::cerr << "[error] direction bogus: " << dir << std::endl; + WARN("direction bogus: " << dir); assert(0<=dir && dir<=2); bool forward = true; @@ -287,23 +280,19 @@ NodeID readDTMPGraphFromStream(istream &in, vector& edgeList, vector" << source << "," << target << "," << length << "," << dir << "," << weight << endl; - cerr << "unresolved source NodeID: " << source << endl; exit(0); + if( ext2IntNodeMap.find(source) == ext2IntNodeMap.end()) { + ERR("after " << edgeList.size() << " edges" << "\n->" << source << "," << target << "," << length << "," << dir << "," << weight << "\n->unresolved source NodeID: " << source); } source = intNodeID->second; intNodeID = ext2IntNodeMap.find(target); - if(ext2IntNodeMap.find(target) == ext2IntNodeMap.end()) { cerr << "unresolved target NodeID : " << target << endl; exit(0); } + if(ext2IntNodeMap.find(target) == ext2IntNodeMap.end()) { ERR("unresolved target NodeID : " << target); } target = intNodeID->second; - if(source == UINT_MAX || target == UINT_MAX) { cerr << "nonexisting source or target" << endl; exit(0); } + if(source == UINT_MAX || target == UINT_MAX) { ERR("nonexisting source or target" ); } EdgeT inputEdge(source, target, 0, weight, forward, backward, type ); edgeList.push_back(inputEdge); @@ -333,12 +322,9 @@ NodeID readDDSGGraphFromStream(istream &in, vector& edgeList, vector> source >> target >> weight >> dir; - // if(dir == 3) - // dir = 0; - assert(weight > 0); if(dir <0 || dir > 3) - std::cerr << "[error] direction bogus: " << dir << std::endl; + ERR( "[error] direction bogus: " << dir ); assert(0<=dir && dir<=3); bool forward = true; @@ -347,8 +333,7 @@ NodeID readDDSGGraphFromStream(istream &in, vector& edgeList, vector& edgeList, vector(edgeList.begin(), edgeList.end()).swap(edgeList); //remove excess candidates. - // cout << "ok" << endl; - // std::cout << "imported " << numberOfNodes << " nodes and " << edgeList.size() << " edges" << std::endl; nodeMap.clear(); return numberOfNodes; } diff --git a/createHierarchy.cpp b/createHierarchy.cpp index f2a1be972..4e3c5d655 100644 --- a/createHierarchy.cpp +++ b/createHierarchy.cpp @@ -28,7 +28,8 @@ or see http://www.gnu.org/licenses/agpl.txt. #undef VERBOSE2 #endif -#include +#include + #include #include #include @@ -60,11 +61,10 @@ std::vector<_Restriction> inputRestrictions; int main (int argc, char *argv[]) { if(argc < 3) { - cerr << "usage: " << std::endl << argv[0] << " " << std::endl; - exit(-1); + ERR("usage: " << std::endl << argv[0] << " "); } INFO("Using restrictions from file: " << argv[2]); - ifstream restrictionsInstream(argv[2], ios::binary); + std::ifstream restrictionsInstream(argv[2], ios::binary); _Restriction restriction; unsigned usableRestrictionsCounter(0); restrictionsInstream.read((char*)&usableRestrictionsCounter, sizeof(unsigned)); @@ -83,36 +83,24 @@ int main (int argc, char *argv[]) { } omp_set_num_threads(numberOfThreads); - std::cout << "preprocessing data from input file " << argv[1]; + INFO("preprocessing data from input file " << argv[1] << " using STL " #ifdef _GLIBCXX_PARALLEL - std::cout << " using STL parallel mode" << std::endl; + "parallel (GCC)" #else - std::cout << " using STL serial mode" << std::endl; + "serial" #endif - + " mode"); ifstream in; in.open (argv[1], ifstream::in | ifstream::binary); if (!in.is_open()) { - cerr << "Cannot open " << argv[1] << std::endl; exit(-1); + ERR("Cannot open " << argv[1]); } - char nodeOut[1024]; - char edgeOut[1024]; - char ramIndexOut[1024]; - char fileIndexOut[1024]; - char levelInfoOut[1024]; - - strcpy(nodeOut, argv[1]); - strcpy(edgeOut, argv[1]); - strcpy(ramIndexOut, argv[1]); - strcpy(fileIndexOut, argv[1]); - strcpy(levelInfoOut, argv[1]); - - strcat(nodeOut, ".nodes"); - strcat(edgeOut, ".hsgr"); - strcat(ramIndexOut, ".ramIndex"); - strcat(fileIndexOut, ".fileIndex"); - strcat(levelInfoOut, ".levels"); + char nodeOut[1024]; strcpy(nodeOut, argv[1]); strcat(nodeOut, ".nodes"); + char edgeOut[1024]; strcpy(edgeOut, argv[1]); strcat(edgeOut, ".hsgr"); + char ramIndexOut[1024]; strcpy(ramIndexOut, argv[1]); strcat(ramIndexOut, ".ramIndex"); + char fileIndexOut[1024]; strcpy(fileIndexOut, argv[1]); strcat(fileIndexOut, ".fileIndex"); + char levelInfoOut[1024]; strcpy(levelInfoOut, argv[1]); strcat(levelInfoOut, ".levels"); std::vector edgeList; NodeID n = readBinaryOSRMGraphFromStream(in, edgeList, &internalToExternaleNodeMapping, inputRestrictions); @@ -132,24 +120,24 @@ int main (int argc, char *argv[]) { DELETE(edgeBasedGraphFactory); WritableGrid * writeableGrid = new WritableGrid(); - std::cout << "building grid ..." << std::flush; + INFO("building grid ..."); writeableGrid->ConstructGrid(nodeBasedEdgeList, &internalToExternaleNodeMapping, ramIndexOut, fileIndexOut); DELETE( writeableGrid ); - std::cout << "writing node map ..." << std::flush; - ofstream mapOutFile(nodeOut, ios::binary); + nodeBasedEdgeList.clear(); + std::vector().swap(nodeBasedEdgeList); - for(NodeID i = 0; i < internalToExternaleNodeMapping.size(); i++) { - mapOutFile.write((char *)&(internalToExternaleNodeMapping.at(i)), sizeof(NodeInfo)); + INFO("writing node map ..."); + std::ofstream mapOutFile(nodeOut, ios::binary); + BOOST_FOREACH(NodeInfo & info, internalToExternaleNodeMapping) { + mapOutFile.write((char *)&(info), sizeof(NodeInfo)); } mapOutFile.close(); - std::cout << "ok" << std::endl; - internalToExternaleNodeMapping.clear(); std::vector().swap(internalToExternaleNodeMapping); inputRestrictions.clear(); std::vector<_Restriction>().swap(inputRestrictions); - std::cout << "initializing contractor ..." << std::flush; + INFO("initializing contractor"); Contractor* contractor = new Contractor( n, edgeBasedEdgeList ); double contractionStartedTimestamp(get_timestamp()); contractor->Run(); @@ -160,24 +148,25 @@ int main (int argc, char *argv[]) { ContractionCleanup * cleanup = new ContractionCleanup(n, contractedEdges); contractedEdges.clear(); + std::vector().swap(contractedEdges); cleanup->Run(); std::vector< InputEdge> cleanedEdgeList; cleanup->GetData(cleanedEdgeList); DELETE( cleanup ); - std::cout << "Serializing edges " << std::flush; + INFO("Serializing edges "); ofstream edgeOutFile(edgeOut, ios::binary); Percent p(cleanedEdgeList.size()); - for(std::vector< InputEdge>::iterator it = cleanedEdgeList.begin(); it != cleanedEdgeList.end(); it++) { + BOOST_FOREACH(InputEdge & edge, cleanedEdgeList) { p.printIncrement(); - edgeOutFile.write((char *)&(it->data), sizeof(EdgeData)); - edgeOutFile.write((char *)&(it->source), sizeof(NodeID)); - edgeOutFile.write((char *)&(it->target), sizeof(NodeID)); + edgeOutFile.write((char *)&(edge.data), sizeof(EdgeData)); + edgeOutFile.write((char *)&(edge.source), sizeof(NodeID)); + edgeOutFile.write((char *)&(edge.target), sizeof(NodeID)); } edgeOutFile.close(); cleanedEdgeList.clear(); - std::cout << "finished" << std::endl; + INFO("finished preprocessing"); return 0; } diff --git a/extractor.cpp b/extractor.cpp index d919ba897..a9e098c16 100644 --- a/extractor.cpp +++ b/extractor.cpp @@ -70,19 +70,16 @@ bool removeIfUnused(ClassT n) { return (false == n.used); } int main (int argc, char *argv[]) { - if(argc <= 1) { - cerr << "usage: " << endl << argv[0] << " " << endl; - exit(-1); - } + GUARANTEE((argc > 1) ,"usage: \n" << argv[0] << " "); - cout << "[extractor] extracting data from input file " << argv[1] << endl; - bool isPBF = false; - string outputFileName(argv[1]); - string restrictionsFileName(argv[1]); - string::size_type pos = outputFileName.find(".osm.bz2"); - if(pos==string::npos) { + INFO("extracting data from input file " << argv[1]); + bool isPBF(false); + std::string outputFileName(argv[1]); + std::string restrictionsFileName(argv[1]); + std::string::size_type pos = outputFileName.find(".osm.bz2"); + if(pos==std::string::npos) { pos = outputFileName.find(".osm.pbf"); - if(pos!=string::npos) { + if(pos!=std::string::npos) { isPBF = true; } } @@ -99,7 +96,7 @@ int main (int argc, char *argv[]) { restrictionsFileName.append(".osrm.restrictions"); } } - string adressFileName(outputFileName); + std::string adressFileName(outputFileName); Settings settings; boost::property_tree::ptree pt; @@ -109,15 +106,15 @@ int main (int argc, char *argv[]) { INFO("Found the following speed profiles: "); int profileCounter(0); BOOST_FOREACH(boost::property_tree::ptree::value_type &v, pt.get_child("")) { - string name = v.first; + std::string name = v.first; cout << " [" << profileCounter << "]" << name << endl; ++profileCounter; } - string usedSpeedProfile(pt.get_child("").begin()->first); + std::string usedSpeedProfile(pt.get_child("").begin()->first); INFO("Using profile \"" << usedSpeedProfile << "\"") BOOST_FOREACH(boost::property_tree::ptree::value_type &v, pt.get_child(usedSpeedProfile)) { - string name = v.first; - string value = v.second.get(""); + std::string name = v.first; + std::string value = v.second.get(""); DEBUG("inserting " << name << "=" << value); if(name == "obeyOneways") { if(value == "no") @@ -150,23 +147,21 @@ int main (int argc, char *argv[]) { unsigned amountOfRAM = 1; unsigned installedRAM = GetPhysicalmemory(); if(installedRAM < 2048264) { - cout << "[Warning] Machine has less than 2GB RAM." << endl; + WARN("Machine has less than 2GB RAM."); } if(testDataFile("extractor.ini")) { ExtractorConfiguration extractorConfig("extractor.ini"); unsigned memoryAmountFromFile = atoi(extractorConfig.GetParameter("Memory").c_str()); if( memoryAmountFromFile != 0 && memoryAmountFromFile <= installedRAM/(1024*1024)) amountOfRAM = memoryAmountFromFile; - cout << "[extractor] using " << amountOfRAM << " GB of RAM for buffers" << endl; + INFO("Using " << amountOfRAM << " GB of RAM for buffers"); } + StringMap stringMap; STXXLContainers externalMemory; unsigned usedNodeCounter = 0; unsigned usedEdgeCounter = 0; - - StringMap stringMap; - double time = get_timestamp(); stringMap[""] = 0; @@ -178,13 +173,9 @@ int main (int argc, char *argv[]) { parser = new XMLParser(argv[1]); } parser->RegisterCallbacks(&nodeFunction, &restrictionFunction, &wayFunction, &adressFunction); - if(parser->Init()) { - parser->Parse(); - } else { - cerr << "[error] parser not initialized!" << endl; - exit(-1); - } - delete parser; + GUARANTEE(parser->Init(), "Parser not initialized!"); + parser->Parse(); + DELETE(parser); stringMap.clear(); try { diff --git a/typedefs.h b/typedefs.h index 9dacefff2..0fd300f4f 100644 --- a/typedefs.h +++ b/typedefs.h @@ -31,8 +31,6 @@ or see http://www.gnu.org/licenses/agpl.txt. using namespace std; -#define VERBOSE(x) x -#define VERBOSE2(x) #ifdef STXXL_VERBOSE_LEVEL #undef STXXL_VERBOSE_LEVEL #endif @@ -41,12 +39,12 @@ using namespace std; #define INFO(x) do {std::cout << "[info " << __FILE__ << ":" << __LINE__ << "] " << x << std::endl;} while(0); #define ERR(x) do {std::cerr << "[error " << __FILE__ << ":" << __LINE__ << "] " << x << std::endl; exit(-1);} while(0); #define WARN(x) do {std::cerr << "[warn " << __FILE__ << ":" << __LINE__ << "] " << x << std::endl;} while(0); +#define GUARANTEE(x,y) do { {do{ if(false == (x)) { ERR(y) } } while(0);} } while(0); + #ifdef NDEBUG #define DEBUG(x) -#define GUARANTEE(x,y) #else #define DEBUG(x) do {std::cout << "[debug " << __FILE__ << ":" << __LINE__ << "] " << x << std::endl;} while(0); -#define GUARANTEE(x,y) do { {do{ if(false == (x)) { ERR(y) } } while(0);} } while(0); #endif #define DELETE(x) do { if(NULL != x) { delete x; x = NULL; } }while(0);