]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/amf_controller.rb
split_node_tags: Remove old unused files.
[rails.git] / app / controllers / amf_controller.rb
index 83a6cd4b58fb871b30c4762dc7630ff6db74f4cf..4214448696d6fb2d85f7f37fb1b0daec83ca30dd 100644 (file)
@@ -123,7 +123,7 @@ class AmfController < ApplicationController
     points = nodes_not_used_in_area.collect { |n| [n.id, n.lon_potlatch(baselong,masterscale), n.lat_potlatch(basey,masterscale), n.tags_as_hash] }
 
     # find the relations used by those nodes and ways
-    relation_ids = Relation.find_for_nodes_and_ways(nodes_in_area.collect {|n| n.id}, way_ids).collect {|n| n.id}.uniq
+    relation_ids = (Relation.find_for_nodes_and_ways(nodes_in_area.collect {|n| n.id}, way_ids)).collect {|n| n.id}.uniq
 
     [way_ids,points,relation_ids]
   end
@@ -589,6 +589,21 @@ class AmfController < ApplicationController
     uid=getuserid(usertoken)
     if !uid then return -1,"You are not logged in, so the way could not be deleted." end
 
+       # FIXME
+       # the next bit removes the way from any relations
+       # the delete_with_relations_and_nodes_and_history method should do this,
+       #   but at present it just throws a 'precondition failed'
+    way=way.to_i 
+    db_now='@now'+(rand*100).to_i.to_s+uid.to_s+way.abs.to_s+Time.new.to_i.to_s
+       db_uqn='unin'+(rand*100).to_i.to_s+uid.to_s+way.abs.to_s+Time.new.to_i.to_s
+    ActiveRecord::Base.connection.execute("SET #{db_now}=NOW()")
+       createuniquenodes(way,db_uqn,[])
+       deleteuniquenoderelations(db_uqn,uid,db_now)
+    deleteitemrelations(way_id,'way',uid,db_now)
+    ActiveRecord::Base.connection.execute("DROP TEMPORARY TABLE #{db_uqn}")
+       # end of FIXME
+
+       # now delete the way
     user = User.find(uid)
     way = Way.find(way_id)
     way.delete_with_relations_and_nodes_and_history(user)