]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/amf_controller.rb
Add SOTM advert.
[rails.git] / app / controllers / amf_controller.rb
index 306b3dec84dd5be3ead36befaef87019ca18b8be..febc4db68cc6a1464e02c00bd504e739f4a587fd 100644 (file)
@@ -126,8 +126,9 @@ class AmfController < ApplicationController
   # are IDs only. 
 
   def whichways(xmin, ymin, xmax, ymax) #:doc:
-       xmin -= 0.01; ymin -= 0.01
-       xmax += 0.01; ymax += 0.01
+       enlarge = [(xmax-xmin)/8,0.01].min
+       xmin -= enlarge; ymin -= enlarge
+       xmax += enlarge; ymax += enlarge
 
        if POTLATCH_USE_SQL then
          way_ids = sql_find_way_ids_in_area(xmin, ymin, xmax, ymax)
@@ -293,9 +294,9 @@ class AmfController < ApplicationController
          if mid < 0
                mid = renumberednodes[mid] if m[0] == 'node'
                mid = renumberedways[mid] if m[0] == 'way'
-               if mid
-                 typedmembers << [m[0], mid, m[2]]
-               end
+         end
+      if mid
+           typedmembers << [m[0], mid, m[2]]
          end
        end
 
@@ -397,6 +398,14 @@ class AmfController < ApplicationController
          nodes.push(id)
        end
 
+       # -- Save revised way
+
+       way.tags = attributes
+       way.nds = nodes
+       way.user_id = uid
+       way.visible = true
+       way.save_with_history!
+
        # -- Delete any unique nodes
        
        uniques.each do |n|
@@ -408,14 +417,6 @@ class AmfController < ApplicationController
          node.save_with_history!
        end
 
-       # -- Save revised way
-
-       way.tags = attributes
-       way.nds = nodes
-       way.user_id = uid
-       way.visible = true
-       way.save_with_history!
-
        [0, originalway, way.id, renumberednodes]
   end
 
@@ -487,6 +488,7 @@ class AmfController < ApplicationController
        way.unshared_node_ids.each do |n|
          deleteitemrelations(n, 'node')
        end
+       deleteitemrelations(way_id, 'way')
 
        way.delete_with_relations_and_nodes_and_history(user)