diff --git a/features/step_definitions/routing.rb b/features/step_definitions/routing.rb index 24c6d6a7d06..ecefd79be74 100644 --- a/features/step_definitions/routing.rb +++ b/features/step_definitions/routing.rb @@ -46,6 +46,8 @@ compasses = compass_list json['route_instructions'] turns = turn_list json['route_instructions'] modes = mode_list json['route_instructions'] + times = time_list json['route_instructions'] + distances = distance_list json['route_instructions'] end end @@ -90,6 +92,12 @@ if table.headers.include? 'modes' got['modes'] = modes end + if table.headers.include? 'times' + got['times'] = times + end + if table.headers.include? 'distances' + got['distances'] = distances + end if table.headers.include? '#' # comment column got['#'] = row['#'] # copy value so it always match end diff --git a/features/support/route.rb b/features/support/route.rb index 15dbf77a47b..1fb7398e471 100644 --- a/features/support/route.rb +++ b/features/support/route.rb @@ -80,25 +80,23 @@ def route_status response end end -def way_list instructions +def extract_instruction_list instructions, index, postfix=nil instructions.reject { |r| r[0].to_s=="#{DESTINATION_REACHED}" }. - map { |r| r[1] }. - map { |r| r=="" ? '""' : r }. + map { |r| r[index] }. + map { |r| (r=="" || r==nil) ? '""' : "#{r}#{postfix}" }. join(',') end +def way_list instructions + extract_instruction_list instructions, 1 +end + def compass_list instructions - instructions.reject { |r| r[0].to_s=="#{DESTINATION_REACHED}" }. - map { |r| r[6] }. - map { |r| r=="" ? '""' : r }. - join(',') + extract_instruction_list instructions, 6 end def bearing_list instructions - instructions.reject { |r| r[0].to_s=="#{DESTINATION_REACHED}" }. - map { |r| r[7] }. - map { |r| r=="" ? '""' : r }. - join(',') + extract_instruction_list instructions, 7 end def turn_list instructions @@ -125,15 +123,20 @@ def turn_list instructions # replace instructions codes with strings # "11-3" (enter roundabout and leave a 3rd exit) gets converted to "enter_roundabout-3" instructions.map do |r| - r[0].to_s.gsub!(/^\d*/) do |match| + r[0].to_s.gsub(/^\d*/) do |match| types[match.to_i].to_s end end.join(',') end def mode_list instructions - instructions.reject { |r| r[0].to_s=="#{DESTINATION_REACHED}" }. - map { |r| r[8] }. - map { |r| (r=="" || r==nil) ? '""' : r }. - join(',') + extract_instruction_list instructions, 8 +end + +def time_list instructions + extract_instruction_list instructions, 4, "s" +end + +def distance_list instructions + extract_instruction_list instructions, 2, "m" end \ No newline at end of file diff --git a/features/testbot/time.feature b/features/testbot/time.feature index 53901ba0dcc..f15a499b830 100644 --- a/features/testbot/time.feature +++ b/features/testbot/time.feature @@ -16,15 +16,15 @@ Feature: Estimation of travel time | f | e | d | And the ways - | nodes | highway | - | xa | primary | - | xb | primary | - | xc | primary | - | xd | primary | - | xe | primary | - | xf | primary | - | xg | primary | - | xh | primary | + | nodes | highway | + | xa | primary | + | xb | primary | + | xc | primary | + | xd | primary | + | xe | primary | + | xf | primary | + | xg | primary | + | xh | primary | When I route I should get | from | to | route | time | @@ -45,15 +45,15 @@ Feature: Estimation of travel time | f | e | d | And the ways - | nodes | highway | - | xa | primary | - | xb | primary | - | xc | primary | - | xd | primary | - | xe | primary | - | xf | primary | - | xg | primary | - | xh | primary | + | nodes | highway | + | xa | primary | + | xb | primary | + | xc | primary | + | xd | primary | + | xe | primary | + | xf | primary | + | xg | primary | + | xh | primary | When I route I should get | from | to | route | time | @@ -74,15 +74,15 @@ Feature: Estimation of travel time | f | e | d | And the ways - | nodes | highway | - | xa | primary | - | xb | primary | - | xc | primary | - | xd | primary | - | xe | primary | - | xf | primary | - | xg | primary | - | xh | primary | + | nodes | highway | + | xa | primary | + | xb | primary | + | xc | primary | + | xd | primary | + | xe | primary | + | xf | primary | + | xg | primary | + | xh | primary | When I route I should get | from | to | route | time | @@ -103,15 +103,15 @@ Feature: Estimation of travel time | f | e | d | And the ways - | nodes | highway | - | xa | primary | - | xb | primary | - | xc | primary | - | xd | primary | - | xe | primary | - | xf | primary | - | xg | primary | - | xh | primary | + | nodes | highway | + | xa | primary | + | xb | primary | + | xc | primary | + | xd | primary | + | xe | primary | + | xf | primary | + | xg | primary | + | xh | primary | When I route I should get | from | to | route | time | @@ -183,9 +183,9 @@ Feature: Estimation of travel time | | | e | And the ways - | nodes | highway | - | abc | primary | - | cde | tertiary | + | nodes | highway | + | abc | primary | + | cde | tertiary | When I route I should get | from | to | route | time | @@ -213,3 +213,26 @@ Feature: Estimation of travel time | 4 | 3 | ab | 10s +-1 | | 4 | 2 | ab | 20s +-1 | | 4 | 1 | ab | 30s +-1 | + + @bug + Scenario: Total travel time should match sum of times of individual ways + Given a grid size of 1000 meters + And the node map + | a | b | | | | + | | | | | | + | | c | | | d | + + And the ways + | nodes | highway | + | ab | primary | + | bc | primary | + | cd | primary | + + When I route I should get + | from | to | route | distances | distance | times | time | + | a | b | ab | 1000m +-1 | 1000m +-1 | 100s +-1 | 100s +-1 | + | b | c | bc | 2000m +-1 | 2000m +-1 | 200s +-1 | 200s +-1 | + | c | d | cd | 3000m +-1 | 3000m +-1 | 300s +-1 | 300s +-1 | + | a | c | ab,bc | 1000m,2000m +-1 | 3000m +-1 | 100s,200s +-1 | 300s +-1 | + | b | d | bc,cd | 2000m,3000m +-1 | 5000m +-1 | 200s,300s +-1 | 500s +-1 | + | a | d | ab,bc,cd | 1000m,2000m,3000m +-1 | 6000m +-1 | 100s,200s,300s +-1 | 600s +-1 |