X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/16a641ac2a663ea926566a5cca2575ee295e8555..740511066fcfaa910e0d9a9d86f6fefce85af343:/app/models/relation.rb diff --git a/app/models/relation.rb b/app/models/relation.rb index a5d463ffb..0d10b7728 100644 --- a/app/models/relation.rb +++ b/app/models/relation.rb @@ -102,6 +102,25 @@ class Relation < ActiveRecord::Base return el1 end + def self.find_for_nodes_and_ways(node_ids, way_ids) + # collect relationships. currently done in one big block at the end; + # may need to move this upwards if people want automatic completion of + # relationships, i.e. deliver referenced objects like we do with ways... + return [] if node_ids.empty? and node_ids.empty? + relations = Array.new + if node_ids.length > 0 + relations += Relation.find_by_sql("select e.* from current_relations e,current_relation_members em where " + + "e.visible=1 and " + + "em.id = e.id and em.member_type='node' and em.member_id in (#{node_ids.join(',')})") + end + if way_ids.length > 0 + relations += Relation.find_by_sql("select e.* from current_relations e,current_relation_members em where " + + "e.visible=1 and " + + "em.id = e.id and em.member_type='way' and em.member_id in (#{way_ids.join(',')})") + end + end + + # FIXME is this really needed? def members unless @members