diff --git a/features/names.feature b/features/names.feature new file mode 100644 index 00000000000..828547566e4 --- /dev/null +++ b/features/names.feature @@ -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 | \ No newline at end of file diff --git a/features/step_definitions/data.rb b/features/step_definitions/data.rb index 58321fd6cc4..93501477dbe 100644 --- a/features/step_definitions/data.rb +++ b/features/step_definitions/data.rb @@ -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 diff --git a/features/support/route.rb b/features/support/route.rb index a66818f60a6..fda46c78d16 100644 --- a/features/support/route.rb +++ b/features/support/route.rb @@ -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 diff --git a/features/utf.feature b/features/utf.feature new file mode 100644 index 00000000000..306b4c8fbbf --- /dev/null +++ b/features/utf.feature @@ -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 Москва |