+ render :text => result.to_s, :content_type => "text/xml"
+ end
+
+ ##
+ # query changesets by bounding box, time, user or open/closed status.
+ def query
+ # find any bounding box
+ if params['bbox']
+ bbox = BoundingBox.from_bbox_params(params)
+ end
+
+ # create the conditions that the user asked for. some or all of
+ # these may be nil.
+ changesets = Changeset.scoped
+ changesets = conditions_bbox(changesets, bbox)
+ changesets = conditions_user(changesets, params['user'], params['display_name'])
+ changesets = conditions_time(changesets, params['time'])
+ changesets = conditions_open(changesets, params['open'])
+ changesets = conditions_closed(changesets, params['closed'])
+
+ # create the results document
+ results = OSM::API.new.get_xml_doc
+
+ # add all matching changesets to the XML results document
+ changesets.order("created_at DESC").limit(100).each do |cs|
+ results.root << cs.to_xml_node
+ end
+
+ render :text => results.to_s, :content_type => "text/xml"
+ end
+
+ ##
+ # updates a changeset's tags. none of the changeset's attributes are
+ # user-modifiable, so they will be ignored.
+ #
+ # changesets are not (yet?) versioned, so we don't have to deal with
+ # history tables here. changesets are locked to a single user, however.
+ #
+ # after succesful update, returns the XML of the changeset.
+ def update
+ # request *must* be a PUT.
+ assert_method :put
+
+ changeset = Changeset.find(params[:id])
+ new_changeset = Changeset.from_xml(request.raw_post)
+
+ unless new_changeset.nil?
+ check_changeset_consistency(changeset, @user)
+ changeset.update_from(new_changeset, @user)
+ render :text => changeset.to_xml, :mime_type => "text/xml"
+ else
+
+ render :nothing => true, :status => :bad_request
+ end
+ end
+
+ ##
+ # list edits (open changesets) in reverse chronological order
+ def list
+ if request.format == :atom and params[:page]
+ redirect_to params.merge({ :page => nil }), :status => :moved_permanently
+ else
+ changesets = conditions_nonempty(Changeset.scoped)
+
+ if params[:display_name]
+ user = User.find_by_display_name(params[:display_name])
+
+ if user and user.active?
+ if user.data_public? or user == @user
+ changesets = changesets.where(:user_id => user.id)
+ else
+ changesets = changesets.where("false")
+ end
+ else
+ render_unknown_user params[:display_name]
+ return
+ end