On Thu, Dec 31, 2009 at 5:35 AM, Morten Kjeldgaard <[email protected]> wrote:

>
> I have a small New Year's wish to the developers of the OSM website. When
> going to the "history" tab, it would be soooooo nice if you could optionally
> remove all entries marked "(big)" from the listing. These are almost always
> entries that cover half the planet, resulting from someone doing script-work
> on the entire database. What I really want to see when looking at the
> history tab is what is currently going on with the map within the bbox I'm
> currently looking at.
>
> Pretty please?
>

Ok, this is my first ever patch on a rails project, let alone to the
rails_port. What do the devs think?
Index: app/models/changeset.rb
===================================================================
--- app/models/changeset.rb	(revision 19244)
+++ app/models/changeset.rb	(working copy)
@@ -17,6 +17,7 @@
   validates_uniqueness_of :id
   validates_numericality_of :id, :on => :update, :integer_only => true
   validates_numericality_of :min_lat, :max_lat, :min_lon, :max_lat, :allow_nil => true, :integer_only => true
+  validates_numericality_of :area, :allow_nil => false, :integer_only => false
   validates_numericality_of :user_id,  :integer_only => true
   validates_numericality_of :num_changes, :integer_only => true, :greater_than_or_equal_to => 0
   validates_associated :user
@@ -98,7 +99,7 @@
 
   ##
   # returns area of the changset bbox as a rough comparitive quantity for use of changset displays
-  def area
+  def compute_area
      if has_valid_bbox?
        (max_lon - min_lon) * (max_lat - min_lat)
      else
@@ -126,6 +127,9 @@
     # update active record. rails 2.1's dirty handling should take care of
     # whether this object needs saving or not.
     self.min_lon, self.min_lat, self.max_lon, self.max_lat = @bbox
+
+    # update the size of the bounding box
+    self.area = compute_area
   end
 
   ##
Index: app/controllers/changeset_controller.rb
===================================================================
--- app/controllers/changeset_controller.rb	(revision 19244)
+++ app/controllers/changeset_controller.rb	(working copy)
@@ -286,6 +286,10 @@
       user_link = render_to_string :partial => "user", :object => user
     end
 
+    if not params[:include_big]
+      conditions = cond_merge conditions, conditions_nonbig
+    end
+
     if user and bbox
       @title =  t 'changeset.list.title_user_bbox', :user => user.display_name, :bbox => bbox.to_s
       @heading =  t 'changeset.list.heading_user_bbox', :user => user.display_name, :bbox => bbox.to_s
@@ -437,5 +441,11 @@
   def conditions_nonempty()
     return ['min_lat IS NOT NULL']
   end
-  
+
+  ##
+  # eliminate big changesets
+  def coniditions_nonbig()
+    return ['area  <= 1500000000000']
+  end
+
 end
_______________________________________________
dev mailing list
[email protected]
http://lists.openstreetmap.org/listinfo/dev

Reply via email to