本文整理汇总了Python中helpers.queryhelper.QueryHelper.get_gps_location_info方法的典型用法代码示例。如果您正苦于以下问题:Python QueryHelper.get_gps_location_info方法的具体用法?Python QueryHelper.get_gps_location_info怎么用?Python QueryHelper.get_gps_location_info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类helpers.queryhelper.QueryHelper
的用法示例。
在下文中一共展示了QueryHelper.get_gps_location_info方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle_location
# 需要导入模块: from helpers.queryhelper import QueryHelper [as 别名]
# 或者: from helpers.queryhelper.QueryHelper import get_gps_location_info [as 别名]
def handle_location(location, redis, cellid=False, db=None):
"""
@param location: position/report/locationdesc/pvt
memcached
cellid: if True issue cellid
@return location
eg.
{u'gps_time': 1407138438,
u'dev_id': u'T123SIMULATOR',
u'defend_status': u'1',
u'locate_error': 20,
u'alt': 0,
u'speed': 126.3,
u'cLat': 0,
u'cLon': 0,
u'lon': 418507200,
u'valid': u'0',
u'ns': u'N',
u'gps': u'20',
u'fobid': u'',
u'degree': 276.5,
u'softversion': u'1.0.0',
u'timestamp': 1407138438,
u'terminal_type': u'1',
u'sessionID': u'cyndqhy9',
u'pbat': u'10',
u'lat': 95630400,
u'is_notify': u'',
u'rName': u'POWERDOWN',
u'name': None,
u'ew': u'E',
u'dev_type': u'1',
u'command': u'T26',
u't': u'REPORT',
u'gsm': u'6',
u'cellid': u'460:0:10101:03633'
u'type':0,
u'category':9,
}
"""
location = DotDict(location)
if location.valid == GATEWAY.LOCATION_STATUS.SUCCESS: # 1
location.type = 0
if location.get('speed') is not None and location.speed <= UWEB.SPEED_DIFF:
pass
#location.degree = get_last_degree(location, redis, db)
elif location.valid == GATEWAY.LOCATION_STATUS.UNMOVE: # 4
logging.info("[LBMPHELPER] Tid:%s gps locate flag :%s", location.dev_id, location.valid)
#last_location = QueryHelper.get_location_info(location.dev_id, db, redis)
last_location = QueryHelper.get_gps_location_info(location.dev_id, db, redis)
if last_location:
current_time = int(time.time())
diff = current_time - last_location.timestamp
logging.info("[LBMPHELPER] current time:%s, last locaiton time:%s, diff time:%s", current_time, last_location.timestamp, diff)
if (current_time - last_location.timestamp) < 60 * 60 * 24 * 30: # 30 days. in seconds
logging.info("[LBMPHELPER] Tid:%s, current_time - last_location.timestamp < 30 days, so use last location time:%s",
location.dev_id, last_location.timestamp)
location.gps_time = last_location.timestamp
location.lat = last_location.latitude
location.lon = last_location.longitude
location.cLat = last_location.clatitude
location.cLon = last_location.clongitude
location.type = 0
location.gps = 0
else:
location.type = 0
logging.info("[LBMPHELPER] Tid:%s, current_time - last_location.timestamp >= 600s, so use location itself: %s.", location.dev_id, location)
pass
else:
location.type = 0
logging.info("[LBMPHELPER] Tid:%s, found no location before, so use location itself: %s.", location.dev_id, location)
pass
# location.lat = last_location.latitude
# if (current_time - last_location.timestamp) > 600:
# location.gps_time = current_time
# logging.info("Tid:%s, current_time - last_location.timestamp > 600s, so use current time:%s", location.dev_id, current_time)
# else:
# logging.info("Tid:%s, current_time - last_location.timestamp <= 600s, so use last location time:%s", location.dev_id, last_location.timestamp)
# location.gps_time = last_location.timestamp
# location.lat = last_location.latitude
# location.lon = last_location.longitude
# location.cLat = last_location.clatitude
# location.cLon = last_location.clongitude
# location.type = 0
# location.gps = 0
#else:
# location.lat = 0
# location.lon = 0
# location.cLat = 0
# location.cLon = 0
# location.type = 0
# location.gps_time = int(time.time())
# location.degree = 0.00
# location.gps = 0
# #if cellid:
# # location = issue_cellid(location, db, redis)
elif location.valid == GATEWAY.LOCATION_STATUS.MOVE: # 6
#.........这里部分代码省略.........