osrm-backend/src/tools/extract.cpp

63 lines
1.7 KiB
C++
Raw Normal View History

#include "extractor/extractor.hpp"
#include "extractor/extractor_options.hpp"
2015-01-27 11:44:46 -05:00
#include "util/simple_logger.hpp"
2013-06-24 16:47:35 -04:00
2015-02-09 11:38:40 -05:00
#include <boost/filesystem.hpp>
#include <cstdlib>
#include <exception>
#include <new>
int main(int argc, char *argv[]) try
2014-05-08 13:40:29 -04:00
{
LogPolicy::GetInstance().Unmute();
ExtractorConfig extractor_config;
const return_code result = ExtractorOptions::ParseArguments(argc, argv, extractor_config);
if (return_code::fail == result)
{
return EXIT_FAILURE;
}
if (return_code::exit == result)
2014-10-15 04:23:48 -04:00
{
return EXIT_SUCCESS;
2014-10-15 04:23:48 -04:00
}
ExtractorOptions::GenerateOutputFilesNames(extractor_config);
if (1 > extractor_config.requested_num_threads)
2014-10-15 04:23:48 -04:00
{
SimpleLogger().Write(logWARNING) << "Number of threads must be 1 or larger";
return EXIT_FAILURE;
2014-10-15 04:23:48 -04:00
}
if (!boost::filesystem::is_regular_file(extractor_config.input_path))
{
SimpleLogger().Write(logWARNING) << "Input file " << extractor_config.input_path.string()
<< " not found!";
return EXIT_FAILURE;
}
if (!boost::filesystem::is_regular_file(extractor_config.profile_path))
{
SimpleLogger().Write(logWARNING) << "Profile " << extractor_config.profile_path.string()
<< " not found!";
return EXIT_FAILURE;
}
return extractor(extractor_config).run();
}
catch (const std::bad_alloc &e)
{
SimpleLogger().Write(logWARNING) << "[exception] " << e.what();
SimpleLogger().Write(logWARNING)
<< "Please provide more memory or consider using a larger swapfile";
return EXIT_FAILURE;
}
catch (const std::exception &e)
{
SimpleLogger().Write(logWARNING) << "[exception] " << e.what();
return EXIT_FAILURE;
}