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
18 if node.save_with_history
19 render :text => node.id
21 render :nothing => true, :status => 500
26 render :nothing => true, :status => 400 # if we got here the doc didnt parse
31 render :nothing => true, :status => 500 # something went very wrong
35 unless Node.exists?(params[:id])
36 render :nothing => true, :status => 404
40 node = Node.find(params[:id])
46 render :nothing => true, :status => 500
51 render :nothing => true, :status => 410
55 render :text => node.to_xml.to_s
61 node.save_with_history
62 render :nothing => true
64 render :nothing => true, :status => 410
68 new_node = Node.from_xml(request.raw_post)
70 node.timestamp = Time.now
71 node.user_id = @user.id
73 node.latitude = new_node.latitude
74 node.longitude = new_node.longitude
75 node.tags = new_node.tags
77 if node.id == new_node.id and node.save_with_history
78 render :nothing => true, :status => 200
80 render :nothing => true, :status => 500
88 node = Node.find(params[:id])
91 render :nothing => true, :staus => 404
95 doc = XML::Document.new
96 doc.encoding = 'UTF-8'
97 root = XML::Node.new 'osm'
98 root['version'] = '0.4'
99 root['generator'] = 'OpenStreetMap server'
102 node.old_nodes.each do |old_node|
103 el1 = XML::Node.new 'node'
104 el1['id'] = old_node.id.to_s
105 el1['lat'] = old_node.latitude.to_s
106 el1['lon'] = old_node.longitude.to_s
107 Node.split_tags(el1, old_node.tags)
108 el1['visible'] = old_node.visible.to_s
109 el1['timestamp'] = old_node.timestamp.xmlschema
113 render :text => doc.to_s