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


Python AttrDict.start_time方法代码示例

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


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

示例1: load_file

# 需要导入模块: from attrdict import AttrDict [as 别名]
# 或者: from attrdict.AttrDict import start_time [as 别名]
def load_file(curr_list):
    prevSection = None
    for entryJSON in curr_list:
        entryDict = AttrDict(entryJSON)
        if entryDict.type == "move":
            trip_id = entryDict.startTime
            for i, activity in enumerate(entryDict.activities):
                print("For trip id = %s, activity %s starts at %s" % (trip_id, i, activity.startTime))
                section = AttrDict()
                section.id = trip_id + "_"+ str(i)
                section.filter = "time"
                section.source = "raw_auto"
                section.start_time = activity.startTime
                section.end_time = activity.endTime
                if prevSection is None:
                    prevSection = section
                else:
                    section.prev_section = prevSection.id
                    prevSection.next_section = section.id
                    prevSection = section
                try:
                    section.start_ts = to_ts(parser.parse(activity.startTime))
                    section.end_ts = to_ts(parser.parse(activity.endTime))
                except ValueError:
                    if len(entryDict.activities) == 1:
                        print("One section case: Error parsing times %s or %s, using start and end points of the trip %s %s instead" % 
                              (activity.startTime, activity.endTime, entryDict.startTime, entryDict.endTime))
                        section.start_ts = to_ts(parser.parse(entryDict.startTime))
                        section.end_ts = to_ts(parser.parse(entryDict.endTime))
                    else:
                        if (i < (len(entryDict.activities) - 1)):
                            # This is not the last activity
                            print("Multi-section, not last section case: Error parsing times %s or %s, using start times of this and next section %s %s instead" %
                                  (activity.startTime, activity.endTime, activity.trackPoints[0].time,
                                   entryDict.activities[i+1].trackPoints[0].time))
                            section.start_ts = to_ts(parser.parse(activity.trackPoints[0].time))
                            section.end_ts = to_ts(parser.parse(entryDict.activities[i+1].trackPoints[0].time))
                        else:
                            # This is the last activity
                            print("Multi-section, last section case: Error parsing times %s or %s, using start times of this and next section %s %s instead" %
                                  (activity.startTime, activity.endTime, activity.trackPoints[0].time,
                                   entryDict.endTime))
                            section.start_ts = to_ts(parser.parse(activity.trackPoints[0].time))
                            section.end_ts = to_ts(parser.parse(entryDict.endTime))

                print("For section %s, inserting track points %s" % (section, len(activity.trackPoints)))
                reconstructedTripsDb.insert(section)
                for i, tp in enumerate(activity.trackPoints):
                    if "accuracy" not in tp:
                        print "Skipping point %d of section %s because it has no accuracy" % (i, section.id)
                        continue
                    point = AttrDict()
                    point.user_id = section.id
                    point.section_id = section.id

                    pointMetadata = AttrDict()
                    pointMetadata.key = "background/location"
                    pointMetadata.filter = "time"
                    point.metadata = pointMetadata

                    pointData = AttrDict()
                    pointData.idx = i
                    pointData.mLatitude = tp.lat
                    pointData.mLongitude = tp.lon
                    pointData.formatted_time = tp.time
                    pointData.mTime = to_ts(parser.parse(tp.time))
                    pointData.mAccuracy = tp.accuracy
                    point.data = pointData
                    # print "Got track point %s" % point
                    reconstructedTimeSeriesDb.insert(point)
开发者ID:adambrown13,项目名称:e-mission-server,代码行数:72,代码来源:read_data_from_raw_dumps.py


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