]> git.openstreetmap.org Git - rails.git/commitdiff
Merge branch 'master' into openstreetbugs
authorTom Hughes <tom@compton.nu>
Fri, 14 May 2010 21:50:38 +0000 (22:50 +0100)
committerTom Hughes <tom@compton.nu>
Fri, 14 May 2010 21:50:38 +0000 (22:50 +0100)
1  2 
config/environment.rb
lib/osm.rb

diff --combined config/environment.rb
index 696a226e753ff7f8312918a62f9c239311698369,7ee9e79af53732ba61efb95ab7003e1d000a31b5..23d46c5d46336998158c1c3e5d8429c5c0b0cc1f
@@@ -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
  
    # Make Active Record use UTC-base instead of local time
    config.active_record.default_timezone = :utc
 +
  end
diff --combined lib/osm.rb
index e2fffd17fe59492c08e6c2b4ea7b8a776738eb9e,704bc099ce23d8ae1ff2c1abdc51e422c57869ee..c34c928ffb350abdda8f340a124ff051d1b0c143
@@@ -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
  
  
    # 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
      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