Merge remote-tracking branch 'upstream/pull/2108'
This commit is contained in:
commit
73fe5a13df
8 changed files with 41 additions and 52 deletions
|
@ -253,48 +253,9 @@ class ApiController < ApplicationController
|
|||
# * maximum area that can be requested in a bbox request in square degrees
|
||||
# * number of tracepoints that are returned in each tracepoints page
|
||||
def capabilities
|
||||
doc = OSM::API.new.get_xml_doc
|
||||
|
||||
api = XML::Node.new "api"
|
||||
version = XML::Node.new "version"
|
||||
version["minimum"] = API_VERSION.to_s
|
||||
version["maximum"] = API_VERSION.to_s
|
||||
api << version
|
||||
area = XML::Node.new "area"
|
||||
area["maximum"] = MAX_REQUEST_AREA.to_s
|
||||
api << area
|
||||
notearea = XML::Node.new "note_area"
|
||||
notearea["maximum"] = MAX_NOTE_REQUEST_AREA.to_s
|
||||
api << notearea
|
||||
tracepoints = XML::Node.new "tracepoints"
|
||||
tracepoints["per_page"] = TRACEPOINTS_PER_PAGE.to_s
|
||||
api << tracepoints
|
||||
waynodes = XML::Node.new "waynodes"
|
||||
waynodes["maximum"] = MAX_NUMBER_OF_WAY_NODES.to_s
|
||||
api << waynodes
|
||||
changesets = XML::Node.new "changesets"
|
||||
changesets["maximum_elements"] = Changeset::MAX_ELEMENTS.to_s
|
||||
api << changesets
|
||||
timeout = XML::Node.new "timeout"
|
||||
timeout["seconds"] = API_TIMEOUT.to_s
|
||||
api << timeout
|
||||
status = XML::Node.new "status"
|
||||
status["database"] = database_status.to_s
|
||||
status["api"] = api_status.to_s
|
||||
status["gpx"] = gpx_status.to_s
|
||||
api << status
|
||||
doc.root << api
|
||||
policy = XML::Node.new "policy"
|
||||
blacklist = XML::Node.new "imagery"
|
||||
IMAGERY_BLACKLIST.each do |url_regex|
|
||||
xnd = XML::Node.new "blacklist"
|
||||
xnd["regex"] = url_regex.to_s
|
||||
blacklist << xnd
|
||||
end
|
||||
policy << blacklist
|
||||
doc.root << policy
|
||||
|
||||
render :xml => doc.to_s
|
||||
@database_status = database_status
|
||||
@api_status = api_status
|
||||
@gpx_status = gpx_status
|
||||
end
|
||||
|
||||
# External apps that use the api are able to query which permissions
|
||||
|
|
22
app/views/api/capabilities.builder
Normal file
22
app/views/api/capabilities.builder
Normal file
|
@ -0,0 +1,22 @@
|
|||
xml.instruct! :xml, :version => "1.0"
|
||||
xml.osm(OSM::API.new.xml_root_attributes) do |osm|
|
||||
osm.api do |api|
|
||||
api.version(:minimum => API_VERSION.to_s, :maximum => API_VERSION.to_s)
|
||||
api.area(:maximum => MAX_REQUEST_AREA.to_s)
|
||||
api.note_area(:maximum => MAX_NOTE_REQUEST_AREA.to_s)
|
||||
api.tracepoints(:per_page => TRACEPOINTS_PER_PAGE.to_s)
|
||||
api.waynodes(:maximum => MAX_NUMBER_OF_WAY_NODES.to_s)
|
||||
api.changesets(:maximum_elements => Changeset::MAX_ELEMENTS.to_s)
|
||||
api.timeout(:seconds => API_TIMEOUT.to_s)
|
||||
api.status(:database => @database_status.to_s,
|
||||
:api => @api_status.to_s,
|
||||
:gpx => @gpx_status.to_s)
|
||||
end
|
||||
osm.policy do |policy|
|
||||
policy.imagery do |imagery|
|
||||
IMAGERY_BLACKLIST.each do |url_regex|
|
||||
imagery.blacklist(:regex => url_regex.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,6 +1,6 @@
|
|||
# create list of permissions
|
||||
xml.instruct! :xml, :version => "1.0"
|
||||
xml.osm("version" => API_VERSION.to_s, "generator" => "OpenStreetMap Server") do
|
||||
xml.osm(OSM::API.new.xml_root_attributes) do
|
||||
xml.permissions do
|
||||
@permissions.each do |permission|
|
||||
xml.permission :name => permission
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
xml.instruct!
|
||||
|
||||
xml.osm(:version => API_VERSION, :generator => GENERATOR) do |osm|
|
||||
xml.osm(OSM::API.new.xml_root_attributes) do |osm|
|
||||
osm << (render(:partial => "note", :collection => @notes) || "")
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
xml.instruct!
|
||||
|
||||
xml.osm(:version => API_VERSION, :generator => GENERATOR) do |osm|
|
||||
xml.osm(OSM::API.new.xml_root_attributes) do |osm|
|
||||
osm << render(:partial => "note", :object => @note)
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
xml.instruct! :xml, :version => "1.0"
|
||||
xml.osm("version" => API_VERSION, "generator" => GENERATOR) do |osm|
|
||||
xml.osm(OSM::API.new.xml_root_attributes) do |osm|
|
||||
osm << render(:partial => "api_user", :object => @user)
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
xml.instruct! :xml, :version => "1.0"
|
||||
xml.osm("version" => API_VERSION, "generator" => GENERATOR) do |osm|
|
||||
xml.osm(OSM::API.new.xml_root_attributes) do |osm|
|
||||
osm << render(:partial => "api_user", :collection => @users)
|
||||
end
|
||||
|
|
16
lib/osm.rb
16
lib/osm.rb
|
@ -494,14 +494,20 @@ module OSM
|
|||
doc = XML::Document.new
|
||||
doc.encoding = XML::Encoding::UTF_8
|
||||
root = XML::Node.new "osm"
|
||||
root["version"] = API_VERSION.to_s
|
||||
root["generator"] = GENERATOR
|
||||
root["copyright"] = COPYRIGHT_OWNER
|
||||
root["attribution"] = ATTRIBUTION_URL
|
||||
root["license"] = LICENSE_URL
|
||||
xml_root_attributes.each do |k, v|
|
||||
root[k] = v
|
||||
end
|
||||
doc.root = root
|
||||
doc
|
||||
end
|
||||
|
||||
def xml_root_attributes
|
||||
{ "version" => API_VERSION.to_s,
|
||||
"generator" => GENERATOR,
|
||||
"copyright" => COPYRIGHT_OWNER,
|
||||
"attribution" => ATTRIBUTION_URL,
|
||||
"license" => LICENSE_URL }
|
||||
end
|
||||
end
|
||||
|
||||
def self.ip_to_country(ip_address)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue