some refactoring
This commit is contained in:
parent
63d8abe32f
commit
74729a372b
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
#include "ExtractionContainers.h"
|
#include "ExtractionContainers.h"
|
||||||
|
|
||||||
void ExtractionContainers::PrepareData(const std::string & outputFileName, const std::string restrictionsFileName, const unsigned amountOfRAM) {
|
void ExtractionContainers::PrepareData(const std::string & output_file_name, const std::string restrictionsFileName, const unsigned amountOfRAM) {
|
||||||
try {
|
try {
|
||||||
unsigned usedNodeCounter = 0;
|
unsigned usedNodeCounter = 0;
|
||||||
unsigned usedEdgeCounter = 0;
|
unsigned usedEdgeCounter = 0;
|
||||||
@ -130,7 +130,7 @@ void ExtractionContainers::PrepareData(const std::string & outputFileName, const
|
|||||||
restrictionsOutstream.close();
|
restrictionsOutstream.close();
|
||||||
|
|
||||||
std::ofstream fout;
|
std::ofstream fout;
|
||||||
fout.open(outputFileName.c_str(), std::ios::binary);
|
fout.open(output_file_name.c_str(), std::ios::binary);
|
||||||
fout.write((char*)&usedNodeCounter, sizeof(unsigned));
|
fout.write((char*)&usedNodeCounter, sizeof(unsigned));
|
||||||
time = get_timestamp();
|
time = get_timestamp();
|
||||||
std::cout << "[extractor] Confirming/Writing used nodes ... " << std::flush;
|
std::cout << "[extractor] Confirming/Writing used nodes ... " << std::flush;
|
||||||
@ -271,7 +271,7 @@ void ExtractionContainers::PrepareData(const std::string & outputFileName, const
|
|||||||
std::cout << "ok" << std::endl;
|
std::cout << "ok" << std::endl;
|
||||||
time = get_timestamp();
|
time = get_timestamp();
|
||||||
std::cout << "[extractor] writing street name index ... " << std::flush;
|
std::cout << "[extractor] writing street name index ... " << std::flush;
|
||||||
std::string nameOutFileName = (outputFileName + ".names");
|
std::string nameOutFileName = (output_file_name + ".names");
|
||||||
std::ofstream nameOutFile(nameOutFileName.c_str(), std::ios::binary);
|
std::ofstream nameOutFile(nameOutFileName.c_str(), std::ios::binary);
|
||||||
unsigned sizeOfNameIndex = nameVector.size();
|
unsigned sizeOfNameIndex = nameVector.size();
|
||||||
nameOutFile.write((char *)&(sizeOfNameIndex), sizeof(unsigned));
|
nameOutFile.write((char *)&(sizeOfNameIndex), sizeof(unsigned));
|
||||||
|
@ -55,7 +55,7 @@ public:
|
|||||||
wayStartEndVector.clear();
|
wayStartEndVector.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrepareData( const std::string & outputFileName, const std::string restrictionsFileName, const unsigned amountOfRAM);
|
void PrepareData( const std::string & output_file_name, const std::string restrictionsFileName, const unsigned amountOfRAM);
|
||||||
|
|
||||||
STXXLNodeIDVector usedNodeIDs;
|
STXXLNodeIDVector usedNodeIDs;
|
||||||
STXXLNodeVector allNodes;
|
STXXLNodeVector allNodes;
|
||||||
|
@ -63,14 +63,14 @@ int main (int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
double startupTime = get_timestamp();
|
double startupTime = get_timestamp();
|
||||||
unsigned numberOfThreads = omp_get_num_procs();
|
unsigned number_of_threads = omp_get_num_procs();
|
||||||
if(testDataFile("contractor.ini")) {
|
if(testDataFile("contractor.ini")) {
|
||||||
ContractorConfiguration contractorConfig("contractor.ini");
|
ContractorConfiguration contractorConfig("contractor.ini");
|
||||||
unsigned rawNumber = stringToInt(contractorConfig.GetParameter("Threads"));
|
unsigned rawNumber = stringToInt(contractorConfig.GetParameter("Threads"));
|
||||||
if(rawNumber != 0 && rawNumber <= numberOfThreads)
|
if(rawNumber != 0 && rawNumber <= number_of_threads)
|
||||||
numberOfThreads = rawNumber;
|
number_of_threads = rawNumber;
|
||||||
}
|
}
|
||||||
omp_set_num_threads(numberOfThreads);
|
omp_set_num_threads(number_of_threads);
|
||||||
|
|
||||||
INFO("Using restrictions from file: " << argv[2]);
|
INFO("Using restrictions from file: " << argv[2]);
|
||||||
std::ifstream restrictionsInstream(argv[2], std::ios::binary);
|
std::ifstream restrictionsInstream(argv[2], std::ios::binary);
|
||||||
|
@ -31,17 +31,15 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
|||||||
#include "typedefs.h"
|
#include "typedefs.h"
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
typedef BaseConfiguration ExtractorConfiguration;
|
|
||||||
|
|
||||||
ExtractorCallbacks * extractCallBacks;
|
ExtractorCallbacks * extractCallBacks;
|
||||||
|
|
||||||
int main (int argc, char *argv[]) {
|
int main (int argc, char *argv[]) {
|
||||||
double earliestTime = get_timestamp();
|
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>]");
|
||||||
@ -50,36 +48,37 @@ int main (int argc, char *argv[]) {
|
|||||||
/*** Setup Scripting Environment ***/
|
/*** Setup Scripting Environment ***/
|
||||||
ScriptingEnvironment scriptingEnvironment((argc > 2 ? argv[2] : "profile.lua"));
|
ScriptingEnvironment scriptingEnvironment((argc > 2 ? argv[2] : "profile.lua"));
|
||||||
|
|
||||||
unsigned numberOfThreads = omp_get_num_procs();
|
unsigned number_of_threads = omp_get_num_procs();
|
||||||
if(testDataFile("extractor.ini")) {
|
if(testDataFile("extractor.ini")) {
|
||||||
ExtractorConfiguration extractorConfig("extractor.ini");
|
BaseConfiguration extractorConfig("extractor.ini");
|
||||||
unsigned rawNumber = stringToInt(extractorConfig.GetParameter("Threads"));
|
unsigned rawNumber = stringToInt(extractorConfig.GetParameter("Threads"));
|
||||||
if( rawNumber != 0 && rawNumber <= numberOfThreads)
|
if( rawNumber != 0 && rawNumber <= number_of_threads) {
|
||||||
numberOfThreads = rawNumber;
|
number_of_threads = rawNumber;
|
||||||
}
|
}
|
||||||
omp_set_num_threads(numberOfThreads);
|
}
|
||||||
|
omp_set_num_threads(number_of_threads);
|
||||||
|
|
||||||
INFO("extracting data from input file " << argv[1]);
|
INFO("extracting data from input file " << argv[1]);
|
||||||
bool isPBF(false);
|
bool file_has_pbf_format(false);
|
||||||
std::string outputFileName(argv[1]);
|
std::string output_file_name(argv[1]);
|
||||||
std::string restrictionsFileName(argv[1]);
|
std::string restrictionsFileName(argv[1]);
|
||||||
std::string::size_type pos = outputFileName.find(".osm.bz2");
|
std::string::size_type pos = output_file_name.find(".osm.bz2");
|
||||||
if(pos==std::string::npos) {
|
if(pos==std::string::npos) {
|
||||||
pos = outputFileName.find(".osm.pbf");
|
pos = output_file_name.find(".osm.pbf");
|
||||||
if(pos!=std::string::npos) {
|
if(pos!=std::string::npos) {
|
||||||
isPBF = true;
|
file_has_pbf_format = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(pos!=std::string::npos) {
|
if(pos!=std::string::npos) {
|
||||||
outputFileName.replace(pos, 8, ".osrm");
|
output_file_name.replace(pos, 8, ".osrm");
|
||||||
restrictionsFileName.replace(pos, 8, ".osrm.restrictions");
|
restrictionsFileName.replace(pos, 8, ".osrm.restrictions");
|
||||||
} else {
|
} else {
|
||||||
pos=outputFileName.find(".osm");
|
pos=output_file_name.find(".osm");
|
||||||
if(pos!=std::string::npos) {
|
if(pos!=std::string::npos) {
|
||||||
outputFileName.replace(pos, 5, ".osrm");
|
output_file_name.replace(pos, 5, ".osrm");
|
||||||
restrictionsFileName.replace(pos, 5, ".osrm.restrictions");
|
restrictionsFileName.replace(pos, 5, ".osrm.restrictions");
|
||||||
} else {
|
} else {
|
||||||
outputFileName.append(".osrm");
|
output_file_name.append(".osrm");
|
||||||
restrictionsFileName.append(".osrm.restrictions");
|
restrictionsFileName.append(".osrm.restrictions");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -96,7 +95,7 @@ int main (int argc, char *argv[]) {
|
|||||||
stringMap[""] = 0;
|
stringMap[""] = 0;
|
||||||
extractCallBacks = new ExtractorCallbacks(&externalMemory, &stringMap);
|
extractCallBacks = new ExtractorCallbacks(&externalMemory, &stringMap);
|
||||||
BaseParser* parser;
|
BaseParser* parser;
|
||||||
if(isPBF) {
|
if(file_has_pbf_format) {
|
||||||
parser = new PBFParser(argv[1], extractCallBacks, scriptingEnvironment);
|
parser = new PBFParser(argv[1], extractCallBacks, scriptingEnvironment);
|
||||||
} else {
|
} else {
|
||||||
parser = new XMLParser(argv[1], extractCallBacks, scriptingEnvironment);
|
parser = new XMLParser(argv[1], extractCallBacks, scriptingEnvironment);
|
||||||
@ -106,18 +105,22 @@ int main (int argc, char *argv[]) {
|
|||||||
ERR("Parser not initialized!");
|
ERR("Parser not initialized!");
|
||||||
}
|
}
|
||||||
INFO("Parsing in progress..");
|
INFO("Parsing in progress..");
|
||||||
double time = get_timestamp();
|
double parsing_start_time = get_timestamp();
|
||||||
parser->Parse();
|
parser->Parse();
|
||||||
INFO("Parsing finished after " << get_timestamp() - time << " seconds");
|
INFO("Parsing finished after " <<
|
||||||
|
(get_timestamp() - parsing_start_time) <<
|
||||||
|
" seconds"
|
||||||
|
);
|
||||||
|
|
||||||
externalMemory.PrepareData(outputFileName, restrictionsFileName, amountOfRAM);
|
externalMemory.PrepareData(output_file_name, restrictionsFileName, amountOfRAM);
|
||||||
|
|
||||||
stringMap.clear();
|
|
||||||
delete parser;
|
delete parser;
|
||||||
delete extractCallBacks;
|
delete extractCallBacks;
|
||||||
INFO("finished after " << get_timestamp() - earliestTime << "s");
|
|
||||||
|
INFO("extraction finished after " << get_timestamp() - startup_time << "s");
|
||||||
|
|
||||||
std::cout << "\nRun:\n"
|
std::cout << "\nRun:\n"
|
||||||
"./osrm-prepare " << outputFileName << " " << restrictionsFileName << std::endl;
|
<< "./osrm-prepare " << output_file_name << " " << restrictionsFileName
|
||||||
|
<< std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user