Class: Tairu::Store::Esri
- Inherits:
-
Object
- Object
- Tairu::Store::Esri
- Defined in:
- lib/tairu/store/esri.rb
Instance Method Summary collapse
- #decode_hex(hex_value) ⇒ Object
- #encode_hex(int_value, length = 8) ⇒ Object
- #get(coord, format = 'png') ⇒ Object
-
#initialize(layer) ⇒ Esri
constructor
A new instance of Esri.
Constructor Details
Instance Method Details
#decode_hex(hex_value) ⇒ Object
27 28 29 |
# File 'lib/tairu/store/esri.rb', line 27 def decode_hex(hex_value) Integer("0x#{hex_value}") end |
#encode_hex(int_value, length = 8) ⇒ Object
31 32 33 34 |
# File 'lib/tairu/store/esri.rb', line 31 def encode_hex(int_value, length=8) length = "%02i" % length "%#{length}x" % int_value end |
#get(coord, format = 'png') ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/tairu/store/esri.rb', line 8 def get(coord, format='png') path = File.join(@tileset, 'Layers', '_alllayers', "L#{'%02i' % coord.zoom}", "R#{encode_hex(coord.row)}", "C#{encode_hex(coord.column)}.#{format}") return nil unless File.exists?(path) data = File.open(path, 'r') do |f| begin f.flock(File::LOCK_SH) f.read ensure f.flock(File::LOCK_UN) end end mime_type = "image/#{format}" tile = data.nil? ? nil : Tairu::Tile.new(data, mime_type) tile end |