2016-03-21 17:42:47 -04:00
|
|
|
#ifndef PROFILE_PROPERTIES_HPP
|
|
|
|
#define PROFILE_PROPERTIES_HPP
|
|
|
|
|
2017-06-27 18:01:05 -04:00
|
|
|
#include "extractor/class_data.hpp"
|
|
|
|
|
2017-03-20 09:34:25 -04:00
|
|
|
#include "util/typedefs.hpp"
|
|
|
|
|
2016-05-12 12:50:10 -04:00
|
|
|
#include <boost/assert.hpp>
|
2016-03-22 16:23:25 -04:00
|
|
|
#include <boost/numeric/conversion/cast.hpp>
|
2017-08-14 17:24:33 -04:00
|
|
|
#include <boost/optional.hpp>
|
2017-07-18 17:05:37 -04:00
|
|
|
|
|
|
|
#include <algorithm>
|
2017-04-06 08:28:43 -04:00
|
|
|
#include <cstdint>
|
2016-03-22 16:23:25 -04:00
|
|
|
|
2016-03-21 17:42:47 -04:00
|
|
|
namespace osrm
|
|
|
|
{
|
|
|
|
namespace extractor
|
|
|
|
{
|
|
|
|
|
2016-11-01 17:13:10 -04:00
|
|
|
const constexpr auto DEFAULT_MAX_SPEED = 180 / 3.6; // 180kmph -> m/s
|
|
|
|
|
2016-03-21 17:42:47 -04:00
|
|
|
struct ProfileProperties
|
|
|
|
{
|
2017-01-26 11:28:27 -05:00
|
|
|
static constexpr int MAX_WEIGHT_NAME_LENGTH = 255;
|
2017-06-27 18:01:05 -04:00
|
|
|
static constexpr int MAX_CLASS_NAME_LENGTH = 255;
|
2016-05-12 12:50:10 -04:00
|
|
|
|
2016-03-21 17:42:47 -04:00
|
|
|
ProfileProperties()
|
2016-11-01 17:13:10 -04:00
|
|
|
: traffic_signal_penalty(0), u_turn_penalty(0),
|
|
|
|
max_speed_for_map_matching(DEFAULT_MAX_SPEED), continue_straight_at_waypoint(true),
|
2016-05-12 12:50:10 -04:00
|
|
|
use_turn_restrictions(false), left_hand_driving(false), fallback_to_duration(true),
|
2017-06-12 17:46:29 -04:00
|
|
|
weight_name{"duration"}, call_tagless_node_function(true)
|
2016-03-21 17:42:47 -04:00
|
|
|
{
|
2017-07-28 05:49:49 -04:00
|
|
|
std::fill(avoidable_classes.begin(), avoidable_classes.end(), INAVLID_CLASS_DATA);
|
2016-05-12 12:50:10 -04:00
|
|
|
BOOST_ASSERT(weight_name[MAX_WEIGHT_NAME_LENGTH] == '\0');
|
2016-03-21 17:42:47 -04:00
|
|
|
}
|
|
|
|
|
2016-05-27 15:05:04 -04:00
|
|
|
double GetUturnPenalty() const { return u_turn_penalty / 10.; }
|
2016-03-21 17:42:47 -04:00
|
|
|
|
|
|
|
void SetUturnPenalty(const double u_turn_penalty_)
|
|
|
|
{
|
2016-03-22 16:23:25 -04:00
|
|
|
u_turn_penalty = boost::numeric_cast<int>(u_turn_penalty_ * 10.);
|
2016-03-21 17:42:47 -04:00
|
|
|
}
|
|
|
|
|
2016-05-27 15:05:04 -04:00
|
|
|
double GetTrafficSignalPenalty() const { return traffic_signal_penalty / 10.; }
|
2016-03-21 17:42:47 -04:00
|
|
|
|
|
|
|
void SetTrafficSignalPenalty(const double traffic_signal_penalty_)
|
|
|
|
{
|
2016-03-22 16:23:25 -04:00
|
|
|
traffic_signal_penalty = boost::numeric_cast<int>(traffic_signal_penalty_ * 10.);
|
2016-03-21 17:42:47 -04:00
|
|
|
}
|
|
|
|
|
2016-11-01 17:13:10 -04:00
|
|
|
double GetMaxSpeedForMapMatching() const { return max_speed_for_map_matching; }
|
|
|
|
|
|
|
|
void SetMaxSpeedForMapMatching(const double max_speed_for_map_matching_)
|
|
|
|
{
|
|
|
|
max_speed_for_map_matching = max_speed_for_map_matching_;
|
|
|
|
}
|
|
|
|
|
2016-05-12 12:50:10 -04:00
|
|
|
void SetWeightName(const std::string &name)
|
|
|
|
{
|
|
|
|
auto count = std::min<std::size_t>(name.length(), MAX_WEIGHT_NAME_LENGTH) + 1;
|
|
|
|
std::copy_n(name.c_str(), count, weight_name);
|
|
|
|
// Make sure this is always zero terminated
|
|
|
|
BOOST_ASSERT(weight_name[count - 1] == '\0');
|
|
|
|
BOOST_ASSERT(weight_name[MAX_WEIGHT_NAME_LENGTH] == '\0');
|
|
|
|
// Set lazy fallback flag
|
|
|
|
fallback_to_duration = name == "duration";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string GetWeightName() const
|
|
|
|
{
|
|
|
|
// Make sure this is always zero terminated
|
|
|
|
BOOST_ASSERT(weight_name[MAX_WEIGHT_NAME_LENGTH] == '\0');
|
|
|
|
return std::string(weight_name);
|
|
|
|
}
|
|
|
|
|
2017-07-18 17:05:37 -04:00
|
|
|
// 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
|
2017-07-21 17:55:19 -04:00
|
|
|
boost::optional<std::size_t> ClassesAreAvoidable(ClassData classes) const
|
2017-07-18 17:05:37 -04:00
|
|
|
{
|
|
|
|
auto iter = std::find(avoidable_classes.begin(), avoidable_classes.end(), classes);
|
|
|
|
if (iter != avoidable_classes.end())
|
|
|
|
{
|
|
|
|
return std::distance(avoidable_classes.begin(), iter);
|
|
|
|
}
|
|
|
|
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
2017-06-27 18:01:05 -04:00
|
|
|
void SetClassName(std::size_t index, const std::string &name)
|
|
|
|
{
|
|
|
|
char *name_ptr = class_names[index];
|
|
|
|
auto count = std::min<std::size_t>(name.length(), MAX_CLASS_NAME_LENGTH) + 1;
|
|
|
|
std::copy_n(name.c_str(), count, name_ptr);
|
|
|
|
// Make sure this is always zero terminated
|
|
|
|
BOOST_ASSERT(class_names[index][count - 1] == '\0');
|
|
|
|
BOOST_ASSERT(class_names[index][MAX_CLASS_NAME_LENGTH] == '\0');
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string GetClassName(std::size_t index) const
|
|
|
|
{
|
|
|
|
BOOST_ASSERT(index <= MAX_CLASS_INDEX);
|
2017-08-08 10:58:43 -04:00
|
|
|
const auto &name_it = std::begin(class_names) + index;
|
|
|
|
return std::string(*name_it);
|
2017-06-27 18:01:05 -04:00
|
|
|
}
|
|
|
|
|
2017-01-17 03:24:52 -05:00
|
|
|
double GetWeightMultiplier() const { return std::pow(10., weight_precision); }
|
|
|
|
|
2017-03-20 09:34:25 -04:00
|
|
|
double GetMaxTurnWeight() const
|
|
|
|
{
|
|
|
|
return std::numeric_limits<TurnPenalty>::max() / GetWeightMultiplier();
|
|
|
|
}
|
|
|
|
|
2016-03-21 17:42:47 -04:00
|
|
|
//! penalty to cross a traffic light in deci-seconds
|
2016-05-12 12:50:10 -04:00
|
|
|
std::int32_t traffic_signal_penalty;
|
2016-03-21 17:42:47 -04:00
|
|
|
//! penalty to do a uturn in deci-seconds
|
2016-05-12 12:50:10 -04:00
|
|
|
std::int32_t u_turn_penalty;
|
2016-11-01 17:13:10 -04:00
|
|
|
double max_speed_for_map_matching;
|
2016-05-12 12:50:10 -04:00
|
|
|
//! depending on the profile, force the routing to always continue in the same direction
|
2016-04-12 12:47:00 -04:00
|
|
|
bool continue_straight_at_waypoint;
|
2016-05-12 12:50:10 -04:00
|
|
|
//! flag used for restriction parser (e.g. used for the walk profile)
|
2016-03-21 17:42:47 -04:00
|
|
|
bool use_turn_restrictions;
|
2016-07-18 09:34:12 -04:00
|
|
|
bool left_hand_driving;
|
2016-05-12 12:50:10 -04:00
|
|
|
bool fallback_to_duration;
|
|
|
|
//! stores the name of the weight (e.g. 'duration', 'distance', 'safety')
|
|
|
|
char weight_name[MAX_WEIGHT_NAME_LENGTH + 1];
|
2017-06-27 18:01:05 -04:00
|
|
|
//! stores the names of each class
|
|
|
|
std::array<char[MAX_CLASS_NAME_LENGTH + 1], MAX_CLASS_INDEX + 1> class_names;
|
2017-07-18 17:05:37 -04:00
|
|
|
//! stores the masks of avoidable class combinations
|
|
|
|
std::array<ClassData, MAX_AVOIDABLE_CLASSES> avoidable_classes;
|
2016-05-12 12:50:10 -04:00
|
|
|
unsigned weight_precision = 1;
|
2017-03-29 17:48:57 -04:00
|
|
|
bool force_split_edges = false;
|
2017-06-12 17:46:29 -04:00
|
|
|
bool call_tagless_node_function = true;
|
2016-03-21 17:42:47 -04:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|