Fixing errors from static analysis
This commit is contained in:
parent
1bcacfab74
commit
5c84c12f40
@ -474,7 +474,7 @@ public:
|
|||||||
newEdge.data.id = data.id;
|
newEdge.data.id = data.id;
|
||||||
}
|
}
|
||||||
BOOST_ASSERT_MSG(
|
BOOST_ASSERT_MSG(
|
||||||
newEdge.data.id <= INT_MAX, //2^31
|
newEdge.data.id != INT_MAX, //2^31
|
||||||
"edge id invalid"
|
"edge id invalid"
|
||||||
);
|
);
|
||||||
newEdge.data.forward = data.forward;
|
newEdge.data.forward = data.forward;
|
||||||
|
@ -56,6 +56,17 @@
|
|||||||
class EdgeBasedGraphFactory : boost::noncopyable {
|
class EdgeBasedGraphFactory : boost::noncopyable {
|
||||||
public:
|
public:
|
||||||
struct EdgeBasedNode {
|
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 {
|
bool operator<(const EdgeBasedNode & other) const {
|
||||||
return other.id < id;
|
return other.id < id;
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,12 @@ private:
|
|||||||
DescriptionFactory alternateDescriptionFactory;
|
DescriptionFactory alternateDescriptionFactory;
|
||||||
_Coordinate current;
|
_Coordinate current;
|
||||||
unsigned numberOfEnteredRestrictedAreas;
|
unsigned numberOfEnteredRestrictedAreas;
|
||||||
struct {
|
struct RoundAbout{
|
||||||
|
RoundAbout() :
|
||||||
|
startIndex(INT_MAX),
|
||||||
|
nameID(INT_MAX),
|
||||||
|
leaveAtExit(INT_MAX)
|
||||||
|
{}
|
||||||
int startIndex;
|
int startIndex;
|
||||||
int nameID;
|
int nameID;
|
||||||
int leaveAtExit;
|
int leaveAtExit;
|
||||||
|
156
extractor.cpp
156
extractor.cpp
@ -39,88 +39,92 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
|||||||
ExtractorCallbacks * extractCallBacks;
|
ExtractorCallbacks * extractCallBacks;
|
||||||
|
|
||||||
int main (int argc, char *argv[]) {
|
int main (int argc, char *argv[]) {
|
||||||
double startup_time = get_timestamp();
|
try {
|
||||||
|
double startup_time = get_timestamp();
|
||||||
|
|
||||||
if(argc < 2) {
|
if(argc < 2) {
|
||||||
ERR("usage: \n" << argv[0] << " <file.osm/.osm.bz2/.osm.pbf> [<profile.lua>]");
|
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;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
omp_set_num_threads(number_of_threads);
|
|
||||||
|
|
||||||
INFO("extracting data from input file " << argv[1]);
|
/*** Setup Scripting Environment ***/
|
||||||
bool file_has_pbf_format(false);
|
ScriptingEnvironment scriptingEnvironment((argc > 2 ? argv[2] : "profile.lua"));
|
||||||
std::string output_file_name(argv[1]);
|
|
||||||
std::string restrictionsFileName(argv[1]);
|
unsigned number_of_threads = omp_get_num_procs();
|
||||||
std::string::size_type pos = output_file_name.find(".osm.bz2");
|
if(testDataFile("extractor.ini")) {
|
||||||
if(pos==std::string::npos) {
|
BaseConfiguration extractorConfig("extractor.ini");
|
||||||
pos = output_file_name.find(".osm.pbf");
|
unsigned rawNumber = stringToInt(extractorConfig.GetParameter("Threads"));
|
||||||
if(pos!=std::string::npos) {
|
if( rawNumber != 0 && rawNumber <= number_of_threads) {
|
||||||
file_has_pbf_format = true;
|
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) {
|
if(pos!=std::string::npos) {
|
||||||
output_file_name.replace(pos, 5, ".osrm");
|
output_file_name.replace(pos, 8, ".osrm");
|
||||||
restrictionsFileName.replace(pos, 5, ".osrm.restrictions");
|
restrictionsFileName.replace(pos, 8, ".osrm.restrictions");
|
||||||
} else {
|
} else {
|
||||||
output_file_name.append(".osrm");
|
pos=output_file_name.find(".osm");
|
||||||
restrictionsFileName.append(".osrm.restrictions");
|
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