include untangling of Extractor
This commit is contained in:
parent
19740758c9
commit
1f6f44ab01
@ -26,17 +26,17 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Extractor.h"
|
#include "Extractor.h"
|
||||||
|
|
||||||
#include "ExtractorCallbacks.h"
|
#include "ExtractorCallbacks.h"
|
||||||
#include "ExtractionContainers.h"
|
#include "ExtractionContainers.h"
|
||||||
#include "PBFParser.h"
|
#include "PBFParser.h"
|
||||||
#include "ScriptingEnvironment.h"
|
#include "ScriptingEnvironment.h"
|
||||||
#include "XMLParser.h"
|
#include "XMLParser.h"
|
||||||
|
|
||||||
#include "../Util/GitDescription.h"
|
#include "../Util/GitDescription.h"
|
||||||
#include "../Util/MachineInfo.h"
|
|
||||||
#include "../Util/OSRMException.h"
|
#include "../Util/OSRMException.h"
|
||||||
#include "../Util/ProgramOptions.h"
|
#include "../Util/ProgramOptions.h"
|
||||||
#include "../Util/SimpleLogger.h"
|
#include "../Util/SimpleLogger.h"
|
||||||
#include "../Util/StringUtil.h"
|
|
||||||
#include "../Util/TimingUtil.h"
|
#include "../Util/TimingUtil.h"
|
||||||
#include "../typedefs.h"
|
#include "../typedefs.h"
|
||||||
|
|
||||||
@ -46,31 +46,23 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
#include <thread>
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <iostream>
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <string>
|
#include <iostream>
|
||||||
|
#include <thread>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
|
Extractor::Extractor() : requested_num_threads(0), file_has_pbf_format(false)
|
||||||
Extractor::Extractor(const char* git_desc) :
|
|
||||||
git_description(git_desc),
|
|
||||||
requested_num_threads(0),
|
|
||||||
file_has_pbf_format(false)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Extractor::~Extractor()
|
Extractor::~Extractor() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Extractor::ParseArguments(int argc, char *argv[])
|
bool Extractor::ParseArguments(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
// declare a group of options that will be allowed only on command line
|
// declare a group of options that will be allowed only on command line
|
||||||
boost::program_options::options_description generic_options("Options");
|
boost::program_options::options_description generic_options("Options");
|
||||||
generic_options.add_options()("version,v", "Show version")("help,h",
|
generic_options.add_options()("version,v", "Show version")("help,h", "Show this help message")(
|
||||||
"Show this help message")(
|
|
||||||
"config,c",
|
"config,c",
|
||||||
boost::program_options::value<boost::filesystem::path>(&config_file_path)
|
boost::program_options::value<boost::filesystem::path>(&config_file_path)
|
||||||
->default_value("extractor.ini"),
|
->default_value("extractor.ini"),
|
||||||
@ -83,7 +75,8 @@ bool Extractor::ParseArguments(int argc, char *argv[])
|
|||||||
&profile_path)->default_value("profile.lua"),
|
&profile_path)->default_value("profile.lua"),
|
||||||
"Path to LUA routing profile")(
|
"Path to LUA routing profile")(
|
||||||
"threads,t",
|
"threads,t",
|
||||||
boost::program_options::value<unsigned int>(&requested_num_threads)->default_value(tbb::task_scheduler_init::default_num_threads()),
|
boost::program_options::value<unsigned int>(&requested_num_threads)
|
||||||
|
->default_value(tbb::task_scheduler_init::default_num_threads()),
|
||||||
"Number of threads to use");
|
"Number of threads to use");
|
||||||
|
|
||||||
// hidden options, will be allowed both on command line and in config file, but will not be
|
// hidden options, will be allowed both on command line and in config file, but will not be
|
||||||
@ -119,7 +112,7 @@ bool Extractor::ParseArguments(int argc, char *argv[])
|
|||||||
|
|
||||||
if (option_variables.count("version"))
|
if (option_variables.count("version"))
|
||||||
{
|
{
|
||||||
SimpleLogger().Write() << git_description;
|
SimpleLogger().Write() << g_GIT_DESCRIPTION;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,7 +155,9 @@ void Extractor::GenerateOutputFilesNames()
|
|||||||
if (pos != std::string::npos)
|
if (pos != std::string::npos)
|
||||||
{
|
{
|
||||||
file_has_pbf_format = true;
|
file_has_pbf_format = true;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
pos = output_file_name.find(".osm.xml");
|
pos = output_file_name.find(".osm.xml");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -195,7 +190,7 @@ void Extractor::GenerateOutputFilesNames()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int Extractor::Execute(int argc, char *argv[])
|
int Extractor::Run(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -203,7 +198,7 @@ int Extractor::Execute(int argc, char *argv[])
|
|||||||
|
|
||||||
TIMER_START(extracting);
|
TIMER_START(extracting);
|
||||||
|
|
||||||
if(!ParseArguments(argc, argv))
|
if (!ParseArguments(argc, argv))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (1 > requested_num_threads)
|
if (1 > requested_num_threads)
|
||||||
@ -260,13 +255,16 @@ int Extractor::Execute(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
parser = new XMLParser(input_path.string().c_str(), extractor_callbacks, scripting_environment);
|
parser = new XMLParser(input_path.string().c_str(),
|
||||||
|
extractor_callbacks,
|
||||||
|
scripting_environment);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!parser->ReadHeader())
|
if (!parser->ReadHeader())
|
||||||
{
|
{
|
||||||
throw OSRMException("Parser not initialized!");
|
throw OSRMException("Parser not initialized!");
|
||||||
}
|
}
|
||||||
|
|
||||||
SimpleLogger().Write() << "Parsing in progress..";
|
SimpleLogger().Write() << "Parsing in progress..";
|
||||||
TIMER_START(parsing);
|
TIMER_START(parsing);
|
||||||
|
|
||||||
@ -275,8 +273,7 @@ int Extractor::Execute(int argc, char *argv[])
|
|||||||
delete extractor_callbacks;
|
delete extractor_callbacks;
|
||||||
|
|
||||||
TIMER_STOP(parsing);
|
TIMER_STOP(parsing);
|
||||||
SimpleLogger().Write() << "Parsing finished after " << TIMER_SEC(parsing)
|
SimpleLogger().Write() << "Parsing finished after " << TIMER_SEC(parsing) << " seconds";
|
||||||
<< " seconds";
|
|
||||||
|
|
||||||
if (extraction_containers.all_edges_list.empty())
|
if (extraction_containers.all_edges_list.empty())
|
||||||
{
|
{
|
||||||
@ -287,8 +284,7 @@ int Extractor::Execute(int argc, char *argv[])
|
|||||||
extraction_containers.PrepareData(output_file_name, restriction_file_name);
|
extraction_containers.PrepareData(output_file_name, restriction_file_name);
|
||||||
|
|
||||||
TIMER_STOP(extracting);
|
TIMER_STOP(extracting);
|
||||||
SimpleLogger().Write() << "extraction finished after " << TIMER_SEC(extracting)
|
SimpleLogger().Write() << "extraction finished after " << TIMER_SEC(extracting) << "s";
|
||||||
<< "s";
|
|
||||||
SimpleLogger().Write() << "To prepare the data for routing, run: "
|
SimpleLogger().Write() << "To prepare the data for routing, run: "
|
||||||
<< "./osrm-prepare " << output_file_name << std::endl;
|
<< "./osrm-prepare " << output_file_name << std::endl;
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,18 @@
|
|||||||
#ifndef EXTRACTOR_H_
|
#ifndef EXTRACTOR_H_
|
||||||
#define EXTRACTOR_H_
|
#define EXTRACTOR_H_
|
||||||
|
|
||||||
#include "../Util/FingerPrint.h"
|
|
||||||
|
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
class ExtractorCallbacks;
|
class ExtractorCallbacks;
|
||||||
|
|
||||||
/** \brief Class of 'extract' utility. */
|
/** \brief Class of 'extract' utility. */
|
||||||
class Extractor
|
class Extractor
|
||||||
{
|
{
|
||||||
ExtractorCallbacks * extractor_callbacks;
|
ExtractorCallbacks *extractor_callbacks;
|
||||||
FingerPrint fingerprint;
|
|
||||||
const char* git_description;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
unsigned requested_num_threads;
|
unsigned requested_num_threads;
|
||||||
boost::filesystem::path config_file_path;
|
boost::filesystem::path config_file_path;
|
||||||
boost::filesystem::path input_path;
|
boost::filesystem::path input_path;
|
||||||
@ -31,11 +28,11 @@ protected:
|
|||||||
/** \brief Parses config file, if present in options */
|
/** \brief Parses config file, if present in options */
|
||||||
void GenerateOutputFilesNames();
|
void GenerateOutputFilesNames();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Extractor(const char* git_desc);
|
explicit Extractor();
|
||||||
Extractor(const Extractor&) = delete;
|
Extractor(const Extractor &) = delete;
|
||||||
virtual ~Extractor();
|
virtual ~Extractor();
|
||||||
|
|
||||||
int Execute(int argc, char *argv[]);
|
int Run(int argc, char *argv[]);
|
||||||
};
|
};
|
||||||
#endif /* EXTRACTOR_H_ */
|
#endif /* EXTRACTOR_H_ */
|
||||||
|
@ -26,10 +26,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Extractor/Extractor.h"
|
#include "Extractor/Extractor.h"
|
||||||
#include "Util/GitDescription.h"
|
|
||||||
|
|
||||||
int main (int argc, char *argv[])
|
int main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
Extractor extractor(g_GIT_DESCRIPTION);
|
return Extractor().Run(argc, argv);
|
||||||
return extractor.Execute(argc, argv);
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user