Class: Tairu::Store::GeoJSON
- Inherits:
-
Object
- Object
- Tairu::Store::GeoJSON
- Defined in:
- lib/tairu/store/geojson.rb
Instance Method Summary collapse
- #flip_y(z, y) ⇒ Object
- #get(coord) ⇒ Object
-
#initialize(layer) ⇒ GeoJSON
constructor
A new instance of GeoJSON.
Constructor Details
Instance Method Details
#flip_y(z, y) ⇒ Object
9 10 11 |
# File 'lib/tairu/store/geojson.rb', line 9 def flip_y(z, y) (2 ** z - 1) - y end |
#get(coord) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/tairu/store/geojson.rb', line 13 def get(coord) y = @flip ? flip_y(coord.zoom, coord.row) : coord.row path = File.join(@tileset, coord.zoom, coord.column, "#{y}.json") 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 = 'application/json' tile = data.nil? ? nil : Tairu::Tile.new(data, mime_type) tile end |