Extract avoidable combinations from profiles into ProfileProperties
This commit is contained in:
committed by
Patrick Niklaus
parent
f347efb006
commit
9c11197768
@@ -12,6 +12,7 @@ namespace extractor
|
||||
|
||||
using ClassData = std::uint8_t;
|
||||
static const std::uint8_t MAX_CLASS_INDEX = 8 - 1;
|
||||
static const std::uint8_t MAX_AVOIDABLE_CLASSES = 8;
|
||||
|
||||
inline bool isSubset(const ClassData lhs, const ClassData rhs) { return (lhs & rhs) == lhs; }
|
||||
|
||||
|
||||
@@ -5,9 +5,11 @@
|
||||
|
||||
#include "util/typedefs.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
#include <boost/numeric/conversion/cast.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
|
||||
namespace osrm
|
||||
@@ -70,6 +72,24 @@ struct ProfileProperties
|
||||
return std::string(weight_name);
|
||||
}
|
||||
|
||||
// Mark this combination of classes as avoidable
|
||||
void SetAvoidableClasses(std::size_t index, ClassData classes)
|
||||
{
|
||||
avoidable_classes[index] = classes;
|
||||
}
|
||||
|
||||
// Check if this classes are avoidable
|
||||
boost::optional<std::size_t> ClassesAreAvoidable(ClassData classes)
|
||||
{
|
||||
auto iter = std::find(avoidable_classes.begin(), avoidable_classes.end(), classes);
|
||||
if (iter != avoidable_classes.end())
|
||||
{
|
||||
return std::distance(avoidable_classes.begin(), iter);
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
void SetClassName(std::size_t index, const std::string &name)
|
||||
{
|
||||
char *name_ptr = class_names[index];
|
||||
@@ -109,6 +129,8 @@ struct ProfileProperties
|
||||
char weight_name[MAX_WEIGHT_NAME_LENGTH + 1];
|
||||
//! stores the names of each class
|
||||
std::array<char[MAX_CLASS_NAME_LENGTH + 1], MAX_CLASS_INDEX + 1> class_names;
|
||||
//! stores the masks of avoidable class combinations
|
||||
std::array<ClassData, MAX_AVOIDABLE_CLASSES> avoidable_classes;
|
||||
unsigned weight_precision = 1;
|
||||
bool force_split_edges = false;
|
||||
bool call_tagless_node_function = true;
|
||||
|
||||
@@ -52,6 +52,7 @@ class ScriptingEnvironment
|
||||
|
||||
virtual const ProfileProperties &GetProfileProperties() = 0;
|
||||
|
||||
virtual std::vector<std::vector<std::string>> GetAvoidableClasses() = 0;
|
||||
virtual std::vector<std::string> GetNameSuffixList() = 0;
|
||||
virtual std::vector<std::string> GetRestrictions() = 0;
|
||||
virtual void ProcessTurn(ExtractionTurn &turn) = 0;
|
||||
|
||||
@@ -58,10 +58,7 @@ class Sol2ScriptingEnvironment final : public ScriptingEnvironment
|
||||
|
||||
const ProfileProperties &GetProfileProperties() override;
|
||||
|
||||
LuaScriptingContext &GetSol2Context();
|
||||
|
||||
std::vector<std::string> GetStringListFromTable(const std::string &table_name);
|
||||
std::vector<std::string> GetStringListFromFunction(const std::string &function_name);
|
||||
std::vector<std::vector<std::string>> GetAvoidableClasses() override;
|
||||
std::vector<std::string> GetNameSuffixList() override;
|
||||
std::vector<std::string> GetRestrictions() override;
|
||||
void ProcessTurn(ExtractionTurn &turn) override;
|
||||
@@ -75,6 +72,12 @@ class Sol2ScriptingEnvironment final : public ScriptingEnvironment
|
||||
std::vector<InputConditionalTurnRestriction> &resulting_restrictions) override;
|
||||
|
||||
private:
|
||||
LuaScriptingContext &GetSol2Context();
|
||||
|
||||
std::vector<std::string> GetStringListFromTable(const std::string &table_name);
|
||||
std::vector<std::vector<std::string>> GetStringListsFromTable(const std::string &table_name);
|
||||
std::vector<std::string> GetStringListFromFunction(const std::string &function_name);
|
||||
|
||||
void InitContext(LuaScriptingContext &context);
|
||||
std::mutex init_mutex;
|
||||
std::string file_name;
|
||||
|
||||
Reference in New Issue
Block a user