- relations = Relation.find(:all,
- :joins => "INNER JOIN current_relation_tags ON current_relation_tags.id = current_relations.id",
- :conditions => cond_rel, :limit => 100)
- end
-
- # then ways
- if do_ways
- ways = Way.find(:all,
- :joins => "INNER JOIN current_way_tags ON current_way_tags.id = current_ways.id",
- :conditions => cond_way, :limit => 100)
- end
-
- # Now, nodes
- if do_nodes
- nodes = Node.find(:all,
- :joins => "INNER JOIN current_node_tags ON current_node_tags.id = current_nodes.id",
- :conditions => cond_node, :limit => 2000)
+ relations = Relation.joins(:relation_tags)
+ relations = relations.where(:current_relation_tags => { :k => type }) if type
+ relations = relations.where(:current_relation_tags => { :v => value }) if value
+ relations = relations.limit(2000)
+ else
+ relations = Array.new