X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/f77d4dc4f71b15af58ee6e5b5d63c436482e7b19..0db30c611a99d62381217d86c5a0bd9d104efb42:/app/controllers/site_controller.rb?ds=inline diff --git a/app/controllers/site_controller.rb b/app/controllers/site_controller.rb index 57ac07501..3a69eed12 100644 --- a/app/controllers/site_controller.rb +++ b/app/controllers/site_controller.rb @@ -77,26 +77,30 @@ class SiteController < ApplicationController ) end - if params[:node] - bbox = Node.find(params[:node]).bbox.to_unscaled - @lat = bbox.centre_lat - @lon = bbox.centre_lon - @zoom = 18 - elsif params[:way] - bbox = Way.find(params[:way]).bbox.to_unscaled - @lat = bbox.centre_lat - @lon = bbox.centre_lon - @zoom = 17 - elsif params[:note] - note = Note.find(params[:note]) - @lat = note.lat - @lon = note.lon - @zoom = 17 - elsif params[:gpx] && current_user - trace = Trace.visible_to(current_user).find(params[:gpx]) - @lat = trace.latitude - @lon = trace.longitude - @zoom = 16 + begin + if params[:node] + bbox = Node.visible.find(params[:node]).bbox.to_unscaled + @lat = bbox.centre_lat + @lon = bbox.centre_lon + @zoom = 18 + elsif params[:way] + bbox = Way.visible.find(params[:way]).bbox.to_unscaled + @lat = bbox.centre_lat + @lon = bbox.centre_lon + @zoom = 17 + elsif params[:note] + note = Note.visible.find(params[:note]) + @lat = note.lat + @lon = note.lon + @zoom = 17 + elsif params[:gpx] && current_user + trace = Trace.visible_to(current_user).find(params[:gpx]) + @lat = trace.latitude + @lon = trace.longitude + @zoom = 16 + end + rescue ActiveRecord::RecordNotFound + # don't try and derive a location from a missing/deleted object end end