Fix incorrect weight fallback for distance-based weights

This commit is contained in:
Michael Krasnyk 2017-04-18 22:31:49 +02:00
parent e96545be2e
commit c81baae1b9
2 changed files with 26 additions and 1 deletions

View File

@ -62,3 +62,28 @@ Feature: Car - weights
| from | to | route | speed | weight |
| a | d | ab,bc,cd,cd | 65 km/h | 44.4 |
| a | e | ab,be,be | 14 km/h | 112 |
Scenario: Distance weights
Given the profile file "car" extended with
"""
api_version = 1
properties.weight_name = 'distance'
"""
Given the node map
"""
a---b---c
|
d
"""
And the ways
| nodes |
| abc |
| bd |
When I route I should get
| waypoints | bearings | route | distance | weights | times |
| a,b | 90 90 | abc,abc | 200m | 200,0 | 11.1s,0s |
| b,c | 90 90 | abc,abc | 200m | 200,0 | 11.1s,0s |
| a,d | 90 180 | abc,bd,bd | 399.9m | 200,200,0 | 13.2s,11.1s,0s |

View File

@ -441,7 +441,7 @@ end
function Handlers.handle_weights(way,result,data,profile)
if properties.weight_name == 'distance' then
result.weight = 0
result.weight = -1
-- 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