-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Obtaining cell_ids #2
Comments
As i understand cell id you used in example.rb is only for New York |
The example cell ID was generated by using the S2 geometry in Python's interpreter, unfortunately the library in question does not exist in Ruby (yet). I am looking for a way to get this implemented but unsure how long that will take. If you need cell_ids then I'd suggest to have a look at this Python excerpt: https://github.com/tejado/pgoapi/blob/master/pokecli.py#L63 (the methods are imported from using |
I've wrote code like this https://gist.github.com/selivandex/35d2e08de01a1aae59bbd261db40af0a And here is ruby usage But i getting response array of cell ids
Can you help me understand? What is |
L stands for Long in Python, it's just to indicate the type of the integer really (you don't see this in Python 3+ anymore) You could use something like this:
example.rb require 'poke-api'
require 'pp'
client = Poke::API::Client.new
client.store_location('New York')
client.login('username', 'password', 'ptc')
# Replace this line as you wish to call the right library, if your file is in a folder ``lib``
# and the example is in the parent directory then you could call from lib.get_cell_id
# A third argument can be optionally provided to indicate the radius (in this case 15)
cell_ids = `python -c 'from get_cell_id import get_cell_ids; \
print(get_cell_ids(#{client.lat},#{client.lng}, 15))'`
cell_ids = cell_ids.tr('[L]', '').split.map(&:to_i)
client.get_map_objects(
latitude: client.lat,
longitude: client.lng,
since_timestamp_ms: [0] * cell_ids.length,
cell_id: cell_ids
)
pp client.call get_cell_id.py (requires s2sphere library to be installed for Python -> from s2sphere import CellId, LatLng
def get_cell_ids(lat, long, radius = 10):
origin = CellId.from_lat_lng(LatLng.from_degrees(lat, long)).parent(15)
walk = [origin.id()]
right = origin.next()
left = origin.prev()
for i in range(radius):
walk.append(right.id())
walk.append(left.id())
right = right.next()
left = left.prev()
return sorted(walk) You get the idea :) |
As of the latest protobufs update both |
Will implement this tomorrow in native Ruby (just enough so we can use it to generate S2 cells). |
@nabeelamjad Thanks! |
I've put up a PR #28 just to ensure that the work I've done is right and if anything needs to be changed, I'll probably merge it in tomorrow. |
I've merged in S2 Geometry cells in the latest release, I'll separate the repo at some other point when I have more time. |
Hello, can you say how did you generated cell_id in the exmaple.rb ? And what cell_id we need?
The text was updated successfully, but these errors were encountered: