Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable testing of way names, including ways with empty or missing names #139

Merged
merged 1 commit into from
Feb 21, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions features/names.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
@routing @names
Feature: Street names in instructions

Scenario: A named street
Given the nodes
| a | b |
| | c |

And the ways
| nodes | name |
| ab | My Way |
| bc | Your Way |

When I route I should get
| from | to | route |
| a | c | My Way,Your Way |

Scenario: Use way type to describe unnamed ways
Given the nodes
| a | b | c |

And the ways
| nodes | highway | name |
| ab | cycleway | |
| bc | track | |

When I route I should get
| from | to | route |
| a | c | cycleway,trac |

Scenario: Don't create instructions for every node of unnamed ways
Given the nodes
| a | b | c | d |

And the ways
| nodes | highway | name |
| abcd | cycleway | |

When I route I should get
| from | to | route |
| a | d | cycleway |
26 changes: 20 additions & 6 deletions features/step_definitions/data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,35 @@

Given /^the ways$/ do |table|
table.hashes.each do |row|
name = row.delete 'nodes'
raise "*** duplicate way '#{name}'" if name_way_hash[name]
way = OSM::Way.new make_osm_id, OSM_USER, OSM_TIMESTAMP
defaults = { 'highway' => 'primary' }
way << defaults.merge( 'name' => name ).merge(row)
way.uid = OSM_UID
name.each_char do |c|

nodes = row.delete 'nodes'
raise "*** duplicate way '#{nodes}'" if name_way_hash[nodes]
nodes.each_char do |c|
raise "*** node invalid name '#{c}', must be single characters" unless c.size == 1
raise "*** ways cannot use numbered nodes, '#{name}'" unless c.match /[a-z]/
node = find_node_by_name(c)
raise "*** unknown node '#{c}'" unless node
way << node
end

defaults = { 'highway' => 'primary' }
tags = defaults.merge(row)

if row['name'] == nil
tags['name'] = nodes
elsif (row['name'] == '""') || (row['name'] == "''")
tags['name'] = ''
elsif row['name'] == ''
tags.delete 'name'
else
tags['name'] = row['name']
end

way << tags
osm_db << way
name_way_hash[name] = way
name_way_hash[nodes] = way
end
end

Expand Down
4 changes: 2 additions & 2 deletions features/support/route.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def route_status response

def way_list instructions
instructions.
#reject { |i| i[2]<=1 }. #FIXME temporary hack to ignore instructions with length==0
map { |r| r[1] }.
reject(&:empty?).join(',')
map { |r| r=="" ? '""' : r }.
join(',')
end
18 changes: 18 additions & 0 deletions features/utf.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@routing @utf
Feature: Basic Routing

Scenario: Streetnames with UTF characters
Given the nodes
| a | b | c | d |

And the ways
| nodes | name |
| ab | Scandinavian København |
| bc | Japanese 東京 |
| cd | Cyrillic Москва |

When I route I should get
| from | to | route |
| a | b | Scandinavian København |
| b | c | Japanese 東京 |
| c | d | Cyrillic Москва |