# get missing nodes if there are any
nodes += Node.find(missing_nodes) if missing_nodes.length > 0
- doc = get_xml_doc
+ doc = OSM::API.get_xml_doc
# get ways
# find which ways are needed
end
end
- def get_xml_doc
- doc = XML::Document.new
- doc.encoding = 'UTF-8'
- root = XML::Node.new 'osm'
- root['version'] = API_VERSION
- root['generator'] = 'OpenStreetMap server'
- doc.root = root
- return doc
- end
-
# extract authorisation credentials from headers, returns user = nil if none\r
private
def get_auth_data
return
end
- doc = get_xml_doc
+ doc = OSM::API.new.get_xml_doc
node.old_nodes.each do |old_node|
doc.root << old_node.to_xml_node
return
end
- doc = get_xml_doc
+ doc = OSM::API.new.get_xml_doc
segment.old_segments.each do |old_segment|
doc.root << old_segment.to_xml_node
render :text => doc.to_s
end
-
-
-
-
-
end
ids = params['segments'].split(',').collect {|s| s.to_i }
if ids.length > 0
segmentlist = Segment.find(ids)
- doc = get_xml_doc
+ doc = OSM::API.get_xml_doc
segmentlist.each do |segment|
doc.root << segment.to_xml_node
end
class UserController < ApplicationController
layout 'site'
- before_filter :authorize, :only => :preferences
+ before_filter :authorize, :only => [:preferences, :api_details]
before_filter :authorize_web, :only => [:rename, :account, :go_public]
before_filter :require_user, :only => [:rename, :account, :go_public]
render :status => 400, :nothing => true
end
end
+
+ def api_details
+ render :text => @user.to_xml.to_s
+ end
end
ids = params['ways'].split(',').collect {|w| w.to_i }
if ids.length > 0
waylist = Way.find(ids)
- doc = get_xml_doc
+ doc = OSM::API.new.get_xml_doc
waylist.each do |way|
doc.root << way.to_xml_node
end
end
def to_xml
- doc = XML::Document.new
- doc.encoding = 'UTF-8'
- root = XML::Node.new 'osm'
- root['version'] = API_VERSION
- root['generator'] = 'OpenStreetMap server'
- doc.root = root
- root << to_xml_node()
+ doc = OSM::API.new.get_xml_doc
+ doc.root << to_xml_node()
return doc
end
end
def to_xml
- doc = XML::Document.new
- doc.encoding = 'UTF-8'
- root = XML::Node.new 'osm'
- root['version'] = API_VERSION
- root['generator'] = 'OpenStreetMap server'
- doc.root = root
- root << to_xml_node()
+ doc = OSM::API.new.get_xml_doc
+ doc.root << to_xml_node()
return doc
end
-require 'digest/md5'
-
class User < ActiveRecord::Base
+ require 'xml/libxml'
+ require 'digest/md5'
+
has_many :traces
validates_confirmation_of :pass_crypt, :message => 'Password must match the confirmation password'
return confirmstring
end
+ def to_xml
+ doc = OSM::API.new.get_xml_doc
+ doc.root << to_xml_node()
+ return doc
+ end
+
+ def to_xml_node
+ el1 = XML::Node.new 'user'
+ el1['display_name'] = self.display_name.to_s
+ el1['account_created'] = self.creation_time.xmlschema
+ return el1
+ end
end
end
def to_xml
- doc = XML::Document.new
- doc.encoding = 'UTF-8'
- root = XML::Node.new 'osm'
- root['version'] = '0.4'
- root['generator'] = 'OpenStreetMap server'
-
- doc.root = root
-
- root << to_xml_node()
+ doc = OSM::API.new.get_xml_doc
+ doc.root << to_xml_node()
return doc
end
map.connect "api/#{API_VERSION}/map", :controller => 'api', :action => 'map'
+ map.connect "api/#{API_VERSION}/user/details", :controller => 'user', :action => 'api_details'
+
# web site
map.connect '/', :controller => 'site', :action => 'index'
return @doc.to_s
end
end
+
+ class API
+ def get_xml_doc
+ doc = XML::Document.new
+ doc.encoding = 'UTF-8'
+ root = XML::Node.new 'osm'
+ root['version'] = API_VERSION
+ root['generator'] = 'OpenStreetMap server'
+ doc.root = root
+ return doc
+ end
+ end
end