diff --git a/app/helpers/browse_helper.rb b/app/helpers/browse_helper.rb index 482503e8ae..ba7172204d 100644 --- a/app/helpers/browse_helper.rb +++ b/app/helpers/browse_helper.rb @@ -1,4 +1,22 @@ module BrowseHelper + def group_way_nodes(way) + groups = [] + + way.way_nodes.each do |way_node| + related_ways = related_ways_of_way_node(way_node) + if !groups.empty? && way_node.node.tags.empty? && groups.last[:nodes].last.tags.empty? && groups.last[:related_ways] == related_ways + groups.last[:nodes] << way_node.node + else + groups << { + :nodes => [way_node.node], + :related_ways => related_ways + } + end + end + + groups + end + def element_icon(type, object) selected_icon_data = { :filename => "#{type}.svg", :priority => 1 } @@ -119,4 +137,8 @@ def sidebar_classic_pagination(pages, page_param) def name_locales(object) object.tags.keys.map { |k| Regexp.last_match(1) if k =~ /^name:(.*)$/ }.flatten end + + def related_ways_of_way_node(way_node) + way_node.node.ways.uniq.sort.reject { |related_way| related_way.id == way_node.way_id } + end end diff --git a/app/views/browse/_way.html.erb b/app/views/browse/_way.html.erb index 9181a3e080..1a6f9cee49 100644 --- a/app/views/browse/_way.html.erb +++ b/app/views/browse/_way.html.erb @@ -25,15 +25,19 @@
> <%= t ".nodes_count", :count => way.way_nodes.count %>