Added location dependent data

This commit is contained in:
Michael Krasnyk
2017-08-15 13:57:44 +02:00
parent 9a482ff828
commit c9673741de
12 changed files with 285 additions and 15 deletions
+1
View File
@@ -79,6 +79,7 @@ struct ExtractorConfig final : storage::IOConfig
boost::filesystem::path input_path;
boost::filesystem::path profile_path;
boost::filesystem::path location_dependent_data_path;
unsigned requested_num_threads;
unsigned small_component_size;
@@ -0,0 +1,44 @@
#ifndef OSRM_LOCATION_DEPENDENT_DATA_HPP
#define OSRM_LOCATION_DEPENDENT_DATA_HPP
#include <boost/filesystem/path.hpp>
#include <boost/geometry.hpp>
#include <boost/geometry/index/rtree.hpp>
#include <osmium/osm/way.hpp>
#include <sol2/sol.hpp>
#include <string>
#include <unordered_map>
namespace osrm
{
namespace extractor
{
struct LocationDependentData
{
using point_t = boost::geometry::model::
point<double, 2, boost::geometry::cs::spherical_equatorial<boost::geometry::degree>>;
using polygon_t = boost::geometry::model::polygon<point_t>;
using box_t = boost::geometry::model::box<point_t>;
using polygon_position_t = std::size_t;
using rtree_t = boost::geometry::index::rtree<std::pair<box_t, polygon_position_t>,
boost::geometry::index::rstar<8>>;
using property_t = boost::variant<boost::blank, double, std::string, bool>;
using properties_t = std::unordered_map<std::string, property_t>;
LocationDependentData(const boost::filesystem::path &file_path);
sol::table operator()(sol::state &state, const osmium::Way &way) const;
private:
rtree_t rtree;
std::vector<std::pair<polygon_t, properties_t>> polygons;
};
}
}
#endif
@@ -2,6 +2,7 @@
#define SCRIPTING_ENVIRONMENT_LUA_HPP
#include "extractor/extraction_relation.hpp"
#include "extractor/location_dependent_data.hpp"
#include "extractor/raster_source.hpp"
#include "extractor/scripting_environment.hpp"
@@ -20,6 +21,11 @@ namespace extractor
struct LuaScriptingContext final
{
LuaScriptingContext(const LocationDependentData &location_dependent_data)
: location_dependent_data(location_dependent_data)
{
}
void ProcessNode(const osmium::Node &,
ExtractionNode &result,
const ExtractionRelationContainer::RelationList &relations);
@@ -46,6 +52,7 @@ struct LuaScriptingContext final
int api_version;
sol::table profile_table;
const LocationDependentData &location_dependent_data;
};
/**
@@ -61,7 +68,8 @@ 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);
explicit Sol2ScriptingEnvironment(const std::string &file_name,
const boost::filesystem::path &location_dependent_data_path);
~Sol2ScriptingEnvironment() override = default;
const ProfileProperties &GetProfileProperties() override;
@@ -93,6 +101,7 @@ class Sol2ScriptingEnvironment final : public ScriptingEnvironment
std::mutex init_mutex;
std::string file_name;
tbb::enumerable_thread_specific<std::unique_ptr<LuaScriptingContext>> script_contexts;
const LocationDependentData location_dependent_data;
};
}
}