fix #1021, always check if files exist
This commit is contained in:
parent
4fc329a1eb
commit
4ec9f2c00f
@ -79,13 +79,13 @@ template <class EdgeDataT> class InternalDataFacade : public BaseDataFacade<Edge
|
|||||||
if (boost::filesystem::exists(timestamp_path))
|
if (boost::filesystem::exists(timestamp_path))
|
||||||
{
|
{
|
||||||
SimpleLogger().Write() << "Loading Timestamp";
|
SimpleLogger().Write() << "Loading Timestamp";
|
||||||
boost::filesystem::ifstream timestampInStream(timestamp_path);
|
boost::filesystem::ifstream timestamp_stream(timestamp_path);
|
||||||
if (!timestampInStream)
|
if (!timestamp_stream)
|
||||||
{
|
{
|
||||||
SimpleLogger().Write(logWARNING) << timestamp_path << " not found";
|
SimpleLogger().Write(logWARNING) << timestamp_path << " not found";
|
||||||
}
|
}
|
||||||
getline(timestampInStream, m_timestamp);
|
getline(timestamp_stream, m_timestamp);
|
||||||
timestampInStream.close();
|
timestamp_stream.close();
|
||||||
}
|
}
|
||||||
if (m_timestamp.empty())
|
if (m_timestamp.empty())
|
||||||
{
|
{
|
||||||
@ -279,16 +279,23 @@ template <class EdgeDataT> class InternalDataFacade : public BaseDataFacade<Edge
|
|||||||
|
|
||||||
// load data
|
// load data
|
||||||
SimpleLogger().Write() << "loading graph data";
|
SimpleLogger().Write() << "loading graph data";
|
||||||
|
AssertPathExists(hsgr_path);
|
||||||
LoadGraph(hsgr_path);
|
LoadGraph(hsgr_path);
|
||||||
SimpleLogger().Write() << "loading egde information";
|
SimpleLogger().Write() << "loading egde information";
|
||||||
|
AssertPathExists(nodes_data_path);
|
||||||
|
AssertPathExists(edges_data_path);
|
||||||
LoadNodeAndEdgeInformation(nodes_data_path, edges_data_path);
|
LoadNodeAndEdgeInformation(nodes_data_path, edges_data_path);
|
||||||
SimpleLogger().Write() << "loading geometries";
|
SimpleLogger().Write() << "loading geometries";
|
||||||
|
AssertPathExists(geometries_path);
|
||||||
LoadGeometries(geometries_path);
|
LoadGeometries(geometries_path);
|
||||||
SimpleLogger().Write() << "loading r-tree";
|
SimpleLogger().Write() << "loading r-tree";
|
||||||
|
AssertPathExists(ram_index_path);
|
||||||
|
AssertPathExists(file_index_path);
|
||||||
LoadRTree(ram_index_path, file_index_path);
|
LoadRTree(ram_index_path, file_index_path);
|
||||||
SimpleLogger().Write() << "loading timestamp";
|
SimpleLogger().Write() << "loading timestamp";
|
||||||
LoadTimestamp(timestamp_path);
|
LoadTimestamp(timestamp_path);
|
||||||
SimpleLogger().Write() << "loading street names";
|
SimpleLogger().Write() << "loading street names";
|
||||||
|
AssertPathExists(names_data_path);
|
||||||
LoadStreetNames(names_data_path);
|
LoadStreetNames(names_data_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#ifndef INI_FILE_UTIL_H
|
#ifndef INI_FILE_UTIL_H
|
||||||
#define INI_FILE_UTIL_H
|
#define INI_FILE_UTIL_H
|
||||||
|
|
||||||
|
#include "SimpleLogger.h"
|
||||||
|
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
#include <boost/filesystem/fstream.hpp>
|
#include <boost/filesystem/fstream.hpp>
|
||||||
|
|
||||||
@ -40,9 +42,19 @@ inline std::string ReadIniFileAndLowerContents(const boost::filesystem::path &pa
|
|||||||
boost::filesystem::fstream config_stream(path);
|
boost::filesystem::fstream config_stream(path);
|
||||||
std::string input_str((std::istreambuf_iterator<char>(config_stream)),
|
std::string input_str((std::istreambuf_iterator<char>(config_stream)),
|
||||||
std::istreambuf_iterator<char>());
|
std::istreambuf_iterator<char>());
|
||||||
std::regex regex("^([^=]*)"); // match from start of line to '='
|
std::regex regex("\\w+=");
|
||||||
std::string format("\\L$1\\E"); // replace with downcased substring
|
|
||||||
return std::regex_replace(input_str, regex, format);
|
std::string output = input_str;
|
||||||
|
const std::sregex_token_iterator end;
|
||||||
|
for (std::sregex_token_iterator i(input_str.begin(), input_str.end(), regex); i != end; ++i)
|
||||||
|
{
|
||||||
|
std::string match = *i;
|
||||||
|
std::string new_regex = *i;
|
||||||
|
std::transform(new_regex.begin(), new_regex.end(), new_regex.begin(), ::tolower);
|
||||||
|
SimpleLogger().Write() << match << " - " << new_regex;
|
||||||
|
output = std::regex_replace(output, std::regex(match), new_regex);
|
||||||
|
}
|
||||||
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // INI_FILE_UTIL_H
|
#endif // INI_FILE_UTIL_H
|
||||||
|
@ -150,6 +150,7 @@ inline unsigned GenerateServerProgramOptions(const int argc,
|
|||||||
|
|
||||||
// parse config file
|
// parse config file
|
||||||
ServerPaths::iterator path_iterator = paths.find("config");
|
ServerPaths::iterator path_iterator = paths.find("config");
|
||||||
|
bool use_ini_file = false;
|
||||||
if (path_iterator != paths.end() && boost::filesystem::is_regular_file(path_iterator->second) &&
|
if (path_iterator != paths.end() && boost::filesystem::is_regular_file(path_iterator->second) &&
|
||||||
!option_variables.count("base"))
|
!option_variables.count("base"))
|
||||||
{
|
{
|
||||||
@ -159,6 +160,8 @@ inline unsigned GenerateServerProgramOptions(const int argc,
|
|||||||
boost::program_options::store(parse_config_file(config_stream, config_file_options),
|
boost::program_options::store(parse_config_file(config_stream, config_file_options),
|
||||||
option_variables);
|
option_variables);
|
||||||
boost::program_options::notify(option_variables);
|
boost::program_options::notify(option_variables);
|
||||||
|
use_ini_file = true;
|
||||||
|
return INIT_OK_START_ENGINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (1 > requested_num_threads)
|
if (1 > requested_num_threads)
|
||||||
|
Loading…
Reference in New Issue
Block a user