Пример #1
0
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
Пример #2
0
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
Пример #3
0
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])
Пример #4
0
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])
Пример #5
0
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])
Пример #6
0
def special_getCoveringRect(lat, lng, radius):
    radius_radians = earthMetersToRadians(radius)
    latlng = LatLng.from_degrees(float(lat),
                                 float(lng)).normalized().to_point()
    region = Cap.from_axis_height(latlng,
                                  (radius_radians * radius_radians) / 2)
    coverer = RegionCoverer()
    coverer.min_level = 5
    coverer.max_level = 5
    coverer.max_cells = MAX_S2_CELLS
    covering = coverer.get_covering(region)
    return covering
Пример #7
0
def build_cap_coverage(lat, lng, cell_count=21, radius=100.0):
    # these are the zoom levels for s2cells
    min_zoom_level = 15
    max_zoom_level = 30

    # radius of the earth in meters
    R = 6378137.0;

    cap_height = ((radius/R)**2)/2
    axis = LatLng.from_degrees(lat, lng).to_point()
    cap = Cap.from_axis_height(axis, cap_height)

    coverer = RegionCoverer()
    coverer.min_level = min_zoom_level
    coverer.max_level = max_zoom_level
    coverer.max_cells = cell_count
    covering = list(coverer.get_covering(cap))
    while(len(covering) < cell_count):
        covering.append(covering[-1].next())
    return covering