From: Tom Hughes Date: Fri, 14 May 2010 21:50:38 +0000 (+0100) Subject: Merge branch 'master' into openstreetbugs X-Git-Tag: live~5068^2~210 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/273706ae09862364deaa0287a3b563340300fdea?hp=-c Merge branch 'master' into openstreetbugs --- 273706ae09862364deaa0287a3b563340300fdea diff --combined config/environment.rb index 696a226e7,7ee9e79af..23d46c5d4 --- a/config/environment.rb +++ b/config/environment.rb @@@ -88,12 -88,6 +88,6 @@@ Rails::Initializer.run do |config # (create the session table with 'rake db:sessions:create') config.action_controller.session_store = :sql_session_store - # We will use the old style of migrations, rather than the newer - # timestamped migrations that were introduced with Rails 2.1, as - # it will be confusing to have the numbered and timestamped migrations - # together in the same folder. - config.active_record.timestamped_migrations = false - # Use SQL instead of Active Record's schema dumper when creating the test database. # This is necessary if your schema can't be completely dumped by the schema dumper, # like if you have constraints or database-specific column types @@@ -104,5 -98,4 +98,5 @@@ # Make Active Record use UTC-base instead of local time config.active_record.default_timezone = :utc + end diff --combined lib/osm.rb index e2fffd17f,704bc099c..c34c928ff --- a/lib/osm.rb +++ b/lib/osm.rb @@@ -471,9 -471,7 +471,7 @@@ module OS def self.IPLocation(ip_address) code = OSM.IPToCountry(ip_address) - unless code.nil? - country = Country.find_by_code(code) - + if code and country = Country.find_by_code(code) return { :minlon => country.min_lon, :minlat => country.min_lat, :maxlon => country.max_lon, :maxlat => country.max_lat } end @@@ -500,7 -498,7 +498,7 @@@ # Return an SQL fragment to select a given area of the globe def self.sql_for_area(minlat, minlon, maxlat, maxlon, prefix = nil) - tilesql = QuadTile.sql_for_area(minlat, minlon, maxlat, maxlon, prefix) + tilesql = QuadTile.sql_for_area(minlat, minlon, maxlat, maxlon, prefix) minlat = (minlat * 10000000).round minlon = (minlon * 10000000).round maxlat = (maxlat * 10000000).round @@@ -509,16 -507,6 +507,16 @@@ return "#{tilesql} AND #{prefix}latitude BETWEEN #{minlat} AND #{maxlat} AND #{prefix}longitude BETWEEN #{minlon} AND #{maxlon}" end + # Return an SQL fragment to select a given area of the globe without using the quadtile index + def self.sql_for_area_no_quadtile(minlat, minlon, maxlat, maxlon, prefix = nil, without_quadtile = :false) + minlat = (minlat * 10000000).round + minlon = (minlon * 10000000).round + maxlat = (maxlat * 10000000).round + maxlon = (maxlon * 10000000).round + + return "#{prefix}latitude BETWEEN #{minlat} AND #{maxlat} AND #{prefix}longitude BETWEEN #{minlon} AND #{maxlon}" + end + # Return a spam score for a chunk of text def self.spam_score(text) link_count = 0