Top Level Namespace

Defined Under Namespace

Modules: POGOProtos, Poke

Constant Summary collapse

Signature =
Google::Protobuf::DescriptorPool.generated_pool.lookup("Signature").msgclass

Instance Method Summary collapse

Instance Method Details

#get_cells(lat, lng, radius = 10) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/poke-api/testing.rb', line 5

def get_cells(lat, lng, radius = 10)
  s2_point = Poke::API::Geometry::S2LatLon.new(lat, lng).to_point
  s2_cell  = Poke::API::Geometry::S2CellId.from_point(s2_point).parent(15)

  next_cell = s2_cell.next
  prev_cell = s2_cell.prev

  radius.times.reduce([s2_cell.id]) do |acc, el|
    acc += [next_cell.id, prev_cell.id]
    next_cell = next_cell.next
    prev_cell = prev_cell.prev
    acc
  end.sort
end