Fixing errors from static analysis
This commit is contained in:
parent
1bcacfab74
commit
5c84c12f40
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
156
extractor.cpp
156
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] << " <file.osm/.osm.bz2/.osm.pbf> [<profile.lua>]");
|
||||
}
|
||||
|
||||
/*** 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] << " <file.osm/.osm.bz2/.osm.pbf> [<profile.lua>]");
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user