Skip to content

Commit 3364be1

Browse files
oxidaseTheMarex
authored andcommitted
Fix incorrect weight fallback for distance-based weights
1 parent a5eeca9 commit 3364be1

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

features/car/weight.feature

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,28 @@ Feature: Car - weights
6262
| from | to | route | speed | weight |
6363
| a | d | ab,bc,cd,cd | 65 km/h | 44.4 |
6464
| a | e | ab,be,be | 14 km/h | 112 |
65+
66+
Scenario: Distance weights
67+
Given the profile file "car" extended with
68+
"""
69+
api_version = 1
70+
properties.weight_name = 'distance'
71+
"""
72+
73+
Given the node map
74+
"""
75+
a---b---c
76+
|
77+
d
78+
"""
79+
80+
And the ways
81+
| nodes |
82+
| abc |
83+
| bd |
84+
85+
When I route I should get
86+
| waypoints | bearings | route | distance | weights | times |
87+
| a,b | 90 90 | abc,abc | 200m | 200,0 | 11.1s,0s |
88+
| b,c | 90 90 | abc,abc | 200m | 200,0 | 11.1s,0s |
89+
| a,d | 90 180 | abc,bd,bd | 399.9m | 200,200,0 | 13.2s,11.1s,0s |

profiles/lib/handlers.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ end
441441

442442
function Handlers.handle_weights(way,result,data,profile)
443443
if properties.weight_name == 'distance' then
444-
result.weight = 0
444+
result.weight = -1
445445
-- set weight rates to 1 for the distance weight, edge weights are distance / rate
446446
if (result.forward_mode ~= mode.inaccessible and result.forward_speed > 0) then
447447
result.forward_rate = 1

0 commit comments

Comments
 (0)