-
- 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]
+
+ [way_ids, points, relation_ids]
+ end
+
+ # Find deleted ways in current bounding box (similar to whichways, but ways
+ # with a deleted node only - not POIs or relations).
+
+ def whichways_deleted(xmin, ymin, xmax, ymax) #:doc:
+ xmin -= 0.01; ymin -= 0.01
+ xmax += 0.01; ymax += 0.01
+
+ nodes_in_area = Node.find_by_area(ymin, xmin, ymax, xmax, :conditions => "current_nodes.visible = 0 AND current_ways.visible = 0", :include => :ways_via_history)
+ way_ids = nodes_in_area.collect { |node| node.ways_via_history_ids }.flatten.uniq
+
+ [way_ids]
+ end
+
+ # Get a way including nodes and tags.
+ # Returns 0 (success), a Potlatch-style array of points, and a hash of tags.
+
+ def getway(wayid) #:doc:
+ if POTLATCH_USE_SQL then
+ points = sql_get_nodes_in_way(wayid)
+ tags = sql_get_tags_in_way(wayid)
+ else
+ # Ideally we would do ":include => :nodes" here but if we do that
+ # then rails only seems to return the first copy of a node when a
+ # way includes a node more than once
+ way = Way.find(wayid)
+ points = way.nodes.collect do |node|
+ [node.lon, node.lat, node.id, nil, node.tags_as_hash]
+ end
+ tags = way.tags