class MapPrint::TileFactory
Public Class Methods
new(base_url, type, sw_lat_lng, ne_lat_lng, zoom)
click to toggle source
# File lib/map_print/tiles/tile_factory.rb, line 8 def initialize(base_url, type, sw_lat_lng, ne_lat_lng, zoom) @base_url = base_url @type = type @sw_lat_lng = sw_lat_lng @ne_lat_lng = ne_lat_lng @zoom = zoom end
Public Instance Methods
download()
click to toggle source
# File lib/map_print/tiles/tile_factory.rb, line 27 def download Parallel.each(tiles, in_processes: 20) do |tile| tile.download end end
px_offset()
click to toggle source
# File lib/map_print/tiles/tile_factory.rb, line 16 def px_offset return @px_offset if @px_offset offset = {} offset[:top] = (ne_offset[:y] * 256).to_i offset[:right] = 256 - (ne_offset[:x] * 256).to_i offset[:bottom] = 256 - (sw_offset[:y] * 256).to_i offset[:left] = (sw_offset[:x] * 256).to_i @px_offset = offset end
tiles()
click to toggle source
# File lib/map_print/tiles/tile_factory.rb, line 41 def tiles return @tiles if @tiles @tiles = [] y_array.each do |y| x_array.each do |x| @tiles << tile_class.new(x, y, @zoom, @base_url) end end @tiles end
x_size()
click to toggle source
# File lib/map_print/tiles/tile_factory.rb, line 33 def x_size x_array.size end
y_size()
click to toggle source
# File lib/map_print/tiles/tile_factory.rb, line 37 def y_size y_array.size end
Private Instance Methods
get_tile_coord_array(coord)
click to toggle source
# File lib/map_print/tiles/tile_factory.rb, line 71 def get_tile_coord_array(coord) coord1 = @sw_lat_lng.get_slippy_map_tile_number(@zoom)[coord] coord2 = @ne_lat_lng.get_slippy_map_tile_number(@zoom)[coord] coord1 < coord2 ? coord1..coord2 : coord2..coord1 end
ne_offset()
click to toggle source
# File lib/map_print/tiles/tile_factory.rb, line 55 def ne_offset @ne_lat_lng.get_slippy_map_tile_number(@zoom)[:offset] end
sw_offset()
click to toggle source
# File lib/map_print/tiles/tile_factory.rb, line 59 def sw_offset @sw_lat_lng.get_slippy_map_tile_number(@zoom)[:offset] end
tile_class()
click to toggle source
# File lib/map_print/tiles/tile_factory.rb, line 77 def tile_class if @type == 'osm' OSMTile elsif @type =~ /bing/ BingTile end end
x_array()
click to toggle source
# File lib/map_print/tiles/tile_factory.rb, line 63 def x_array @x_array ||= get_tile_coord_array(:x) end
y_array()
click to toggle source
# File lib/map_print/tiles/tile_factory.rb, line 67 def y_array @y_array ||= get_tile_coord_array(:y) end