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


Python DotDict.location方法代码示例

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


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

示例1: get_realtime

# 需要导入模块: from utils.dotdict import DotDict [as 别名]
# 或者: from utils.dotdict.DotDict import location [as 别名]
    def get_realtime(self, uid, sim):
        """Get the location of the current realtime request.

        workflow:
        if there is alive memcached, we can get location from it,
        else get location from db
        return result to user browser
        """
        ret = DotDict(status=ErrorCode.SUCCESS,
                      message='',
                      location=None)
        location = QueryHelper.get_location_info(self.current_user.tid, self.db, self.redis)

        locations = [location,] 
        locations = get_locations_with_clatlon(locations, self.db) 
        location = locations[0]

        if (location and location.clatitude and location.clongitude):
            if not location.name:
                location.name = ''
            if location.has_key('id'):
                del location['id']

            location['degree'] = float(location.degree)
            location['tid'] = self.current_user.tid
            ret.location = location

        return ret
开发者ID:jcsy521,项目名称:ydws,代码行数:30,代码来源:realtime.py

示例2: request_realtime

# 需要导入模块: from utils.dotdict import DotDict [as 别名]
# 或者: from utils.dotdict.DotDict import location [as 别名]
    def request_realtime(self, query, callback=None):
        """
        All realtime requests in REALTIME_VALID_INTERVAL will be considered as
        only one. If not, invoke gf and use handle_location of lbmphelper. 
        """
        location = QueryHelper.get_location_info(self.current_user.tid, self.db, self.redis)
        if location and location['name'] is None:
            location['name'] = '' 
                
        ret = DotDict(status=ErrorCode.SUCCESS,
                      message='',
                      location=None)

        locations = [location,] 
        locations = get_locations_with_clatlon(locations, self.db) 
        location = locations[0]

        if (location and location.clatitude and location.clongitude):
            if location.has_key('id'):
                del location['id']
            
            location['degree'] = float(location.degree)
            location['tid'] = self.current_user.tid
            ret.location = location
            if callback:
                callback(ret)
                return

        lat, lon = get_latlon_from_cellid(0,0,0,0, self.current_user.sim)
        clat, clon = get_clocation_from_ge([lat,],[lon,]) 
        clat = int(clat[0]) if len(clat)>0 else 0 
        clon = int(clon[0]) if len(clon)>0 else 0 
        name = get_location_name(clat, clon, self.redis)
        
        location = DotDict(category = 1, # cellid
                           dev_id = self.current_user.tid, 
                           lat = lat, 
                           lon = lon, 
                           cLat = clat, 
                           cLon = clon, 
                           alt = 0,
                           gps_time = int(time.time()), 
                           type = 1, 
                           speed = 0.0, 
                           degree = 0.0, 
                           name = name, 
                           cellid = None,
                           locate_error = 20)
        if clat and clon:
            ret.location = DotDict()
            ret.location.latitude = lat
            ret.location.longitude = lon
            ret.location.clongitude = clon
            ret.location.clatitude = clat
            ret.location.timestamp = int(time.time()) 
            ret.location.name = name
            ret.location.speed = 0
            ret.location.type = 1
            ret.location.tid = self.current_user.tid
            ret.location.degree = 0.0 
            ret.location.locte_error = 20 
            insert_location(location, self.db, self.redis)
            logging.info("[UWEB] tid %s cellid query success", self.current_user.tid)
        else:
            ret.status = ErrorCode.LOCATION_CELLID_FAILED 
            ret.message = ErrorCode.ERROR_MESSAGE[ret.status]
            logging.info("[UWEB] Do not find any location, and cellid query failed. tid: %s", 
                         self.current_user.tid)

        if callback:
            callback(ret)
开发者ID:jcsy521,项目名称:ydws,代码行数:73,代码来源:realtime.py


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