module Tsuga::Model::Tile::ClassMethods
Public Instance Methods
enclosing_viewport(point_ne:nil, point_sw:nil, depth:nil)
click to toggle source
Return an array of Tile
instances that encloses both corner points FIXME: this is untested
# File lib/tsuga/model/tile.rb, line 87 def enclosing_viewport(point_ne:nil, point_sw:nil, depth:nil) # $stderr.puts "aiming to enclose:" # $stderr.puts "%.2f %.2f -> %.2f %.2f" % [point_ne.lat, point_ne.lng, point_sw.lat, point_sw.lng] # $stderr.flush tiles = [] first_tile = including(point_sw, depth:depth) offset_lat = 0 loop do offset_lng = 0 loop do # $stderr.puts("offset: #{offset_lat} #{offset_lng}") # $stderr.flush new_tile = first_tile.neighbour(lat:offset_lat, lng:offset_lng) tiles << new_tile # $stderr.puts "%.2f %.2f -> %.2f %.2f" % [new_tile.southwest.lat, new_tile.southwest.lng, new_tile.northeast.lat, new_tile.northeast.lng] # $stderr.flush offset_lng += 1 break if tiles.last.northeast.lng >= point_ne.lng end break if tiles.last.northeast.lat >= point_ne.lat offset_lat += 1 offset_lng = 0 end return tiles end
including(point, options={})
click to toggle source
Returns a Tile
instance. point
should respond to geohash
. Options:
-
:depth
# File lib/tsuga/model/tile.rb, line 78 def including(point, options={}) depth = options[:depth] raise ArgumentError, 'bad depth' unless (0..31).include?(depth) new(prefix: point.prefix(depth)) end