+ tiles = Node.count(:conditions => ["timestamp BETWEEN ? AND ?", starttime, endtime],
+ :group => "maptile_for_point(latitude, longitude, #{zoom})")
+
+ doc = OSM::API.new.get_xml_doc
+ changes = XML::Node.new 'changes'
+ changes["starttime"] = starttime.xmlschema
+ changes["endtime"] = endtime.xmlschema
+
+ tiles.each do |tile, count|
+ x = (tile.to_i >> zoom) & mask
+ y = tile.to_i & mask
+
+ t = XML::Node.new 'tile'
+ t["x"] = x.to_s
+ t["y"] = y.to_s
+ t["z"] = zoom.to_s
+ t["changes"] = count.to_s
+
+ changes << t
+ end
+
+ doc.root << changes
+
+ render :text => doc.to_s, :content_type => "text/xml"
+ else
+ render :nothing => true, :status => :bad_request
+ end
+ end
+
+ def capabilities
+ doc = OSM::API.new.get_xml_doc
+
+ api = XML::Node.new 'api'
+ version = XML::Node.new 'version'
+ version['minimum'] = '0.5';
+ version['maximum'] = '0.5';
+ api << version
+ area = XML::Node.new 'area'
+ area['maximum'] = MAX_REQUEST_AREA.to_s;
+ api << area
+
+ doc.root << api
+
+ render :text => doc.to_s, :content_type => "text/xml"