Class: MapPrint::BingTile

Inherits:
Tile
  • Object
show all
Defined in:
lib/map_print/tiles/bing_tile.rb

Constant Summary collapse

BIT_TO_QUADKEY =
{
  [false, false] => '0',
  [false, true]  => '1',
  [true, false]  => '2',
  [true, true]   => '3'
}

Instance Method Summary collapse

Methods inherited from Tile

#coords, #download, #file_path, #initialize, #tile_number_to_lat_lng

Constructor Details

This class inherits a constructor from MapPrint::Tile

Instance Method Details

#cache_nameObject



16
17
18
19
20
# File 'lib/map_print/tiles/bing_tile.rb', line 16

def cache_name
  'bing-' + @base_url.scan(/\/\/(.*?)\/\$/).first.first.gsub('/', '-')
rescue
  'bing'
end

#provider_nameObject



12
13
14
# File 'lib/map_print/tiles/bing_tile.rb', line 12

def provider_name
  'bing'
end

#tile2quadObject



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/map_print/tiles/bing_tile.rb', line 22

def tile2quad
  quadkey_chars = []

  tx = @x.to_i
  ty = @y.to_i

  @z.times do
    quadkey_chars.push BIT_TO_QUADKEY[[ty.odd?, tx.odd?]] # bit order y,x
    tx >>= 1 ; ty >>= 1
  end

  quadkey_chars.join.reverse
end

#tile_urlObject



36
37
38
# File 'lib/map_print/tiles/bing_tile.rb', line 36

def tile_url
  @base_url.gsub('${quadkey}', tile2quad)
end