@@ -28,35 +28,31 @@ def show
28
28
return
29
29
end
30
30
31
- nodes = Node . bbox ( @bounds ) . where ( : visible => true ) . includes ( :node_tags ) . limit ( Settings . max_number_of_nodes + 1 )
31
+ @ nodes = Node . bbox ( @bounds ) . visible . includes ( :node_tags ) . limit ( Settings . max_number_of_nodes + 1 )
32
32
33
- node_ids = nodes . collect ( &:id )
33
+ node_ids = @ nodes. collect ( &:id )
34
34
if node_ids . length > Settings . max_number_of_nodes
35
35
report_error ( "You requested too many nodes (limit is #{ Settings . max_number_of_nodes } ). Either request a smaller area, or use planet.osm" )
36
36
return
37
37
end
38
38
39
39
# get ways
40
40
# find which ways are needed
41
- ways = [ ]
41
+ @ ways = [ ]
42
42
if node_ids . empty?
43
43
list_of_way_nodes = [ ]
44
44
else
45
45
way_nodes = WayNode . where ( :node_id => node_ids )
46
46
way_ids = way_nodes . collect { |way_node | way_node . id [ 0 ] }
47
- ways = Way . preload ( :way_nodes , :way_tags ) . find ( way_ids )
47
+ @ ways = Way . preload ( :way_nodes , :way_tags ) . visible . find ( way_ids )
48
48
49
- list_of_way_nodes = ways . flat_map { |way | way . way_nodes . map ( &:node_id ) }
49
+ list_of_way_nodes = @ ways. flat_map { |way | way . way_nodes . map ( &:node_id ) }
50
50
end
51
51
52
52
# - [0] in case some thing links to node 0 which doesn't exist. Shouldn't actually ever happen but it does. FIXME: file a ticket for this
53
53
nodes_to_fetch = ( list_of_way_nodes . uniq - node_ids ) - [ 0 ]
54
54
55
- nodes += Node . includes ( :node_tags ) . find ( nodes_to_fetch ) unless nodes_to_fetch . empty?
56
-
57
- @nodes = nodes . filter ( &:visible? )
58
-
59
- @ways = ways . filter ( &:visible? )
55
+ @nodes += Node . includes ( :node_tags ) . visible . find ( nodes_to_fetch ) unless nodes_to_fetch . empty?
60
56
61
57
@relations = Relation . nodes ( @nodes ) . visible +
62
58
Relation . ways ( @ways ) . visible
0 commit comments