1 class NodeController < ApplicationController
4 before_filter :authorize
7 response.headers["Content-Type"] = 'application/xml'
11 node = Node.from_xml(request.raw_post, true)
13 render :text => "XML didn't parse", :status => 400 # if we got here the doc didnt parse
18 node.user_id = @user.id
20 if node.save_with_history
21 render :text => node.id
23 render :nothing => true, :status => 500
28 render :nothing => true, :status => 400 # if we got here the doc didnt parse
33 render :nothing => true, :status => 500 # something went very wrong
37 response.headers["Content-Type"] = 'application/xml'
38 unless Node.exists?(params[:id])
39 render :nothing => true, :status => 404
43 node = Node.find(params[:id])
49 render :nothing => true, :status => 500
54 render :nothing => true, :status => 410
58 render :text => node.to_xml.to_s
64 node.save_with_history
65 render :nothing => true
67 render :nothing => true, :status => 410
71 new_node = Node.from_xml(request.raw_post)
73 node.timestamp = Time.now
74 node.user_id = @user.id
76 node.latitude = new_node.latitude
77 node.longitude = new_node.longitude
78 node.tags = new_node.tags
80 if node.id == new_node.id and node.save_with_history
81 render :nothing => true, :status => 200
83 render :nothing => true, :status => 500
91 response.headers["Content-Type"] = 'application/xml'
92 node = Node.find(params[:id])
95 render :nothing => true, :staus => 404
99 doc = XML::Document.new
100 doc.encoding = 'UTF-8'
101 root = XML::Node.new 'osm'
102 root['version'] = '0.4'
103 root['generator'] = 'OpenStreetMap server'
106 node.old_nodes.each do |old_node|
107 el1 = XML::Node.new 'node'
108 el1['id'] = old_node.id.to_s
109 el1['lat'] = old_node.latitude.to_s
110 el1['lon'] = old_node.longitude.to_s
111 Node.split_tags(el1, old_node.tags)
112 el1['visible'] = old_node.visible.to_s
113 el1['timestamp'] = old_node.timestamp.xmlschema
117 render :text => doc.to_s