本文整理汇总了Python中ichnaea.models.content.DataMap.shard_id方法的典型用法代码示例。如果您正苦于以下问题:Python DataMap.shard_id方法的具体用法?Python DataMap.shard_id怎么用?Python DataMap.shard_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ichnaea.models.content.DataMap
的用法示例。
在下文中一共展示了DataMap.shard_id方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_shard_id
# 需要导入模块: from ichnaea.models.content import DataMap [as 别名]
# 或者: from ichnaea.models.content.DataMap import shard_id [as 别名]
def test_shard_id(self):
assert DataMap.shard_id(None, None) is None
assert DataMap.shard_id(85000, 180000) == 'ne'
assert DataMap.shard_id(36000, 5000) == 'ne'
assert DataMap.shard_id(35999, 5000) == 'se'
assert DataMap.shard_id(-85000, 180000) == 'se'
assert DataMap.shard_id(85000, -180000) == 'nw'
assert DataMap.shard_id(36000, 4999) == 'nw'
assert DataMap.shard_id(35999, 4999) == 'sw'
assert DataMap.shard_id(-85000, -180000) == 'sw'
示例2: test_shard_id
# 需要导入模块: from ichnaea.models.content import DataMap [as 别名]
# 或者: from ichnaea.models.content.DataMap import shard_id [as 别名]
def test_shard_id(self):
self.assertEqual(DataMap.shard_id(None, None), None)
self.assertEqual(DataMap.shard_id(85000, 180000), 'ne')
self.assertEqual(DataMap.shard_id(36000, 5000), 'ne')
self.assertEqual(DataMap.shard_id(35999, 5000), 'se')
self.assertEqual(DataMap.shard_id(-85000, 180000), 'se')
self.assertEqual(DataMap.shard_id(85000, -180000), 'nw')
self.assertEqual(DataMap.shard_id(36000, 4999), 'nw')
self.assertEqual(DataMap.shard_id(35999, 4999), 'sw')
self.assertEqual(DataMap.shard_id(-85000, -180000), 'sw')
示例3: _queue
# 需要导入模块: from ichnaea.models.content import DataMap [as 别名]
# 或者: from ichnaea.models.content.DataMap import shard_id [as 别名]
def _queue(self, pairs):
grids = defaultdict(list)
for lat, lon in pairs:
lat, lon = DataMap.scale(lat, lon)
shard_id = DataMap.shard_id(lat, lon)
grids[shard_id].append(encode_datamap_grid(lat, lon))
for shard_id, values in grids.items():
queue = self.celery_app.data_queues['update_datamap_' + shard_id]
queue.enqueue(list(values), json=False)
示例4: test_one
# 需要导入模块: from ichnaea.models.content import DataMap [as 别名]
# 或者: from ichnaea.models.content.DataMap import shard_id [as 别名]
def test_one(self):
lat = 1.234567
lon = 2.345678
shard_id = DataMap.shard_id(*DataMap.scale(lat, lon))
self._queue([(lat, lon)])
update_datamap.delay(shard_id=shard_id).get()
grids = self.session.query(DataMap.shards()[shard_id]).all()
self.assertEqual(len(grids), 1)
self._check_position(grids[0], 1.235, 2.346)
self.assertEqual(grids[0].created, self.today)
self.assertEqual(grids[0].modified, self.today)
示例5: test_one
# 需要导入模块: from ichnaea.models.content import DataMap [as 别名]
# 或者: from ichnaea.models.content.DataMap import shard_id [as 别名]
def test_one(self, celery, session):
lat = 1.234567
lon = 2.345678
shard_id = DataMap.shard_id(*DataMap.scale(lat, lon))
self._queue(celery, [(lat, lon)])
update_datamap.delay(shard_id=shard_id).get()
grids = session.query(DataMap.shards()[shard_id]).all()
assert len(grids) == 1
self._check_position(grids[0], 1.235, 2.346)
assert grids[0].created == self.today
assert grids[0].modified == self.today
示例6: test_update
# 需要导入模块: from ichnaea.models.content import DataMap [as 别名]
# 或者: from ichnaea.models.content.DataMap import shard_id [as 别名]
def test_update(self):
lat = 1.0
lon = 2.0
shard_id = DataMap.shard_id(*DataMap.scale(lat, lon))
self._add([(lat, lon, self.yesterday)])
self._queue([(lat, lon)])
update_datamap.delay(shard_id=shard_id).get()
grids = self.session.query(DataMap.shards()[shard_id]).all()
self.assertEqual(len(grids), 1)
self._check_position(grids[0], 1.0, 2.0)
self.assertEqual(grids[0].created, self.yesterday)
self.assertEqual(grids[0].modified, self.today)
示例7: test_update
# 需要导入模块: from ichnaea.models.content import DataMap [as 别名]
# 或者: from ichnaea.models.content.DataMap import shard_id [as 别名]
def test_update(self, celery, session):
lat = 1.0
lon = 2.0
shard_id = DataMap.shard_id(*DataMap.scale(lat, lon))
self._add(session, [(lat, lon, self.yesterday)])
self._queue(celery, [(lat, lon)])
update_datamap.delay(shard_id=shard_id).get()
grids = session.query(DataMap.shards()[shard_id]).all()
assert len(grids) == 1
self._check_position(grids[0], 1.0, 2.0)
assert grids[0].created == self.yesterday
assert grids[0].modified == self.today