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


Python DotDict.locate_error方法代码示例

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


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

示例1: insert_location

# 需要导入模块: from utils.dotdict import DotDict [as 别名]
# 或者: from utils.dotdict.DotDict import locate_error [as 别名]
def insert_location(location, db, redis):
    """Insert whole-data into T_LOCATION.
    """
    location = DotDict(location)
    # NOTE: if locate_error is bigger then 500, set it 500
    if int(location.locate_error) > 500:
        location.locate_error = 500
    lid = db.execute("INSERT INTO T_LOCATION(tid, latitude, longitude, altitude,"
                     "    clatitude, clongitude, timestamp, name, category, type,"
                     "    speed, degree, cellid, locate_error)"
                     "  VALUES (%s, %s, %s, %s, %s, %s, %s,"
                     "          %s, %s, %s, %s, %s, %s, %s)",
                     location.dev_id, location.lat, location.lon,
                     location.alt, location.cLat, location.cLon,
                     location.gps_time, location.name,
                     location.category, location.type,
                     location.speed, location.degree,
                     location.cellid, location.locate_error)
    if location.lat and location.lon:
        track_key = get_track_key(location.dev_id)
        track = redis.get(track_key)
        # if track is on, just put PVT into redis
        # maybe put cellid into redis later.
        # if track and (int(track) == 1) and (location.get("Tid", None) != EVENTER.TRIGGERID.PVT):
        #    return lid
        # NOTE: if location's type is gps, put it into redis
        if track and (int(track) == 1) and (location.type != 0):
            return lid

        location_key = get_location_key(location.dev_id)
        last_location = redis.getvalue(location_key)
        if (last_location and (location.gps_time > last_location['timestamp'])) or\
                not last_location:

            logging.info("[PUBLIC] Keep location in redis. tid: %s, location: %s",
                         location.dev_id, location)
            mem_location = {'id': lid,
                            'latitude': location.lat,
                            'longitude': location.lon,
                            'type': location.type,
                            'clatitude': location.cLat,
                            'clongitude': location.cLon,
                            'timestamp': location.gps_time,
                            'name': location.name,
                            'degree': location.degree,
                            'speed': location.speed,
                            'locate_error': location.locate_error}
            location_key = get_location_key(location.dev_id)
            redis.setvalue(location_key, mem_location, EVENTER.LOCATION_EXPIRY)

            if int(location.type) == 0:  # gps
                logging.info("[PUBLIC] Keep gps_location in gps_redis. tid: %s, location: %s",
                             location.dev_id, location)
                location_key = get_gps_location_key(location.dev_id)
                redis.setvalue(
                    location_key, mem_location, EVENTER.LOCATION_EXPIRY)

    return lid
开发者ID:jcsy521,项目名称:ydws,代码行数:60,代码来源:public.py


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