enable testing of way names, including ways with empty or missing name tags
This commit is contained in:
parent
15f2b21b62
commit
0984a669ce
41
features/names.feature
Normal file
41
features/names.feature
Normal file
@ -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 |
|
@ -31,21 +31,35 @@ end
|
||||
|
||||
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
|
||||
|
||||
|
@ -62,7 +62,7 @@ end
|
||||
|
||||
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
features/utf.feature
Normal file
18
features/utf.feature
Normal file
@ -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 Москва |
|
Loading…
Reference in New Issue
Block a user