当前位置: 首页>>代码示例>>Python>>正文


Python s2sphere.RegionCoverer方法代码示例

本文整理汇总了Python中s2sphere.RegionCoverer方法的典型用法代码示例。如果您正苦于以下问题:Python s2sphere.RegionCoverer方法的具体用法?Python s2sphere.RegionCoverer怎么用?Python s2sphere.RegionCoverer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在s2sphere的用法示例。


在下文中一共展示了s2sphere.RegionCoverer方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_covering

# 需要导入模块: import s2sphere [as 别名]
# 或者: from s2sphere import RegionCoverer [as 别名]
def test_covering(self):
        r = s2sphere.RegionCoverer()
        p1 = s2sphere.LatLng.from_degrees(33, -122)
        p2 = s2sphere.LatLng.from_degrees(33.1, -122.1)
        cell_ids = r.get_covering(s2sphere.LatLngRect.from_point_pair(p1, p2))
        ids = sorted([c.id() for c in cell_ids])
        target = [9291041754864156672,
                  9291043953887412224,
                  9291044503643226112,
                  9291045878032760832,
                  9291047252422295552,
                  9291047802178109440,
                  9291051650468806656,
                  9291052200224620544]
        self.assertEqual(ids, target) 
开发者ID:sidewalklabs,项目名称:s2sphere,代码行数:17,代码来源:covering_test.py

示例2: break_down_area_to_cell

# 需要导入模块: import s2sphere [as 别名]
# 或者: from s2sphere import RegionCoverer [as 别名]
def break_down_area_to_cell(north, south, west, east):
    """ Return a list of s2 cell id"""
    result = []

    region = s2sphere.RegionCoverer()
    region.min_level = 15
    region.max_level = 15
    p1 = s2sphere.LatLng.from_degrees(north, west)
    p2 = s2sphere.LatLng.from_degrees(south, east)
    rect = s2sphere.LatLngRect.from_point_pair(p1, p2)

    print rect.area()
    if rect.area() * 1000 * 1000 * 100 > 5:
        return []

    cell_ids = region.get_covering(rect)
    result += [cell_id.id() for cell_id in cell_ids]
    print result

    return result 
开发者ID:chenditc-bittiger,项目名称:pokemon_R2_week4_coding_class,代码行数:22,代码来源:scan_area.py

示例3: break_down_area_to_cell

# 需要导入模块: import s2sphere [as 别名]
# 或者: from s2sphere import RegionCoverer [as 别名]
def break_down_area_to_cell(north, south, west, east):  
    print DBG + "Inside break_down_area_to_cell"
    result = []
    
    region = s2sphere.RegionCoverer()
    region.min_level = 15
    region.max_level = 15
    p1 = s2sphere.LatLng.from_degrees(north, west)
    p2 = s2sphere.LatLng.from_degrees(south, east)

    rect = s2sphere.LatLngRect.from_point_pair(p1, p2)
    area = rect.area()
    if (area * 1000 * 1000 * 100 > 7):
        print DBG + "The area is too big, return..."
        logger.info(DBG + "The area is too big, return...")
        return
    
    cell_ids = region.get_covering(s2sphere.LatLngRect.from_point_pair(p1, p2))
    result += [cell_id.id() for cell_id in cell_ids]
    print cell_ids

    return result 
开发者ID:hackjutsu,项目名称:pokemongo-map-poc,代码行数:24,代码来源:views.py

示例4: cover_region_s2

# 需要导入模块: import s2sphere [as 别名]
# 或者: from s2sphere import RegionCoverer [as 别名]
def cover_region_s2(location1,location2):
    rc = RegionCoverer()
    rc.max_level = lvl_big
    rc.min_level = lvl_big
    rc.max_cells = 1000
    locations = []

    if location1[0] > location2[0]:
        lat1,lat2 = location2[0],location1[0]
    else:
        lat1, lat2 = location1[0], location2[0]


    if location1[1] > location2[1]:
        lng1, lng2 = location2[1], location1[1]
    else:
        lng1, lng2 = location1[1], location2[1]

    lng1 = (lng1 + 180) % 360 - 180
    lng2 = (lng2 + 180) % 360 - 180

    lngs = []
    if lng2 > lng1:
        lngs.append((lng1,lng2))
    elif lng2 < lng1:
        lngs.append((-180.0,lng2))
        lngs.append((lng1,180.0))

    for lng1,lng2 in lngs:
        cids = rc.get_covering(LatLngRect(LatLng.from_degrees(lat1,lng1),LatLng.from_degrees(lat2,lng2)))

        for cid in cids:
            ll_cid = cid.to_lat_lng()
            locations.append((ll_cid.lat().degrees,ll_cid.lng().degrees))
    return locations 
开发者ID:seikur0,项目名称:PGO-mapscan-opt,代码行数:37,代码来源:maplib.py

示例5: get_cell_ids

# 需要导入模块: import s2sphere [as 别名]
# 或者: from s2sphere import RegionCoverer [as 别名]
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]) 
开发者ID:PokeHunterProject,项目名称:pogom-linux,代码行数:12,代码来源:utilities.py

示例6: break_down_area_to_cell

# 需要导入模块: import s2sphere [as 别名]
# 或者: from s2sphere import RegionCoverer [as 别名]
def break_down_area_to_cell(north, south, west, east):
    """ Return a list of s2 cell id"""
    result = []

    region = s2sphere.RegionCoverer()
    region.min_level = 15
    region.max_level = 15
    p1 = s2sphere.LatLng.from_degrees(north, west)
    p2 = s2sphere.LatLng.from_degrees(south, east)

    cell_ids = region.get_covering(s2sphere.LatLngRect.from_point_pair(p1, p2))
    result += [cell_id.id() for cell_id in cell_ids]
    print result

    return result 
开发者ID:chenditc-bittiger,项目名称:pokemon_R2_week4_coding_class,代码行数:17,代码来源:scan_area.py

示例7: cover_circle

# 需要导入模块: import s2sphere [as 别名]
# 或者: from s2sphere import RegionCoverer [as 别名]
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 
开发者ID:tcmaps,项目名称:fastmap,代码行数:12,代码来源:utils.py

示例8: cover_square

# 需要导入模块: import s2sphere [as 别名]
# 或者: from s2sphere import RegionCoverer [as 别名]
def cover_square(lat, lng, width, level=15):
    offset = int(width / 2)
    g = Geodesic.WGS84  # @UndefinedVariable
    r = RegionCoverer()
    r.min_level, r.min_level = level, level
    g1 = g.Direct(lat, lng, 360, offset)
    g1 = g.Direct(g1['lat2'],g1['lon2'],270,offset)
    p1 = LatLng.from_degrees(g1['lat2'],g1['lon2'])
    g2 = g.Direct(lat, lng, 180, offset)
    g2 = g.Direct(g2['lat2'],g2['lon2'], 90,offset)
    p2 = LatLng.from_degrees(g2['lat2'],g2['lon2'])
    cells = r.get_covering(LatLngRect.from_point_pair(p1, p2))
    return cells 
开发者ID:tcmaps,项目名称:fastmap,代码行数:15,代码来源:utils.py

示例9: break_down_area_to_cell

# 需要导入模块: import s2sphere [as 别名]
# 或者: from s2sphere import RegionCoverer [as 别名]
def break_down_area_to_cell(north, south, west, east): 
    "return a list of s2 cell ids"
    result = []
    
    region = s2sphere.RegionCoverer()
    region.min_level = 15
    region.max_level = 15
    p1 = s2sphere.LatLng.from_degrees(north, west)
    p2 = s2sphere.LatLng.from_degrees(south, east)

    cell_ids = region.get_covering(s2sphere.LatLngRect.from_point_pair(p1, p2))
    result += [cell_id.id() for cell_id in cell_ids]
    #  print cell_ids

    return result 
开发者ID:hackjutsu,项目名称:pokemongo-map-poc,代码行数:17,代码来源:my_pokemon_api.py

示例10: get_cell_ids

# 需要导入模块: import s2sphere [as 别名]
# 或者: from s2sphere import RegionCoverer [as 别名]
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]) 
开发者ID:favll,项目名称:pogom,代码行数:14,代码来源:utilities.py

示例11: cover_circle

# 需要导入模块: import s2sphere [as 别名]
# 或者: from s2sphere import RegionCoverer [as 别名]
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 
开发者ID:tcmaps,项目名称:pickymap,代码行数:12,代码来源:ext.py


注:本文中的s2sphere.RegionCoverer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。