-
- def getway(args)
- objname,wayid,$baselong,$basey,$masterscale=args
- wayid=wayid.to_i
- points=[]
- lastid=-1
- xmin=999999; xmax=-999999
- ymin=999999; ymax=-999999
-
-RAILS_DEFAULT_LOGGER.error("Looking for way #{wayid}")
- nodelist=ActiveRecord::Base.connection.select_all "SELECT n1.latitude AS lat1,n1.longitude AS long1,n1.id AS id1,n1.tags as tags1, "+
- " n2.latitude AS lat2,n2.longitude AS long2,n2.id AS id2,n2.tags as tags2,segment_id "+
- " FROM current_way_segments,current_segments,current_nodes AS n1,current_nodes AS n2 "+
- " WHERE current_way_segments.id=#{wayid} "+
- " AND segment_id=current_segments.id "+
- " AND n1.id=node_a and n2.id=node_b "+
- " ORDER BY sequence_id"
- nodelist.each {|row|
- xs1=long2coord(row['long1'].to_f); ys1=lat2coord(row['lat1'].to_f)
- xs2=long2coord(row['long2'].to_f); ys2=lat2coord(row['lat2'].to_f)
- if (row['id1'].to_i!=lastid)
- points<<[xs1,ys1,row['id1'].to_i,0,tag2array(row['tags1']),0]
- end
- lastid=row['id2'].to_i
- points<<[xs2,ys2,row['id2'].to_i,1,tag2array(row['tags2']),row['segment_id'].to_i]
- xmin=[xmin,row['long1'].to_f,row['long2'].to_f].min
- xmax=[xmax,row['long1'].to_f,row['long2'].to_f].max
- ymin=[ymin,row['lat1'].to_f,row['lat2'].to_f].min
- ymax=[ymax,row['lat1'].to_f,row['lat2'].to_f].max
- }
-
- attributes={}
- attrlist=ActiveRecord::Base.connection.select_all "SELECT k,v FROM current_way_tags WHERE id=#{wayid}"
- attrlist.each {|a| attributes[a['k']]=a['v'] }
-
-RAILS_DEFAULT_LOGGER.error("Way #{wayid} #{xmin},#{xmax},#{ymin},#{ymax}")
- [objname,points,attributes,xmin,xmax,ymin,ymax]
+ [wayid,points,tags]
+ end
+
+ # Get an old version of a way, and all constituent nodes.
+ #
+ # For undelete (version=0), always uses the most recent version of each node,
+ # even if it's moved. For revert (version=1+), uses the node in existence
+ # at the time, generating a new id if it's still visible and has been moved/
+ # retagged.
+
+ def getway_old(id,version) #:doc:
+ if version<0
+ old_way = OldWay.find(:first, :conditions => ['visible=1 AND id=?', id], :order => 'version DESC')
+ points = old_way.get_nodes_undelete
+ else
+ old_way = OldWay.find(:first, :conditions => ['id=? AND version=?', id, version])
+ points = old_way.get_nodes_revert