From: Thomas Wood Date: Thu, 9 Apr 2009 11:18:31 +0000 (+0000) Subject: Add has_valid_bbox? method to Changeset model to tidy checking for bbox, and fix... X-Git-Tag: live~8121^2~31 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/c64ebb9139dd5a25b82b6e8170d3b554cf45d516 Add has_valid_bbox? method to Changeset model to tidy checking for bbox, and fix edge case where no bbox would cause changeset browsing to die. --- diff --git a/app/models/changeset.rb b/app/models/changeset.rb index d41a82989..53078b2e8 100644 --- a/app/models/changeset.rb +++ b/app/models/changeset.rb @@ -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, diff --git a/app/views/browse/_changeset_details.rhtml b/app/views/browse/_changeset_details.rhtml index baeb44508..12d4dfb25 100644 --- a/app/views/browse/_changeset_details.rhtml +++ b/app/views/browse/_changeset_details.rhtml @@ -21,10 +21,9 @@ Bounding box: - <% 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? %> No bounding box has been stored for this changeset. - <% - 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 diff --git a/app/views/browse/changeset.rhtml b/app/views/browse/changeset.rhtml index c95705f8c..95fc1b1ac 100644 --- a/app/views/browse/changeset.rhtml +++ b/app/views/browse/changeset.rhtml @@ -16,6 +16,8 @@ or <%= link_to "osmChange XML", :controller => "changeset", :action => "download" %> + <% if @changeset.has_valid_bbox? %> <%= render :partial => "map", :object => @changeset %> + <% end %>