1 class NodeController < ApplicationController
4 before_filter :authorize
8 node = Node.from_xml(request.raw_post, true)
11 node.user_id = @user.id
12 if node.save_with_history
14 render :text => node.id
16 render :nothing => true, :status => 500
21 render :nothing => true, :status => 400 # if we got here the doc didnt parse
26 render :nothing => true, :status => 500 # something went very wrong
30 unless Node.exists?(params[:id])
31 render :nothing => true, :status => 400
35 node = Node.find(params[:id])
41 render :nothing => true, :status => 500
46 render :nothing => true, :status => 410
50 render :text => node.to_xml.to_s
56 node.save_with_history
57 render :nothing => true
59 render :nothing => true, :status => 410
63 new_node = Node.from_xml(request.raw_post)
65 node.timestamp = Time.now
66 node.user_id = @user.id
68 node.latitude = new_node.latitude
69 node.longitude = new_node.longitude
70 node.tags = new_node.tags
72 if node.id == new_node.id and node.save_with_history
73 render :nothing => true, :status => 200
75 render :nothing => true, :status => 500
83 node = Node.find(params[:id])
86 render :nothing => true, :staus => 404
90 doc = XML::Document.new
91 doc.encoding = 'UTF-8'
92 root = XML::Node.new 'osm'
93 root['version'] = '0.4'
94 root['generator'] = 'OpenStreetMap server'
97 node.old_nodes.each do |old_node|
98 el1 = XML::Node.new 'node'
99 el1['id'] = old_node.id.to_s
100 el1['lat'] = old_node.latitude.to_s
101 el1['lon'] = old_node.longitude.to_s
102 Node.split_tags(el1, old_node.tags)
103 el1['visible'] = old_node.visible.to_s
104 el1['timestamp'] = old_node.timestamp.xmlschema
108 render :text => doc.to_s