X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/112950ca3afd95c8b63e69f7b580585529b6cbaf..889ee9e3680ea693351801a0f041852389a24db6:/app/controllers/amf_controller.rb diff --git a/app/controllers/amf_controller.rb b/app/controllers/amf_controller.rb index a2bb1b454..4eda7b00a 100644 --- a/app/controllers/amf_controller.rb +++ b/app/controllers/amf_controller.rb @@ -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 @@ -594,8 +594,8 @@ class AmfController < ApplicationController # 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+id.to_i.abs.to_s+Time.new.to_i.to_s - db_uqn='unin'+(rand*100).to_i.to_s+uid.to_s+way.to_i.abs.to_s+Time.new.to_i.to_s + 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) @@ -638,8 +638,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 +654,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