2016-03-21 17:42:47 -04:00
|
|
|
#ifndef PROFILE_PROPERTIES_HPP
|
|
|
|
#define PROFILE_PROPERTIES_HPP
|
|
|
|
|
2017-03-20 09:34:25 -04:00
|
|
|
#include "util/typedefs.hpp"
|
|
|
|
|
2016-05-12 12:50:10 -04:00
|
|
|
#include <algorithm>
|
|
|
|
#include <boost/assert.hpp>
|
2016-03-22 16:23:25 -04:00
|
|
|
#include <boost/numeric/conversion/cast.hpp>
|
|
|
|
|
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;
|
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),
|
|
|
|
weight_name{"duration"}
|
2016-03-21 17:42:47 -04:00
|
|
|
{
|
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-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];
|
|
|
|
unsigned weight_precision = 1;
|
2016-03-21 17:42:47 -04:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|