]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/amf_controller.rb
Fix spelling mistake.
[rails.git] / app / controllers / amf_controller.rb
index 935746ed4fa3aa3298cb2603d6b0ce9c6756756d..7f85280b79d29d5b320460d01f028f14727a3fd0 100644 (file)
@@ -29,7 +29,7 @@ class AmfController < ApplicationController
   include Potlatch
 
   session :off
-  before_filter :check_write_availability
+  before_filter :check_api_writable
 
   # Main AMF handlers: process the raw AMF string (using AMF library) and
   # calls each action (private method) accordingly.
@@ -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)
@@ -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
 
@@ -523,10 +524,10 @@ class AmfController < ApplicationController
   end
 
   # Authenticate token
-  # (could be removed if no-one uses the username+password form)
+  # (can also be of form user:pass)
 
   def getuserid(token) #:doc:
-       if (token =~ /^(.+)\+(.+)$/) then
+       if (token =~ /^(.+)\:(.+)$/) then
          user = User.authenticate(:username => $1, :password => $2)
        else
          user = User.authenticate(:token => token)