Revert Potlatch 0.10 from the trunk - we will keep it on the potlatch_010
branch for now until it has been reviewed.
This commit is contained in:
parent
62a1ec4748
commit
50c0333ea6
11 changed files with 740 additions and 1128 deletions
File diff suppressed because it is too large
Load diff
|
@ -20,10 +20,6 @@ class Node < ActiveRecord::Base
|
|||
has_many :containing_relation_members, :class_name => "RelationMember", :as => :member
|
||||
has_many :containing_relations, :class_name => "Relation", :through => :containing_relation_members, :source => :relation, :extend => ObjectFinder
|
||||
|
||||
# Atomic undelete support
|
||||
has_many :old_way_nodes
|
||||
has_many :ways_via_history, :class_name=> "Way", :through => :old_way_nodes, :source => :way
|
||||
|
||||
# Sanity check the latitude and longitude and add an error if it's broken
|
||||
def validate_position
|
||||
errors.add_to_base("Node is not in the world") unless in_world?
|
||||
|
|
|
@ -110,35 +110,6 @@ class OldWay < ActiveRecord::Base
|
|||
return el1
|
||||
end
|
||||
|
||||
# Read full version of old way
|
||||
# For get_nodes_undelete, uses same nodes, even if they've moved since
|
||||
# For get_nodes_revert, allocates new ids
|
||||
# Currently returns Potlatch-style array
|
||||
|
||||
def get_nodes_undelete
|
||||
points = []
|
||||
self.nds.each do |n|
|
||||
node=Node.find(n)
|
||||
points << [node.lon, node.lat, n, node.visible ? 1 : 0, node.tags_as_hash]
|
||||
end
|
||||
points
|
||||
end
|
||||
|
||||
def get_nodes_revert
|
||||
points=[]
|
||||
self.nds.each do |n|
|
||||
oldnode=OldNode.find(:first, :conditions=>['id=? AND timestamp<=?',n,self.timestamp], :order=>"timestamp DESC")
|
||||
curnode=Node.find(n)
|
||||
id=n; v=curnode.visible ? 1 : 0
|
||||
if oldnode.lat!=curnode.lat or oldnode.lon!=curnode.lon or oldnode.tags!=curnode.tags then
|
||||
# node has changed: if it's in other ways, give it a new id
|
||||
if curnode.ways-[self.id] then id=-1; v=nil end
|
||||
end
|
||||
points << [oldnode.lon, oldnode.lat, id, v, oldnode.tags_as_hash]
|
||||
end
|
||||
points
|
||||
end
|
||||
|
||||
# Temporary method to match interface to nodes
|
||||
def tags_as_hash
|
||||
return self.tags
|
||||
|
|
|
@ -2,7 +2,4 @@ class OldWayNode < ActiveRecord::Base
|
|||
set_table_name 'way_nodes'
|
||||
|
||||
set_primary_keys :id, :version, :sequence_id
|
||||
|
||||
# Atomic undelete support
|
||||
belongs_to :way, :foreign_key=> :id
|
||||
end
|
||||
|
|
|
@ -236,7 +236,13 @@ class Way < ActiveRecord::Base
|
|||
# delete a way and it's nodes that aren't part of other ways, with history
|
||||
def delete_with_relations_and_nodes_and_history(user)
|
||||
|
||||
node_ids_to_delete = self.unique_nodes
|
||||
node_ids = self.nodes.collect {|node| node.id }
|
||||
node_ids_not_to_delete = []
|
||||
way_nodes = WayNode.find(:all, :conditions => "node_id in (#{node_ids.join(',')}) and id != #{self.id}")
|
||||
|
||||
node_ids_not_to_delete = way_nodes.collect {|way_node| way_node.node_id}
|
||||
|
||||
node_ids_to_delete = node_ids - node_ids_not_to_delete
|
||||
|
||||
# delete the nodes not used by other ways
|
||||
node_ids_to_delete.each do |node_id|
|
||||
|
@ -252,16 +258,6 @@ class Way < ActiveRecord::Base
|
|||
|
||||
end
|
||||
|
||||
# Find nodes that belong to this way only
|
||||
def unique_nodes
|
||||
node_ids = self.nodes.collect {|node| node.id }
|
||||
if node_ids.length==0 then return [] end
|
||||
node_ids_in_other_ways = []
|
||||
way_nodes = WayNode.find(:all, :conditions => "node_id in (#{node_ids.join(',')}) and id != #{self.id}")
|
||||
node_ids_in_other_ways = way_nodes.collect {|way_node| way_node.node_id}
|
||||
return node_ids - node_ids_in_other_ways
|
||||
end
|
||||
|
||||
# Temporary method to match interface to nodes
|
||||
def tags_as_hash
|
||||
return self.tags
|
||||
|
|
|
@ -65,9 +65,9 @@
|
|||
fo.addVariable('token','<%= session[:token] %>');
|
||||
if (lat) { fo.addVariable('lat',lat); }
|
||||
if (lon) { fo.addVariable('long',lon); }
|
||||
<% if params['gpx'] %>fo.addVariable('gpx' ,'<%= h(params['gpx'] ) %>');<% end %>
|
||||
<% if params['way'] %>fo.addVariable('way' ,'<%= h(params['way'] ) %>');<% end %>
|
||||
<% if params['node'] %>fo.addVariable('node','<%= h(params['node']) %>');<% end %>
|
||||
<% if params['gpx'] %>
|
||||
fo.addVariable('gpx','<%= h(params['gpx']) %>');
|
||||
<% end %>
|
||||
fo.write("map");
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue