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/Util/GraphLoader.h b/Util/GraphLoader.h index 3ed93033a..30074d577 100644 --- a/Util/GraphLoader.h +++ b/Util/GraphLoader.h @@ -104,7 +104,7 @@ NodeID readBinaryOSRMGraphFromStream(istream &in, vector& edgeList, vecto ExternalNodeMap ext2IntNodeMap; in.read((char*)&n, sizeof(NodeID)); DEBUG("Importing n = " << n << " nodes "); - for (NodeID i=0; i& edgeList, vecto } in.read((char*)&m, sizeof(unsigned)); 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; } @@ -144,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) { ERR("loaded null length edge" ); } - // translate the external NodeIDs to internal IDs ExternalNodeMap::iterator intNodeID = ext2IntNodeMap.find(source); if( ext2IntNodeMap.find(source) == ext2IntNodeMap.end()) { @@ -177,20 +175,19 @@ NodeID readBinaryOSRMGraphFromStream(istream &in, vector& edgeList, vecto intNodeID = ext2IntNodeMap.find(target); if(ext2IntNodeMap.find(target) == ext2IntNodeMap.end()) { #ifndef NDEBUG - WARN("unresolved target NodeID : " << target ); + WARN("unresolved target NodeID : " << target ); #endif continue; } target = intNodeID->second; - - if(source == UINT_MAX || target == UINT_MAX) { ERR("nonexisting source or target"); } + 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 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 {