]> git.openstreetmap.org Git - rails.git/commitdiff
Add has_valid_bbox? method to Changeset model to tidy checking for bbox, and fix...
authorThomas Wood <grand.edgemaster@gmail.com>
Thu, 9 Apr 2009 11:18:31 +0000 (11:18 +0000)
committerThomas Wood <grand.edgemaster@gmail.com>
Thu, 9 Apr 2009 11:18:31 +0000 (11:18 +0000)
app/models/changeset.rb
app/views/browse/_changeset_details.rhtml
app/views/browse/changeset.rhtml

index d41a8298940c5bdfd08f6632a27f12ddfa892a05..53078b2e892b3fe0a670cf2b2ddfc67d1dd6777f 100644 (file)
@@ -85,6 +85,10 @@ class Changeset < ActiveRecord::Base
   def bbox
     @bbox ||= [ min_lon, min_lat, max_lon, max_lat ]
   end
+  
+  def has_valid_bbox?
+    not bbox.include? nil
+  end
 
   ##
   # expand the bounding box to include the given bounding box. also, 
index baeb44508763dbb1a76a77ed3e2bdbe4cec084e2..12d4dfb25b84e616d8d0c9423bbdd0c9a92fba88 100644 (file)
 
   <tr>
     <th>Bounding box:</th>
-    <% if changeset_details.max_lat.nil? or changeset_details.min_lat.nil? or changeset_details.max_lon.nil? or changeset_details.min_lon.nil? %>
+    <% unless changeset_details.has_valid_bbox? %>
       <td>No bounding box has been stored for this changeset.</td>
-    <%
-       else
+    <% else
           minlon = changeset_details.min_lon/GeoRecord::SCALE.to_f
           minlat = changeset_details.min_lat/GeoRecord::SCALE.to_f
           maxlon = changeset_details.max_lon/GeoRecord::SCALE.to_f
index c95705f8cc4146b866ee93560774fe35fd7748a4..95fc1b1ac91298bb9acfc155f379099c714e8c12 100644 (file)
@@ -16,6 +16,8 @@
     or
     <%= link_to "osmChange XML", :controller => "changeset", :action => "download" %>
     </td>
+    <% if @changeset.has_valid_bbox? %>
     <%= render :partial => "map", :object => @changeset %>
+    <% end %>
   </tr>
 </table>