def cover_circle(lat, lng, radius, level): EARTH_RADIUS = 6371 * 1000 region = Cap.from_axis_angle(LatLng.from_degrees(lat, lng).to_point(), \ Angle.from_degrees(360*radius/(2*math.pi*EARTH_RADIUS))) coverer = RegionCoverer() coverer.min_level = level coverer.max_level = level cells = coverer.get_covering(region) return cells
def cover_circle(lat, lng, radius, level=15): EARTH = 6371000 region = Cap.from_axis_angle(\ LatLng.from_degrees(lat, lng).to_point(), \ Angle.from_degrees(360*radius/(2*math.pi*EARTH))) coverer = RegionCoverer() coverer.min_level = level coverer.max_level = level cells = coverer.get_covering(region) return cells
def get_cell_ids(lat, long, radius=1000): # Max values allowed by server according to this comment: # https://github.com/AeonLucid/POGOProtos/issues/83#issuecomment-235612285 if radius > 1500: radius = 1500 # radius = 1500 is max allowed by the server region = Cap.from_axis_angle(LatLng.from_degrees(lat, long).to_point(), Angle.from_degrees(360*radius/(2*math.pi*EARTH_RADIUS))) coverer = RegionCoverer() coverer.min_level = 15 coverer.max_level = 15 cells = coverer.get_covering(region) cells = cells[:100] # len(cells) = 100 is max allowed by the server return sorted([x.id() for x in cells])
def get_cell_ids(lat, long, radius=500): if radius > 500: radius = 500 region = Cap.from_axis_angle( LatLng.from_degrees(lat, long).to_point(), Angle.from_degrees(360 * radius / (2 * math.pi * EARTH_RADIUS))) coverer = RegionCoverer() coverer.min_level = 15 coverer.max_level = 15 cells = coverer.get_covering(region) cells = cells[:21] return sorted([x.id() for x in cells])