本文整理汇总了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]
示例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())
示例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)
示例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())
示例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())
示例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())
示例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)
示例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)
示例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
}