當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。