X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/349413a520d05cf9c55fe6870de6ea2f933a3248..bab8ad3a7ba2f896c93e20771385276d4182248a:/lib/quad_tile.rb diff --git a/lib/quad_tile.rb b/lib/quad_tile.rb index 6e4fb6d22..1f7e6e501 100644 --- a/lib/quad_tile.rb +++ b/lib/quad_tile.rb @@ -39,6 +39,25 @@ module QuadTile return t end + + def self.iterate_tiles_for_area(minlat, minlon, maxlat, maxlon) + tiles = tiles_for_area(minlat, minlon, maxlat, maxlon) + first = last = nil + + tiles.sort.each do |tile| + if last.nil? + first = last = tile + elsif tile == last + 1 + last = tile + else + yield first, last + + first = last = tile + end + end + + yield first, last unless last.nil? + end end def self.sql_for_area(minlat, minlon, maxlat, maxlon, prefix) @@ -58,24 +77,5 @@ module QuadTile return "( " + sql.join(" OR ") + " )" end - def self.iterate_tiles_for_area(minlat, minlon, maxlat, maxlon) - tiles = tiles_for_area(minlat, minlon, maxlat, maxlon) - first = last = nil - - tiles.sort.each do |tile| - if last.nil? - first = last = tile - elsif tile == last + 1 - last = tile - else - yield first, last - - first = last = tile - end - end - - yield first, last unless last.nil? - end - private_class_method :tile_for_xy, :iterate_tiles_for_area end