various things
This commit is contained in:
parent
5f2116df78
commit
59cc0015f5
11 changed files with 62 additions and 24 deletions
27
app/controllers/api_controller.rb
Normal file
27
app/controllers/api_controller.rb
Normal file
|
@ -0,0 +1,27 @@
|
|||
class ApiController < ApplicationController
|
||||
|
||||
def map
|
||||
|
||||
|
||||
doc = XML::Document.new
|
||||
doc.encoding = 'UTF-8'
|
||||
root = XML::Node.new 'osm'
|
||||
root['version'] = '0.4'
|
||||
root['generator'] = 'OpenStreetMap server'
|
||||
doc.root = root
|
||||
|
||||
render :text => doc.to_s
|
||||
|
||||
#el1 = XML::Node.new 'node'
|
||||
#el1['id'] = self.id.to_s
|
||||
#el1['lat'] = self.latitude.to_s
|
||||
#el1['lon'] = self.longitude.to_s
|
||||
#Node.split_tags(el1, self.tags)
|
||||
#el1['visible'] = self.visible.to_s
|
||||
#el1['timestamp'] = self.timestamp.xmlschema
|
||||
#root << el1
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
|
@ -1,2 +0,0 @@
|
|||
class MapController < ApplicationController
|
||||
end
|
|
@ -5,12 +5,17 @@ class NodeController < ApplicationController
|
|||
|
||||
def create
|
||||
if request.put?
|
||||
node = Node.from_xml(request.raw_post, true)
|
||||
node = nil
|
||||
begin
|
||||
node = Node.from_xml(request.raw_post, true)
|
||||
rescue
|
||||
render :text => "XML didn't parse", :status => 400 # if we got here the doc didnt parse
|
||||
return
|
||||
end
|
||||
|
||||
if node
|
||||
node.user_id = @user.id
|
||||
if node.save_with_history
|
||||
|
||||
render :text => node.id
|
||||
else
|
||||
render :nothing => true, :status => 500
|
||||
|
|
2
app/helpers/api_helper.rb
Normal file
2
app/helpers/api_helper.rb
Normal file
|
@ -0,0 +1,2 @@
|
|||
module ApiHelper
|
||||
end
|
|
@ -1,2 +0,0 @@
|
|||
module MapHelper
|
||||
end
|
5
app/models/api.rb
Normal file
5
app/models/api.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class Api < ActiveRecord::Base
|
||||
|
||||
|
||||
|
||||
end
|
|
@ -1,2 +0,0 @@
|
|||
class Map < ActiveRecord::Base
|
||||
end
|
|
@ -27,8 +27,10 @@ class Node < ActiveRecord::Base
|
|||
return nil
|
||||
end
|
||||
|
||||
if pt['id'] != '0'
|
||||
node.id = pt['id'].to_i
|
||||
unless create
|
||||
if pt['id'] != '0'
|
||||
node.id = pt['id'].to_i
|
||||
end
|
||||
end
|
||||
|
||||
node.visible = pt['visible'] and pt['visible'] == 'true'
|
||||
|
@ -102,5 +104,4 @@ class Node < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue