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


Python s2sphere.CellId方法代码示例

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


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

示例1: get_search_points

# 需要导入模块: import s2sphere [as 别名]
# 或者: from s2sphere import CellId [as 别名]
def get_search_points(self, cell_id):
        points = []

        # For cell level 15
        for c in Cell(CellId(cell_id)).subdivide():
            for cc in c.subdivide():
                latlng = LatLng.from_point(cc.get_center())
                point = (latlng.lat().degrees, latlng.lng().degrees)
                points.append(point)

        points[0], points[1] = points[1], points[0]
        points[14], points[15] = points[15], points[14]
        point = points.pop(2)
        points.insert(7, point)
        point = points.pop(13)
        points.insert(8, point)

        closest = min(points, key=lambda p: great_circle(self.bot.position, p).meters)
        index = points.index(closest)

        return points[index:] + points[:index] 
开发者ID:PokemonGoF,项目名称:PokemonGo-Bot,代码行数:23,代码来源:pokemon_hunter.py

示例2: test_cellid

# 需要导入模块: import s2sphere [as 别名]
# 或者: from s2sphere import CellId [as 别名]
def test_cellid(self):
        lat, lng = (33, -122)
        py_cellid = s2sphere.CellId.from_lat_lng(
            s2sphere.LatLng.from_degrees(lat, lng)
        )
        cpp_cellid = s2.S2CellId.FromLatLng(
            s2.S2LatLng.FromDegrees(lat, lng)
        )
        self.assertEqual(py_cellid.id(), cpp_cellid.id()) 
开发者ID:sidewalklabs,项目名称:s2sphere,代码行数:11,代码来源:compare_implementations.py

示例3: get_position_from_cell

# 需要导入模块: import s2sphere [as 别名]
# 或者: from s2sphere import CellId [as 别名]
def get_position_from_cell(cellid):
    cell = CellId(id_ = long(cellid)).to_lat_lng()
    return (math.degrees(cell._LatLng__coords[0]), math.degrees(cell._LatLng__coords[1]), 0) 
开发者ID:hackjutsu,项目名称:pokemongo-map-poc,代码行数:5,代码来源:my_pokemon_api.py

示例4: cellid_parent_comparison

# 需要导入模块: import s2sphere [as 别名]
# 或者: from s2sphere import CellId [as 别名]
def cellid_parent_comparison(self, level=12):
        lat, lng = (33, -122)
        py_cellid = (s2sphere.CellId
                     .from_lat_lng(s2sphere.LatLng.from_degrees(lat, lng))
                     .parent(level))
        cpp_cellid = (s2.S2CellId
                      .FromLatLng(s2.S2LatLng.FromDegrees(lat, lng))
                      .parent(level))
        self.assertEqual(py_cellid.id(), cpp_cellid.id()) 
开发者ID:sidewalklabs,项目名称:s2sphere,代码行数:11,代码来源:compare_implementations.py

示例5: test_cellid_from_truncated_token

# 需要导入模块: import s2sphere [as 别名]
# 或者: from s2sphere import CellId [as 别名]
def test_cellid_from_truncated_token(self):
        py_cellid = s2sphere.CellId.from_token('89c259c4')
        cpp_cellid = s2.S2CellId.FromToken('89c259c4')
        self.assertEqual(py_cellid.id(), cpp_cellid.id()) 
开发者ID:sidewalklabs,项目名称:s2sphere,代码行数:6,代码来源:compare_implementations.py

示例6: test_cellid_to_token

# 需要导入模块: import s2sphere [as 别名]
# 或者: from s2sphere import CellId [as 别名]
def test_cellid_to_token(self):
        py_cellid = s2sphere.CellId.from_token('89c259c4')
        cpp_cellid = s2.S2CellId.FromToken('89c259c4')
        self.assertEqual(py_cellid.to_token(), cpp_cellid.ToToken()) 
开发者ID:sidewalklabs,项目名称:s2sphere,代码行数:6,代码来源:compare_implementations.py

示例7: test_average_area

# 需要导入模块: import s2sphere [as 别名]
# 或者: from s2sphere import CellId [as 别名]
def test_average_area(self):
        # has not equivalent SWIG wrapped version
        py_cell = s2sphere.Cell(s2sphere.CellId.from_token('89c259c4'))
        self.assertEqual(py_cell.average_area(), 3.120891902436607e-08) 
开发者ID:sidewalklabs,项目名称:s2sphere,代码行数:6,代码来源:compare_implementations.py

示例8: get_position_from_cell_id

# 需要导入模块: import s2sphere [as 别名]
# 或者: from s2sphere import CellId [as 别名]
def get_position_from_cell_id(cell_id):
    cell = s2sphere.CellId(id_ = cell_id).to_lat_lng()

    return (math.degrees(cell._LatLng__coords[0]), math.degrees(cell._LatLng__coords[1]), 0) 
开发者ID:chenditc-bittiger,项目名称:pokemon_R2_week4_coding_class,代码行数:6,代码来源:scan_area.py

示例9: get_meta_cell

# 需要导入模块: import s2sphere [as 别名]
# 或者: from s2sphere import CellId [as 别名]
def get_meta_cell(self):
        location = self.position[0:2]
        cells = self.find_close_cells(*location)

        # Combine all cells into a single dict of the items we care about.
        forts = []
        wild_pokemons = []
        catchable_pokemons = []
        nearby_pokemons = []
        for cell in cells:
            if "forts" in cell and len(cell["forts"]):
                forts += cell["forts"]
            if "wild_pokemons" in cell and len(cell["wild_pokemons"]):
                wild_pokemons += cell["wild_pokemons"]
            if "catchable_pokemons" in cell and len(cell["catchable_pokemons"]):
                catchable_pokemons += cell["catchable_pokemons"]
            if "nearby_pokemons" in cell and len(cell["nearby_pokemons"]):
                latlng = LatLng.from_point(Cell(CellId(cell["s2_cell_id"])).get_center())

                for p in cell["nearby_pokemons"]:
                    p["latitude"] = latlng.lat().degrees
                    p["longitude"] = latlng.lng().degrees
                    p["s2_cell_id"] = cell["s2_cell_id"]

                nearby_pokemons += cell["nearby_pokemons"]

        # If there are forts present in the cells sent from the server or we don't yet have any cell data, return all data retrieved
        if len(forts) > 1 or not self.cell:
            return {
                "forts": forts,
                "wild_pokemons": wild_pokemons,
                "catchable_pokemons": catchable_pokemons,
                "nearby_pokemons": nearby_pokemons
            }
        # If there are no forts present in the data from the server, keep our existing fort data and only update the pokemon cells.
        else:
            return {
                "forts": self.cell["forts"],
                "wild_pokemons": wild_pokemons,
                "catchable_pokemons": catchable_pokemons,
                "nearby_pokemons": nearby_pokemons
            } 
开发者ID:PokemonGoF,项目名称:PokemonGo-Bot,代码行数:44,代码来源:__init__.py


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