]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/amf_controller.rb
trap for #971 until I can work out why it's doing it
[rails.git] / app / controllers / amf_controller.rb
index 4214448696d6fb2d85f7f37fb1b0daec83ca30dd..359b45326b99137b89bfaaba944959b15a45d503 100644 (file)
@@ -376,10 +376,11 @@ class AmfController < ApplicationController
 
     RAILS_DEFAULT_LOGGER.info("  Message: putway, id=#{originalway}")
 
-    # -- Check for null IDs or short ways
+    # -- Check for null IDs, short ways or lats=90
 
     points.each do |a|
       if a[2]==0 or a[2].nil? then return -2,"Server error - node with id 0 found in way #{originalway}." end
+      if coord2lat(a[1],masterscale,basey)==90 then return -2,"Server error - node with lat -90 found in way #{originalway}." end
     end
     
     if points.length<2 then return -2,"Server error - way is only #{points.length} points long." end
@@ -638,8 +639,8 @@ class AmfController < ApplicationController
     #   which means the SWF needs to allocate new ids
     # - if it's an invisible node, we can reuse the old node id
 
-    # get node list from specified version of way,
-    # and the _current_ lat/long/tags of each node
+    # -----    get node list from specified version of way,
+    #          and the _current_ lat/long/tags of each node
 
     row=ActiveRecord::Base.connection.select_one("SELECT timestamp FROM ways WHERE version=#{version} AND id=#{id}")
     waytime=row['timestamp']
@@ -654,31 +655,31 @@ class AmfController < ApplicationController
   EOF
     rows=ActiveRecord::Base.connection.select_all(sql)
 
-    # if historic (full revert), get the old version of each node
-    # - if it's in another way now, generate a new id
-    # - if it's not in another way, use the old ID
+    # -----    if historic (full revert), get the old version of each node
+    #          - if it's in another way now, generate a new id
+    #          - if it's not in another way, use the old ID
+
     if historic then
       rows.each_index do |i|
         sql=<<-EOF
     SELECT latitude*0.0000001 AS latitude,longitude*0.0000001 AS longitude,tags,cwn.id AS currentway 
       FROM nodes n
  LEFT JOIN current_way_nodes cwn
-      ON cwn.node_id=n.id
+ LEFT JOIN current_way_nodes cwn
+        ON cwn.node_id=n.id AND cwn.id!=#{id} 
      WHERE n.id=#{rows[i]['id']} 
        AND n.timestamp<="#{waytime}" 
-     AND cwn.id!=#{id} 
-     ORDER BY n.timestamp DESC 
+  ORDER BY n.timestamp DESC 
      LIMIT 1
     EOF
         row=ActiveRecord::Base.connection.select_one(sql)
-        unless row.nil? then
-          nx=row['longitude'].to_f
-          ny=row['latitude'].to_f
+        nx=row['longitude'].to_f
+        ny=row['latitude'].to_f
+        if (!row.nil?)
           if (row['currentway'] && (nx!=rows[i]['longitude'].to_f or ny!=rows[i]['latitude'].to_f or row['tags']!=rows[i]['tags'])) then rows[i]['id']=-1 end
-          rows[i]['longitude']=nx
-          rows[i]['latitude' ]=ny
-          rows[i]['tags'     ]=row['tags']
-        end
+               end
+        rows[i]['longitude']=nx
+        rows[i]['latitude' ]=ny
+        rows[i]['tags'     ]=row['tags']
       end
     end
     rows