]> git.openstreetmap.org Git - rails.git/commitdiff
various things
authorSteve Coast <steve@asklater.com>
Fri, 17 Nov 2006 19:56:54 +0000 (19:56 +0000)
committerSteve Coast <steve@asklater.com>
Fri, 17 Nov 2006 19:56:54 +0000 (19:56 +0000)
app/controllers/api_controller.rb [new file with mode: 0644]
app/controllers/map_controller.rb [deleted file]
app/controllers/node_controller.rb
app/helpers/api_helper.rb [new file with mode: 0644]
app/helpers/map_helper.rb [deleted file]
app/models/api.rb [new file with mode: 0644]
app/models/map.rb [deleted file]
app/models/node.rb
config/routes.rb
db/migrate/012_create_apis.rb [new file with mode: 0644]
db/migrate/012_create_maps.rb [deleted file]

diff --git a/app/controllers/api_controller.rb b/app/controllers/api_controller.rb
new file mode 100644 (file)
index 0000000..99afae6
--- /dev/null
@@ -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
diff --git a/app/controllers/map_controller.rb b/app/controllers/map_controller.rb
deleted file mode 100644 (file)
index c36dba1..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-class MapController < ApplicationController
-end
index 428d4b9c2005541846a781346856a9b42bf987e3..c5b4f279b54ee16bf80b34ba336c090643b68837 100644 (file)
@@ -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
diff --git a/app/helpers/api_helper.rb b/app/helpers/api_helper.rb
new file mode 100644 (file)
index 0000000..1f82fcf
--- /dev/null
@@ -0,0 +1,2 @@
+module ApiHelper
+end
diff --git a/app/helpers/map_helper.rb b/app/helpers/map_helper.rb
deleted file mode 100644 (file)
index 65a9561..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-module MapHelper
-end
diff --git a/app/models/api.rb b/app/models/api.rb
new file mode 100644 (file)
index 0000000..ce56602
--- /dev/null
@@ -0,0 +1,5 @@
+class Api < ActiveRecord::Base
+
+
+
+end
diff --git a/app/models/map.rb b/app/models/map.rb
deleted file mode 100644 (file)
index e7d4ce2..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-class Map < ActiveRecord::Base
-end
index c37be933a26eef84c2e5c24a45cc7b58b0b4fd32..f184a6ae97d54d4ce00e40a51097345161a1b4ab 100644 (file)
@@ -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
index 4f898ea76382e8b17cd4879ab818016ffe34903c..3ad3dddf41ae16c6a5d53611e8b4567032e55ec2 100644 (file)
@@ -1,5 +1,6 @@
 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
@@ -10,9 +11,12 @@ ActionController::Routing::Routes.draw do |map|
   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'
diff --git a/db/migrate/012_create_apis.rb b/db/migrate/012_create_apis.rb
new file mode 100644 (file)
index 0000000..21989cf
--- /dev/null
@@ -0,0 +1,11 @@
+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
diff --git a/db/migrate/012_create_maps.rb b/db/migrate/012_create_maps.rb
deleted file mode 100644 (file)
index c44068a..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-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