Allow multiple GeoJSON files

This commit is contained in:
Michael Krasnyk 2017-08-18 15:27:49 +02:00
parent fb02a4c674
commit fc39e0ce1a
7 changed files with 22 additions and 10 deletions

View File

@ -79,7 +79,7 @@ struct ExtractorConfig final : storage::IOConfig
boost::filesystem::path input_path; boost::filesystem::path input_path;
boost::filesystem::path profile_path; boost::filesystem::path profile_path;
boost::filesystem::path location_dependent_data_path; std::vector<boost::filesystem::path> location_dependent_data_paths;
unsigned requested_num_threads; unsigned requested_num_threads;
unsigned small_component_size; unsigned small_component_size;

View File

@ -30,11 +30,13 @@ struct LocationDependentData
using property_t = boost::variant<boost::blank, double, std::string, bool>; using property_t = boost::variant<boost::blank, double, std::string, bool>;
using properties_t = std::unordered_map<std::string, property_t>; using properties_t = std::unordered_map<std::string, property_t>;
LocationDependentData(const boost::filesystem::path &file_path); LocationDependentData(const std::vector<boost::filesystem::path> &file_paths);
sol::table operator()(sol::state &state, const osmium::Way &way) const; sol::table operator()(sol::state &state, const osmium::Way &way) const;
private: private:
void loadLocationDependentData(const boost::filesystem::path &file_path);
rtree_t rtree; rtree_t rtree;
std::vector<std::pair<polygon_t, properties_t>> polygons; std::vector<std::pair<polygon_t, properties_t>> polygons;
}; };

View File

@ -68,8 +68,9 @@ class Sol2ScriptingEnvironment final : public ScriptingEnvironment
static const constexpr int SUPPORTED_MIN_API_VERSION = 0; static const constexpr int SUPPORTED_MIN_API_VERSION = 0;
static const constexpr int SUPPORTED_MAX_API_VERSION = 3; static const constexpr int SUPPORTED_MAX_API_VERSION = 3;
explicit Sol2ScriptingEnvironment(const std::string &file_name, explicit Sol2ScriptingEnvironment(
const boost::filesystem::path &location_dependent_data_path); const std::string &file_name,
const std::vector<boost::filesystem::path> &location_dependent_data_paths);
~Sol2ScriptingEnvironment() override = default; ~Sol2ScriptingEnvironment() override = default;
const ProfileProperties &GetProfileProperties() override; const ProfileProperties &GetProfileProperties() override;

View File

@ -18,7 +18,15 @@ namespace osrm
namespace extractor namespace extractor
{ {
LocationDependentData::LocationDependentData(const boost::filesystem::path &file_path) LocationDependentData::LocationDependentData(const std::vector<boost::filesystem::path> &file_paths)
{
for (const auto &path : file_paths)
{
loadLocationDependentData(path);
}
}
void LocationDependentData::loadLocationDependentData(const boost::filesystem::path &file_path)
{ {
if (file_path.empty()) if (file_path.empty())
return; return;

View File

@ -81,8 +81,9 @@ template <class T> double lonToDouble(T const &object)
} }
Sol2ScriptingEnvironment::Sol2ScriptingEnvironment( Sol2ScriptingEnvironment::Sol2ScriptingEnvironment(
const std::string &file_name, const boost::filesystem::path &location_dependent_data_path) const std::string &file_name,
: file_name(file_name), location_dependent_data(location_dependent_data_path) const std::vector<boost::filesystem::path> &location_dependent_data_paths)
: file_name(file_name), location_dependent_data(location_dependent_data_paths)
{ {
util::Log() << "Using script " << file_name; util::Log() << "Using script " << file_name;
} }

View File

@ -11,7 +11,7 @@ namespace osrm
void extract(const extractor::ExtractorConfig &config) void extract(const extractor::ExtractorConfig &config)
{ {
extractor::Sol2ScriptingEnvironment scripting_environment(config.profile_path.string(), extractor::Sol2ScriptingEnvironment scripting_environment(config.profile_path.string(),
config.location_dependent_data_path); config.location_dependent_data_paths);
extractor::Extractor(config).run(scripting_environment); extractor::Extractor(config).run(scripting_environment);
} }

View File

@ -63,8 +63,8 @@ return_code parseArguments(int argc,
->default_value(false), ->default_value(false),
"Save conditional restrictions found during extraction to disk for use " "Save conditional restrictions found during extraction to disk for use "
"during contraction")("location-dependent-data", "during contraction")("location-dependent-data",
boost::program_options::value<boost::filesystem::path>( boost::program_options::value<std::vector<boost::filesystem::path>>(
&extractor_config.location_dependent_data_path) &extractor_config.location_dependent_data_paths)
->composing(), ->composing(),
"GeoJSON files with location-dependent data"); "GeoJSON files with location-dependent data");