Add read-only max_turn_weight in ProfileProperties

This commit is contained in:
Michael Krasnyk 2017-03-20 14:34:25 +01:00
parent 851fcf0758
commit 78a199e2fb
3 changed files with 13 additions and 1 deletions

View File

@ -13,6 +13,9 @@ properties.max_speed_for_map_matching = 180/3.6
properties.use_turn_restrictions = true properties.use_turn_restrictions = true
properties.continue_straight_at_waypoint = true properties.continue_straight_at_waypoint = true
properties.weight_name = 'test_version1' properties.weight_name = 'test_version1'
properties.weight_precision = 2
assert(properties.max_turn_weight == 327.67)
function node_function (node, result) function node_function (node, result)
print ('node_function ' .. node:id()) print ('node_function ' .. node:id())

View File

@ -1,6 +1,8 @@
#ifndef PROFILE_PROPERTIES_HPP #ifndef PROFILE_PROPERTIES_HPP
#define PROFILE_PROPERTIES_HPP #define PROFILE_PROPERTIES_HPP
#include "util/typedefs.hpp"
#include <algorithm> #include <algorithm>
#include <boost/assert.hpp> #include <boost/assert.hpp>
#include <boost/numeric/conversion/cast.hpp> #include <boost/numeric/conversion/cast.hpp>
@ -66,6 +68,11 @@ struct ProfileProperties
double GetWeightMultiplier() const { return std::pow(10., weight_precision); } double GetWeightMultiplier() const { return std::pow(10., weight_precision); }
double GetMaxTurnWeight() const
{
return std::numeric_limits<TurnPenalty>::max() / GetWeightMultiplier();
}
//! penalty to cross a traffic light in deci-seconds //! penalty to cross a traffic light in deci-seconds
std::int32_t traffic_signal_penalty; std::int32_t traffic_signal_penalty;
//! penalty to do a uturn in deci-seconds //! penalty to do a uturn in deci-seconds

View File

@ -245,7 +245,9 @@ void Sol2ScriptingEnvironment::InitContext(LuaScriptingContext &context)
"weight_precision", "weight_precision",
&ProfileProperties::weight_precision, &ProfileProperties::weight_precision,
"weight_name", "weight_name",
sol::property(&ProfileProperties::SetWeightName, &ProfileProperties::GetWeightName)); sol::property(&ProfileProperties::SetWeightName, &ProfileProperties::GetWeightName),
"max_turn_weight",
sol::property(&ProfileProperties::GetMaxTurnWeight));
context.state.new_usertype<std::vector<std::string>>( context.state.new_usertype<std::vector<std::string>>(
"vector", "vector",