Class: MapPrint::TileFactory
- Inherits:
-
Object
- Object
- MapPrint::TileFactory
- Defined in:
- lib/map_print/tiles/tile_factory.rb
Instance Method Summary collapse
- #download ⇒ Object
-
#initialize(base_url, type, sw_lat_lng, ne_lat_lng, zoom) ⇒ TileFactory
constructor
A new instance of TileFactory.
- #px_offset ⇒ Object
- #tiles ⇒ Object
- #x_size ⇒ Object
- #y_size ⇒ Object
Constructor Details
#initialize(base_url, type, sw_lat_lng, ne_lat_lng, zoom) ⇒ TileFactory
Returns a new instance of TileFactory.
8 9 10 11 12 13 14 |
# 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 |
Instance Method Details
#download ⇒ Object
27 28 29 30 31 |
# 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 ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# 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 ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 |
# 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 ⇒ Object
33 34 35 |
# File 'lib/map_print/tiles/tile_factory.rb', line 33 def x_size x_array.size end |
#y_size ⇒ Object
37 38 39 |
# File 'lib/map_print/tiles/tile_factory.rb', line 37 def y_size y_array.size end |