Skip to content

Commit 82ead0a

Browse files
author
DennisOSRM
committed
Merge branch 'master' of https://[email protected]/DennisOSRM/Project-OSRM.git
2 parents 5ff2fc9 + b353df8 commit 82ead0a

File tree

5 files changed

+162
-2
lines changed

5 files changed

+162
-2
lines changed

features/bearing.feature

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
@routing @bearing
2+
Feature: Compass bearing
3+
4+
@northwest
5+
Scenario: Bearing when going northwest
6+
Given the node map
7+
| b | |
8+
| | a |
9+
10+
And the ways
11+
| nodes |
12+
| ab |
13+
14+
When I route I should get
15+
| from | to | route | compass | bearing |
16+
| a | b | ab | NW | 45 |
17+
18+
@west
19+
Scenario: Bearing when going west
20+
Given the node map
21+
| b | a |
22+
23+
And the ways
24+
| nodes |
25+
| ab |
26+
27+
When I route I should get
28+
| from | to | route | compass | bearing |
29+
| a | b | ab | W | 90 |
30+
31+
Scenario: Bearing af 45 degree intervals
32+
Given the node map
33+
| b | a | h |
34+
| c | x | g |
35+
| d | e | f |
36+
37+
And the ways
38+
| nodes |
39+
| xa |
40+
| xb |
41+
| xc |
42+
| xd |
43+
| xe |
44+
| xf |
45+
| xg |
46+
| xh |
47+
48+
When I route I should get
49+
| from | to | route | compass | bearing |
50+
| x | a | xa | N | 0 |
51+
| x | b | xb | NW | 45 |
52+
| x | c | xc | W | 90 |
53+
| x | d | xd | SW | 135 |
54+
| x | e | xe | S | 180 |
55+
| x | f | xf | SE | 225 |
56+
| x | g | xg | E | 270 |
57+
| x | h | xh | NE | 315 |
58+
59+
Scenario: Bearing in a roundabout
60+
Given the node map
61+
| | d | c | |
62+
| e | | | b |
63+
| f | | | a |
64+
| | g | h | |
65+
66+
And the ways
67+
| nodes | oneway |
68+
| ab | yes |
69+
| bc | yes |
70+
| cd | yes |
71+
| de | yes |
72+
| ef | yes |
73+
| fg | yes |
74+
| gh | yes |
75+
| ha | yes |
76+
77+
When I route I should get
78+
| from | to | route | compass | bearing |
79+
| c | b | cd,de,ef,fg,gh,ha,ab | W,SW,S,SE,E,NE,N | 90,135,180,225,270,0,45 |
80+
| g | f | gh,ha,ab,bc,cd,de,ef | E,NE,N,NW,W,SW,S | 270,315,0,45,90,180,225 |
81+
82+
Scenario: Bearing should stay constant when zig-zagging
83+
Given the node map
84+
| b | d | f | h |
85+
| a | c | e | g |
86+
87+
And the ways
88+
| nodes |
89+
| ab |
90+
| bc |
91+
| cd |
92+
| de |
93+
| ef |
94+
| fg |
95+
| gh |
96+
97+
When I route I should get
98+
| from | to | route | compass | bearing |
99+
| a | h | ab,bc,cd,de,ef,fg,gh | N,SE,N,SE,N,SE,N | 0,225,0,225,0,225,0 |

features/step_definitions/routing.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ def computed_route
202202
json = JSON.parse response.body
203203
if json['status'] == 0
204204
instructions = way_list json['route_instructions']
205+
bearings = bearing_list json['route_instructions']
206+
compasses = compass_list json['route_instructions']
205207
end
206208
end
207209

@@ -221,6 +223,12 @@ def computed_route
221223
raise "*** time must be specied in seconds. (ex: 60s)" unless row['time'] =~ /\d+s/
222224
got['time'] = instructions ? "#{json['route_summary']['total_time'].to_s}s" : nil
223225
end
226+
if table.headers.include? 'bearing'
227+
got['bearing'] = bearings
228+
end
229+
if table.headers.include? 'compass'
230+
got['compass'] = compasses
231+
end
224232
end
225233

226234
if row != got

features/support/data.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,11 @@ def reprocess
166166
Dir.chdir TEST_FOLDER do
167167
write_speedprofile
168168
write_osm
169-
#convert_osm_to_pbf
169+
convert_osm_to_pbf
170170
unless extracted?
171171
log_preprocess_info
172172
log "== Extracting #{@osm_file}.osm...", :preprocess
173-
unless system "../osrm-extract #{@osm_file}.osm 1>>#{PREPROCESS_LOG_FILE} 2>>#{PREPROCESS_LOG_FILE}"
173+
unless system "../osrm-extract #{@osm_file}.osm.pbf 1>>#{PREPROCESS_LOG_FILE} 2>>#{PREPROCESS_LOG_FILE}"
174174
log "*** Exited with code #{$?.exitstatus}.", :preprocess
175175
raise "*** osrm-extract exited with code #{$?.exitstatus}. The file preprocess.log might contain more info."
176176
end

features/support/route.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,17 @@ def way_list instructions
6969
map { |r| r=="" ? '""' : r }.
7070
join(',')
7171
end
72+
73+
def compass_list instructions
74+
instructions.reject { |r| r[0].to_s=="#{DESTINATION_REACHED}" }.
75+
map { |r| r[6] }.
76+
map { |r| r=="" ? '""' : r }.
77+
join(',')
78+
end
79+
80+
def bearing_list instructions
81+
instructions.reject { |r| r[0].to_s=="#{DESTINATION_REACHED}" }.
82+
map { |r| r[7] }.
83+
map { |r| r=="" ? '""' : r }.
84+
join(',')
85+
end

features/weird.feature

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
@routing @weird
2+
Feature: Weird routings discovered
3+
4+
Scenario: Routing on a oneway roundabout
5+
Given the node map
6+
| | d | c | |
7+
| e | | | b |
8+
| f | | | a |
9+
| | g | h | |
10+
11+
And the ways
12+
| nodes | oneway |
13+
| ab | yes |
14+
| bc | yes |
15+
| cd | yes |
16+
| de | yes |
17+
| ef | yes |
18+
| fg | yes |
19+
| gh | yes |
20+
| ha | yes |
21+
22+
When I route I should get
23+
| from | to | route |
24+
| a | b | ab |
25+
| b | c | bc |
26+
| c | d | cd |
27+
| d | e | de |
28+
| e | f | ef |
29+
| f | g | fg |
30+
| g | h | gh |
31+
| h | a | ha |
32+
| b | a | bc,cd,de,ef,fg,gh,ha |
33+
| c | b | cd,de,ef,fg,gh,ha,ab |
34+
| d | c | de,ef,fg,gh,ha,ab,bc |
35+
| e | d | ef,fg,gh,ha,ab,bc,cd |
36+
| f | e | fg,gh,ha,ab,bc,cd,de |
37+
| g | f | gh,ha,ab,bc,cd,de,ef |
38+
| h | g | ha,ab,bc,cd,de,ef,fg |
39+
| a | h | ab,bc,cd,de,ef,fg,gh |

0 commit comments

Comments
 (0)