fix revert to cope with moved nodes properly (OH NOES I updated some SQL)
This commit is contained in:
parent
f08c9de073
commit
889ee9e368
1 changed files with 16 additions and 16 deletions
|
@ -638,7 +638,7 @@ class AmfController < ApplicationController
|
||||||
# which means the SWF needs to allocate new ids
|
# which means the SWF needs to allocate new ids
|
||||||
# - if it's an invisible node, we can reuse the old node id
|
# - if it's an invisible node, we can reuse the old node id
|
||||||
|
|
||||||
# get node list from specified version of way,
|
# ----- get node list from specified version of way,
|
||||||
# and the _current_ lat/long/tags of each node
|
# 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}")
|
row=ActiveRecord::Base.connection.select_one("SELECT timestamp FROM ways WHERE version=#{version} AND id=#{id}")
|
||||||
|
@ -654,33 +654,33 @@ class AmfController < ApplicationController
|
||||||
EOF
|
EOF
|
||||||
rows=ActiveRecord::Base.connection.select_all(sql)
|
rows=ActiveRecord::Base.connection.select_all(sql)
|
||||||
|
|
||||||
# if historic (full revert), get the old version of each node
|
# ----- 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 in another way now, generate a new id
|
||||||
# - if it's not in another way, use the old ID
|
# - if it's not in another way, use the old ID
|
||||||
|
|
||||||
if historic then
|
if historic then
|
||||||
rows.each_index do |i|
|
rows.each_index do |i|
|
||||||
sql=<<-EOF
|
sql=<<-EOF
|
||||||
SELECT latitude*0.0000001 AS latitude,longitude*0.0000001 AS longitude,tags,cwn.id AS currentway
|
SELECT latitude*0.0000001 AS latitude,longitude*0.0000001 AS longitude,tags,cwn.id AS currentway
|
||||||
FROM nodes n
|
FROM nodes n
|
||||||
LEFT JOIN current_way_nodes cwn
|
LEFT JOIN current_way_nodes cwn
|
||||||
ON cwn.node_id=n.id
|
ON cwn.node_id=n.id AND cwn.id!=#{id}
|
||||||
WHERE n.id=#{rows[i]['id']}
|
WHERE n.id=#{rows[i]['id']}
|
||||||
AND n.timestamp<="#{waytime}"
|
AND n.timestamp<="#{waytime}"
|
||||||
AND cwn.id!=#{id}
|
|
||||||
ORDER BY n.timestamp DESC
|
ORDER BY n.timestamp DESC
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
EOF
|
EOF
|
||||||
row=ActiveRecord::Base.connection.select_one(sql)
|
row=ActiveRecord::Base.connection.select_one(sql)
|
||||||
unless row.nil? then
|
|
||||||
nx=row['longitude'].to_f
|
nx=row['longitude'].to_f
|
||||||
ny=row['latitude'].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
|
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
|
||||||
|
end
|
||||||
rows[i]['longitude']=nx
|
rows[i]['longitude']=nx
|
||||||
rows[i]['latitude' ]=ny
|
rows[i]['latitude' ]=ny
|
||||||
rows[i]['tags' ]=row['tags']
|
rows[i]['tags' ]=row['tags']
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
rows
|
rows
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue