Added 'distance' weight to car profile
This commit is contained in:
parent
5fd6355829
commit
9e5d45d86a
@ -131,6 +131,8 @@ inline RouteLeg assembleLeg(const datafacade::BaseDataFacade &facade,
|
|||||||
{
|
{
|
||||||
const auto target_duration =
|
const auto target_duration =
|
||||||
(target_traversed_in_reverse ? target_node.reverse_duration : target_node.forward_duration);
|
(target_traversed_in_reverse ? target_node.reverse_duration : target_node.forward_duration);
|
||||||
|
const auto target_weight =
|
||||||
|
(target_traversed_in_reverse ? target_node.reverse_weight : target_node.forward_weight);
|
||||||
|
|
||||||
auto distance = std::accumulate(
|
auto distance = std::accumulate(
|
||||||
leg_geometry.segment_distances.begin(), leg_geometry.segment_distances.end(), 0.);
|
leg_geometry.segment_distances.begin(), leg_geometry.segment_distances.end(), 0.);
|
||||||
@ -165,6 +167,7 @@ inline RouteLeg assembleLeg(const datafacade::BaseDataFacade &facade,
|
|||||||
// On local segments, the target duration is already part of the duration, however.
|
// On local segments, the target duration is already part of the duration, however.
|
||||||
|
|
||||||
duration = duration + target_duration;
|
duration = duration + target_duration;
|
||||||
|
weight = weight + target_weight;
|
||||||
if (route_data.empty())
|
if (route_data.empty())
|
||||||
{
|
{
|
||||||
duration -= (target_traversed_in_reverse ? source_node.reverse_duration
|
duration -= (target_traversed_in_reverse ? source_node.reverse_duration
|
||||||
@ -204,7 +207,7 @@ inline RouteLeg assembleLeg(const datafacade::BaseDataFacade &facade,
|
|||||||
|
|
||||||
return RouteLeg{std::round(distance * 10.) / 10.,
|
return RouteLeg{std::round(distance * 10.) / 10.,
|
||||||
duration / 10.,
|
duration / 10.,
|
||||||
duration / facade.GetWeightMultiplier(),
|
weight / facade.GetWeightMultiplier(),
|
||||||
summary,
|
summary,
|
||||||
{}};
|
{}};
|
||||||
}
|
}
|
||||||
|
@ -342,7 +342,10 @@ function way_function(way, result)
|
|||||||
'handle_startpoint',
|
'handle_startpoint',
|
||||||
|
|
||||||
-- set name, ref and pronunciation
|
-- set name, ref and pronunciation
|
||||||
'handle_names'
|
'handle_names',
|
||||||
|
|
||||||
|
-- set weight properties of the way
|
||||||
|
'handle_weights'
|
||||||
}
|
}
|
||||||
|
|
||||||
Handlers.run(handlers,way,result,data,profile)
|
Handlers.run(handlers,way,result,data,profile)
|
||||||
|
@ -405,6 +405,18 @@ function Handlers.handle_oneway(way,result,data,profile)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Handlers.handle_weights(way,result,data,profile)
|
||||||
|
if properties.weight_name == 'distance' then
|
||||||
|
result.weight = 0
|
||||||
|
-- set weight rates to 1 for the distance weight, edge weights are distance / rate
|
||||||
|
if (result.forward_mode ~= mode.inaccessible and result.forward_speed > 0) then
|
||||||
|
result.forward_rate = 1
|
||||||
|
end
|
||||||
|
if (result.backward_mode ~= mode.inaccessible and result.backward_speed > 0) then
|
||||||
|
result.backward_rate = 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- handle various that can block access
|
-- handle various that can block access
|
||||||
function Handlers.handle_blocked_ways(way,result,data,profile)
|
function Handlers.handle_blocked_ways(way,result,data,profile)
|
||||||
|
Loading…
Reference in New Issue
Block a user