1 class NodeController < ApplicationController
4 before_filter :authorize
10 node = Node.from_xml(request.raw_post, true)
12 render :text => "XML didn't parse", :status => 400 # if we got here the doc didnt parse
17 node.user_id = @user.id
19 if node.save_with_history
20 render :text => node.id
22 render :nothing => true, :status => 500
27 render :nothing => true, :status => 400 # if we got here the doc didnt parse
32 render :nothing => true, :status => 500 # something went very wrong
36 unless Node.exists?(params[:id])
37 render :nothing => true, :status => 404
41 node = Node.find(params[:id])
47 render :nothing => true, :status => 500
52 render :nothing => true, :status => 410
56 render :text => node.to_xml.to_s
62 node.save_with_history
63 render :nothing => true
65 render :nothing => true, :status => 410
69 new_node = Node.from_xml(request.raw_post)
71 node.timestamp = Time.now
72 node.user_id = @user.id
74 node.latitude = new_node.latitude
75 node.longitude = new_node.longitude
76 node.tags = new_node.tags
78 if node.id == new_node.id and node.save_with_history
79 render :nothing => true, :status => 200
81 render :nothing => true, :status => 500
89 node = Node.find(params[:id])
92 render :nothing => true, :staus => 404
96 doc = XML::Document.new
97 doc.encoding = 'UTF-8'
98 root = XML::Node.new 'osm'
99 root['version'] = '0.4'
100 root['generator'] = 'OpenStreetMap server'
103 node.old_nodes.each do |old_node|
104 el1 = XML::Node.new 'node'
105 el1['id'] = old_node.id.to_s
106 el1['lat'] = old_node.latitude.to_s
107 el1['lon'] = old_node.longitude.to_s
108 Node.split_tags(el1, old_node.tags)
109 el1['visible'] = old_node.visible.to_s
110 el1['timestamp'] = old_node.timestamp.xmlschema
114 render :text => doc.to_s