--- /dev/null
+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
+++ /dev/null
-class MapController < ApplicationController
-end
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
--- /dev/null
+module ApiHelper
+end
+++ /dev/null
-module MapHelper
-end
--- /dev/null
+class Api < ActiveRecord::Base
+
+
+
+end
+++ /dev/null
-class Map < ActiveRecord::Base
-end
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'
end
end
end
-
end
ActionController::Routing::Routes.draw do |map|
-# map.connect ':controller/service.wsdl', :action => 'wsdl'
+
+ # API
map.connect 'api/0.4/node/create', :controller => 'node', :action => 'create'
map.connect 'api/0.4/node/:id/history', :controller => 'node', :action => 'history', :id => nil
map.connect 'api/0.4/segment/:id', :controller => 'segment', :action => 'rest'
map.connect 'api/0.4/way/create', :controller => 'way', :action => 'create'
+ map.connect 'api/0.4/way/:id/history', :controller => 'way', :action => 'history'
map.connect 'api/0.4/way/:id', :controller => 'way', :action => 'rest'
+
+ map.connect 'api/0.4/map', :controller => 'api', :action => 'map'
- # misc site stuff
+ # web site
map.connect '/', :controller => 'site', :action => 'index'
map.connect '/index.html', :controller => 'site', :action => 'index'
--- /dev/null
+class CreateApis < ActiveRecord::Migration
+ def self.up
+ create_table :apis do |t|
+ # t.column :name, :string
+ end
+ end
+
+ def self.down
+ drop_table :apis
+ end
+end
+++ /dev/null
-class CreateMaps < ActiveRecord::Migration
- def self.up
- create_table :maps do |t|
- # t.column :name, :string
- end
- end
-
- def self.down
- drop_table :maps
- end
-end