- if request.post?
- cs = Changeset.find(params[:id])
- check_changeset_consistency(cs, @user)
-
- # keep an array of lons and lats
- lon = Array.new
- lat = Array.new
-
- # the request is in pseudo-osm format... this is kind-of an
- # abuse, maybe should change to some other format?
- doc = XML::Parser.string(request.raw_post).parse
- doc.find("//osm/node").each do |n|
- lon << n['lon'].to_f * GeoRecord::SCALE
- lat << n['lat'].to_f * GeoRecord::SCALE
- end
-
- # add the existing bounding box to the lon-lat array
- lon << cs.min_lon unless cs.min_lon.nil?
- lat << cs.min_lat unless cs.min_lat.nil?
- lon << cs.max_lon unless cs.max_lon.nil?
- lat << cs.max_lat unless cs.max_lat.nil?
-
- # collapse the arrays to minimum and maximum
- cs.min_lon, cs.min_lat, cs.max_lon, cs.max_lat =
- lon.min, lat.min, lon.max, lat.max
-
- # save the larger bounding box and return the changeset, which
- # will include the bigger bounding box.
- cs.save!
- render :text => cs.to_xml.to_s, :content_type => "text/xml"