]> git.openstreetmap.org Git - rails.git/commitdiff
nodes and segments plural API calls
authorSteve Coast <steve@asklater.com>
Fri, 1 Dec 2006 09:51:18 +0000 (09:51 +0000)
committerSteve Coast <steve@asklater.com>
Fri, 1 Dec 2006 09:51:18 +0000 (09:51 +0000)
app/controllers/node_controller.rb
app/controllers/segment_controller.rb
config/routes.rb

index 5370306f3b4cd1bf7cf4118022e811a1cc421c72..5e5784e68dbc06a0bc4757ac56a86e04b140b118 100644 (file)
@@ -87,4 +87,18 @@ class NodeController < ApplicationController
 
   end
 
 
   end
 
+  def nodes
+    response.headers["Content-Type"] = 'application/xml'
+    ids = params['nodes'].split(',').collect {|n| n.to_i }
+    if ids.length > 0
+      nodelist = Node.find(ids)
+      doc = get_xml_doc
+      nodelist.each do |node|
+        doc.root << node.to_xml_node
+      end 
+      render :text => doc.to_s
+    else
+      render :nothing => true, :status => 400
+    end
+  end
 end
 end
index 9315bce778e6262433a10e1416f780c93a6b7306..048e599c3fb434804dcf79a2c1123d35c56cc3ed 100644 (file)
@@ -80,4 +80,19 @@ class SegmentController < ApplicationController
 
   end
 
 
   end
 
+  def segments
+    response.headers["Content-Type"] = 'application/xml'
+    ids = params['segments'].split(',').collect {|s| s.to_i }
+    if ids.length > 0
+      segmentlist = Segment.find(ids)
+      doc = get_xml_doc
+      segmentlist.each do |segment|
+        doc.root << segment.to_xml_node
+      end 
+      render :text => doc.to_s
+    else
+      render :nothing => true, :status => 400
+    end
+  end
+
 end
 end
index 33a6dc13adce465bc62060b66f6bb23f7803df05..e8cf82559b76def9c68a2648d88b46f4b2c5cd24 100644 (file)
@@ -5,11 +5,13 @@ ActionController::Routing::Routes.draw do |map|
   map.connect "api/#{API_VERSION}/node/create", :controller => 'node', :action => 'create'
   map.connect "api/#{API_VERSION}/node/:id/history", :controller => 'old_node', :action => 'history', :id => nil
   map.connect "api/#{API_VERSION}/node/:id", :controller => 'node', :action => 'rest', :id => nil
   map.connect "api/#{API_VERSION}/node/create", :controller => 'node', :action => 'create'
   map.connect "api/#{API_VERSION}/node/:id/history", :controller => 'old_node', :action => 'history', :id => nil
   map.connect "api/#{API_VERSION}/node/:id", :controller => 'node', :action => 'rest', :id => nil
-
+  map.connect "api/#{API_VERSION}/nodes", :controller => 'node', :action => 'nodes', :id => nil
+  
   map.connect "api/#{API_VERSION}/segment/create", :controller => 'segment', :action => 'create'
   map.connect "api/#{API_VERSION}/segment/:id/history", :controller => 'old_segment', :action => 'history'
   map.connect "api/#{API_VERSION}/segment/:id", :controller => 'segment', :action => 'rest'
   map.connect "api/#{API_VERSION}/segment/create", :controller => 'segment', :action => 'create'
   map.connect "api/#{API_VERSION}/segment/:id/history", :controller => 'old_segment', :action => 'history'
   map.connect "api/#{API_VERSION}/segment/:id", :controller => 'segment', :action => 'rest'
-
+  map.connect "api/#{API_VERSION}/segments", :controller => 'segment', :action => 'segments', :id => nil
+  
   map.connect "api/#{API_VERSION}/way/create", :controller => 'way', :action => 'create'
   map.connect "api/#{API_VERSION}/way/:id/history", :controller => 'old_way', :action => 'history', :id => nil
   map.connect "api/#{API_VERSION}/way/:id", :controller => 'way', :action => 'rest', :id => nil
   map.connect "api/#{API_VERSION}/way/create", :controller => 'way', :action => 'create'
   map.connect "api/#{API_VERSION}/way/:id/history", :controller => 'old_way', :action => 'history', :id => nil
   map.connect "api/#{API_VERSION}/way/:id", :controller => 'way', :action => 'rest', :id => nil