From fc39e0ce1af3f5df738ca812b8336cb5eaa1aaa3 Mon Sep 17 00:00:00 2001 From: Michael Krasnyk Date: Fri, 18 Aug 2017 15:27:49 +0200 Subject: [PATCH] Allow multiple GeoJSON files --- include/extractor/extractor_config.hpp | 2 +- include/extractor/location_dependent_data.hpp | 4 +++- include/extractor/scripting_environment_lua.hpp | 5 +++-- src/extractor/location_dependent_data.cpp | 10 +++++++++- src/extractor/scripting_environment_lua.cpp | 5 +++-- src/osrm/extractor.cpp | 2 +- src/tools/extract.cpp | 4 ++-- 7 files changed, 22 insertions(+), 10 deletions(-) diff --git a/include/extractor/extractor_config.hpp b/include/extractor/extractor_config.hpp index f181c8d69..6678d5b8e 100644 --- a/include/extractor/extractor_config.hpp +++ b/include/extractor/extractor_config.hpp @@ -79,7 +79,7 @@ struct ExtractorConfig final : storage::IOConfig boost::filesystem::path input_path; boost::filesystem::path profile_path; - boost::filesystem::path location_dependent_data_path; + std::vector location_dependent_data_paths; unsigned requested_num_threads; unsigned small_component_size; diff --git a/include/extractor/location_dependent_data.hpp b/include/extractor/location_dependent_data.hpp index 4ced5f70c..efec42687 100644 --- a/include/extractor/location_dependent_data.hpp +++ b/include/extractor/location_dependent_data.hpp @@ -30,11 +30,13 @@ struct LocationDependentData using property_t = boost::variant; using properties_t = std::unordered_map; - LocationDependentData(const boost::filesystem::path &file_path); + LocationDependentData(const std::vector &file_paths); sol::table operator()(sol::state &state, const osmium::Way &way) const; private: + void loadLocationDependentData(const boost::filesystem::path &file_path); + rtree_t rtree; std::vector> polygons; }; diff --git a/include/extractor/scripting_environment_lua.hpp b/include/extractor/scripting_environment_lua.hpp index ef3c8836f..556e92e59 100644 --- a/include/extractor/scripting_environment_lua.hpp +++ b/include/extractor/scripting_environment_lua.hpp @@ -68,8 +68,9 @@ class Sol2ScriptingEnvironment final : public ScriptingEnvironment static const constexpr int SUPPORTED_MIN_API_VERSION = 0; static const constexpr int SUPPORTED_MAX_API_VERSION = 3; - explicit Sol2ScriptingEnvironment(const std::string &file_name, - const boost::filesystem::path &location_dependent_data_path); + explicit Sol2ScriptingEnvironment( + const std::string &file_name, + const std::vector &location_dependent_data_paths); ~Sol2ScriptingEnvironment() override = default; const ProfileProperties &GetProfileProperties() override; diff --git a/src/extractor/location_dependent_data.cpp b/src/extractor/location_dependent_data.cpp index 001ee0b08..0fd0f6b49 100644 --- a/src/extractor/location_dependent_data.cpp +++ b/src/extractor/location_dependent_data.cpp @@ -18,7 +18,15 @@ namespace osrm namespace extractor { -LocationDependentData::LocationDependentData(const boost::filesystem::path &file_path) +LocationDependentData::LocationDependentData(const std::vector &file_paths) +{ + for (const auto &path : file_paths) + { + loadLocationDependentData(path); + } +} + +void LocationDependentData::loadLocationDependentData(const boost::filesystem::path &file_path) { if (file_path.empty()) return; diff --git a/src/extractor/scripting_environment_lua.cpp b/src/extractor/scripting_environment_lua.cpp index be6819a5b..f2cb1abd6 100644 --- a/src/extractor/scripting_environment_lua.cpp +++ b/src/extractor/scripting_environment_lua.cpp @@ -81,8 +81,9 @@ template double lonToDouble(T const &object) } Sol2ScriptingEnvironment::Sol2ScriptingEnvironment( - const std::string &file_name, const boost::filesystem::path &location_dependent_data_path) - : file_name(file_name), location_dependent_data(location_dependent_data_path) + const std::string &file_name, + const std::vector &location_dependent_data_paths) + : file_name(file_name), location_dependent_data(location_dependent_data_paths) { util::Log() << "Using script " << file_name; } diff --git a/src/osrm/extractor.cpp b/src/osrm/extractor.cpp index 99391bba7..c045c4727 100644 --- a/src/osrm/extractor.cpp +++ b/src/osrm/extractor.cpp @@ -11,7 +11,7 @@ namespace osrm void extract(const extractor::ExtractorConfig &config) { extractor::Sol2ScriptingEnvironment scripting_environment(config.profile_path.string(), - config.location_dependent_data_path); + config.location_dependent_data_paths); extractor::Extractor(config).run(scripting_environment); } diff --git a/src/tools/extract.cpp b/src/tools/extract.cpp index 592b036e6..ce1637bc7 100644 --- a/src/tools/extract.cpp +++ b/src/tools/extract.cpp @@ -63,8 +63,8 @@ return_code parseArguments(int argc, ->default_value(false), "Save conditional restrictions found during extraction to disk for use " "during contraction")("location-dependent-data", - boost::program_options::value( - &extractor_config.location_dependent_data_path) + boost::program_options::value>( + &extractor_config.location_dependent_data_paths) ->composing(), "GeoJSON files with location-dependent data");