diff --git a/Contractor/Contractor.h b/Contractor/Contractor.h index 35d2aa29e..18bee5de6 100644 --- a/Contractor/Contractor.h +++ b/Contractor/Contractor.h @@ -474,7 +474,7 @@ public: newEdge.data.id = data.id; } BOOST_ASSERT_MSG( - newEdge.data.id <= INT_MAX, //2^31 + newEdge.data.id != INT_MAX, //2^31 "edge id invalid" ); newEdge.data.forward = data.forward; diff --git a/Contractor/EdgeBasedGraphFactory.h b/Contractor/EdgeBasedGraphFactory.h index c51e4d2ea..7949af6ff 100644 --- a/Contractor/EdgeBasedGraphFactory.h +++ b/Contractor/EdgeBasedGraphFactory.h @@ -56,6 +56,17 @@ class EdgeBasedGraphFactory : boost::noncopyable { public: struct EdgeBasedNode { + EdgeBasedNode() : + id(INT_MAX), + lat1(INT_MAX), + lat2(INT_MAX), + lon1(INT_MAX), + lon2(INT_MAX >> 1), + belongsToTinyComponent(false), + nameID(UINT_MAX), + weight(UINT_MAX >> 1), + ignoreInGrid(false) + { } bool operator<(const EdgeBasedNode & other) const { return other.id < id; } diff --git a/Descriptors/JSONDescriptor.h b/Descriptors/JSONDescriptor.h index 7ef4c8dfd..da7afcbb8 100644 --- a/Descriptors/JSONDescriptor.h +++ b/Descriptors/JSONDescriptor.h @@ -41,7 +41,12 @@ private: DescriptionFactory alternateDescriptionFactory; _Coordinate current; unsigned numberOfEnteredRestrictedAreas; - struct { + struct RoundAbout{ + RoundAbout() : + startIndex(INT_MAX), + nameID(INT_MAX), + leaveAtExit(INT_MAX) + {} int startIndex; int nameID; int leaveAtExit; diff --git a/extractor.cpp b/extractor.cpp index 800fd8be5..de801ff51 100644 --- a/extractor.cpp +++ b/extractor.cpp @@ -39,88 +39,92 @@ or see http://www.gnu.org/licenses/agpl.txt. ExtractorCallbacks * extractCallBacks; int main (int argc, char *argv[]) { - double startup_time = get_timestamp(); + try { + double startup_time = get_timestamp(); - if(argc < 2) { - ERR("usage: \n" << argv[0] << " []"); - } - - /*** Setup Scripting Environment ***/ - ScriptingEnvironment scriptingEnvironment((argc > 2 ? argv[2] : "profile.lua")); - - unsigned number_of_threads = omp_get_num_procs(); - if(testDataFile("extractor.ini")) { - BaseConfiguration extractorConfig("extractor.ini"); - unsigned rawNumber = stringToInt(extractorConfig.GetParameter("Threads")); - if( rawNumber != 0 && rawNumber <= number_of_threads) { - number_of_threads = rawNumber; + if(argc < 2) { + ERR("usage: \n" << argv[0] << " []"); } - } - omp_set_num_threads(number_of_threads); - INFO("extracting data from input file " << argv[1]); - bool file_has_pbf_format(false); - std::string output_file_name(argv[1]); - std::string restrictionsFileName(argv[1]); - std::string::size_type pos = output_file_name.find(".osm.bz2"); - if(pos==std::string::npos) { - pos = output_file_name.find(".osm.pbf"); - if(pos!=std::string::npos) { - file_has_pbf_format = true; + /*** Setup Scripting Environment ***/ + ScriptingEnvironment scriptingEnvironment((argc > 2 ? argv[2] : "profile.lua")); + + unsigned number_of_threads = omp_get_num_procs(); + if(testDataFile("extractor.ini")) { + BaseConfiguration extractorConfig("extractor.ini"); + unsigned rawNumber = stringToInt(extractorConfig.GetParameter("Threads")); + if( rawNumber != 0 && rawNumber <= number_of_threads) { + number_of_threads = rawNumber; + } + } + omp_set_num_threads(number_of_threads); + + INFO("extracting data from input file " << argv[1]); + bool file_has_pbf_format(false); + std::string output_file_name(argv[1]); + std::string restrictionsFileName(argv[1]); + std::string::size_type pos = output_file_name.find(".osm.bz2"); + if(pos==std::string::npos) { + pos = output_file_name.find(".osm.pbf"); + if(pos!=std::string::npos) { + file_has_pbf_format = true; + } } - } - if(pos!=std::string::npos) { - output_file_name.replace(pos, 8, ".osrm"); - restrictionsFileName.replace(pos, 8, ".osrm.restrictions"); - } else { - pos=output_file_name.find(".osm"); if(pos!=std::string::npos) { - output_file_name.replace(pos, 5, ".osrm"); - restrictionsFileName.replace(pos, 5, ".osrm.restrictions"); + output_file_name.replace(pos, 8, ".osrm"); + restrictionsFileName.replace(pos, 8, ".osrm.restrictions"); } else { - output_file_name.append(".osrm"); - restrictionsFileName.append(".osrm.restrictions"); + pos=output_file_name.find(".osm"); + if(pos!=std::string::npos) { + output_file_name.replace(pos, 5, ".osrm"); + restrictionsFileName.replace(pos, 5, ".osrm.restrictions"); + } else { + output_file_name.append(".osrm"); + restrictionsFileName.append(".osrm.restrictions"); + } } + + unsigned amountOfRAM = 1; + unsigned installedRAM = GetPhysicalmemory(); + if(installedRAM < 2048264) { + WARN("Machine has less than 2GB RAM."); + } + + StringMap stringMap; + ExtractionContainers externalMemory; + + stringMap[""] = 0; + extractCallBacks = new ExtractorCallbacks(&externalMemory, &stringMap); + BaseParser* parser; + if(file_has_pbf_format) { + parser = new PBFParser(argv[1], extractCallBacks, scriptingEnvironment); + } else { + parser = new XMLParser(argv[1], extractCallBacks, scriptingEnvironment); + } + + if(!parser->ReadHeader()) { + ERR("Parser not initialized!"); + } + INFO("Parsing in progress.."); + double parsing_start_time = get_timestamp(); + parser->Parse(); + INFO("Parsing finished after " << + (get_timestamp() - parsing_start_time) << + " seconds" + ); + + externalMemory.PrepareData(output_file_name, restrictionsFileName, amountOfRAM); + + delete parser; + delete extractCallBacks; + + INFO("extraction finished after " << get_timestamp() - startup_time << "s"); + + std::cout << "\nRun:\n" + << "./osrm-prepare " << output_file_name << " " << restrictionsFileName + << std::endl; + return 0; + } catch(std::exception & e) { + WARN("unhandled exception: " << e.what()); } - - unsigned amountOfRAM = 1; - unsigned installedRAM = GetPhysicalmemory(); - if(installedRAM < 2048264) { - WARN("Machine has less than 2GB RAM."); - } - - StringMap stringMap; - ExtractionContainers externalMemory; - - stringMap[""] = 0; - extractCallBacks = new ExtractorCallbacks(&externalMemory, &stringMap); - BaseParser* parser; - if(file_has_pbf_format) { - parser = new PBFParser(argv[1], extractCallBacks, scriptingEnvironment); - } else { - parser = new XMLParser(argv[1], extractCallBacks, scriptingEnvironment); - } - - if(!parser->ReadHeader()) { - ERR("Parser not initialized!"); - } - INFO("Parsing in progress.."); - double parsing_start_time = get_timestamp(); - parser->Parse(); - INFO("Parsing finished after " << - (get_timestamp() - parsing_start_time) << - " seconds" - ); - - externalMemory.PrepareData(output_file_name, restrictionsFileName, amountOfRAM); - - delete parser; - delete extractCallBacks; - - INFO("extraction finished after " << get_timestamp() - startup_time << "s"); - - std::cout << "\nRun:\n" - << "./osrm-prepare " << output_file_name << " " << restrictionsFileName - << std::endl; - return 0; }