def format(entry): formatted_entry = ad.AttrDict() formatted_entry["_id"] = entry["_id"] formatted_entry.user_id = entry.user_id m = entry.metadata if "time_zone" not in m: m.time_zone = "America/Los_Angeles" logging.debug("Timestamp conversion: %s -> %s done" % (entry.metadata.write_ts, m.write_ts)) fc.expand_metadata_times(m) formatted_entry.metadata = m data = ad.AttrDict() data.curr_state = state_map[entry.data.currState].value logging.debug("Mapped %s -> %s" % (entry.data.currState, data.curr_state)) data.transition = transition_map[entry.data.transition].value if "ts" not in data: data.ts = formatted_entry.metadata.write_ts logging.debug("No existing timestamp, copyied from metadata%s" % data.ts) data.local_dt = formatted_entry.metadata.write_local_dt data.fmt_time = formatted_entry.metadata.write_fmt_time else: logging.debug("Retaining existing timestamp %s" % data.ts) fc.expand_data_times(data, metadata) formatted_entry.data = data return formatted_entry
def format(entry): formatted_entry = ad.AttrDict() formatted_entry["_id"] = entry["_id"] formatted_entry.user_id = entry.user_id m = entry.metadata if "time_zone" not in m: m.time_zone = "America/Los_Angeles" logging.debug("Timestamp conversion: %s -> %s done" % (entry.metadata.write_ts, m.write_ts)) fc.expand_metadata_times(m) formatted_entry.metadata = m data = ad.AttrDict() data.curr_state = state_map[entry.data.currState].value logging.debug("Mapped %s -> %s" % (entry.data.currState, data.curr_state)) data.transition = transition_map[entry.data.transition].value if "ts" not in data: data.ts = formatted_entry.metadata.write_ts logging.debug("No existing timestamp, copyied from metadata%s" % data.ts) data.local_dt = formatted_entry.metadata.write_local_dt data.fmt_time = formatted_entry.metadata.write_fmt_time else: logging.debug("Retaining existing timestamp %s" % data.ts) fc.expand_data_times(data, metadata) formatted_entry.data = data return formatted_entry
def format_location_raw(entry): formatted_entry = ad.AttrDict() formatted_entry["_id"] = entry["_id"] formatted_entry.user_id = entry.user_id metadata = entry.metadata metadata.time_zone = "America/Los_Angeles" metadata.write_ts = old_div(float(entry.metadata.write_ts), 1000) fc.expand_metadata_times(metadata) formatted_entry.metadata = metadata data = ad.AttrDict() data.latitude = entry.data.mLatitude data.longitude = entry.data.mLongitude data.loc = geojson.Point((data.longitude, data.latitude)) data.ts = old_div(float(entry.data.mTime), 1000) # convert the ms from the phone to secs fc.expand_data_times(data, metadata) data.altitude = entry.data.mAltitude data.accuracy = entry.data.mAccuracy data.sensed_speed = entry.data.mSpeed data.heading = entry.data.mBearing formatted_entry.data = data return formatted_entry
def format_location_simple(entry): formatted_entry = ad.AttrDict() formatted_entry["_id"] = entry["_id"] formatted_entry.user_id = entry.user_id metadata = entry.metadata fc.expand_metadata_times(metadata) formatted_entry.metadata = metadata data = entry.data fc.expand_data_times(data, metadata) data.loc = geojson.Point((data.longitude, data.latitude)) data.heading = entry.data.bearing del data.bearing formatted_entry.data = data return formatted_entry
def format(entry): formatted_entry = ad.AttrDict() formatted_entry["_id"] = entry["_id"] formatted_entry.user_id = entry.user_id metadata = entry.metadata if "time_zone" not in metadata: metadata.time_zone = "America/Los_Angeles" logging.debug("Timestamp conversion: %s -> %s done" % (entry.metadata.write_ts, metadata.write_ts)) fc.expand_metadata_times(metadata) formatted_entry.metadata = metadata data = entry.data fc.expand_data_times(data, metadata) formatted_entry.data = data return formatted_entry
def format_location_simple(entry): formatted_entry = ad.AttrDict() formatted_entry["_id"] = entry["_id"] formatted_entry.user_id = entry.user_id metadata = entry.metadata fc.expand_metadata_times(metadata) formatted_entry.metadata = metadata data = entry.data fc.expand_data_times(data, metadata) data.loc = geojson.Point((data.longitude, data.latitude)) data.heading = entry.data.bearing del data.bearing formatted_entry.data = data return formatted_entry
def format(entry): formatted_entry = ad.AttrDict() formatted_entry["_id"] = entry["_id"] formatted_entry.user_id = entry.user_id metadata = entry.metadata if "time_zone" not in metadata: metadata.time_zone = "America/Los_Angeles" logging.debug("Timestamp conversion: %s -> %s done" % (entry.metadata.write_ts, metadata.write_ts)) fc.expand_metadata_times(metadata) formatted_entry.metadata = metadata data = entry.data fc.expand_data_times(data, metadata) data.local_dt = ecsdlq.get_local_date(data.ts, metadata.time_zone) data.fmt_time = arrow.get(data.ts).to(metadata.time_zone).isoformat() formatted_entry.data = data return formatted_entry
def format(entry): formatted_entry = ad.AttrDict() formatted_entry["_id"] = entry["_id"] formatted_entry.user_id = entry.user_id metadata = entry.metadata if "time_zone" not in metadata: metadata.time_zone = "America/Los_Angeles" logging.debug("Timestamp conversion: %s -> %s done" % (entry.metadata.write_ts, metadata.write_ts)) fc.expand_metadata_times(metadata) formatted_entry.metadata = metadata data = entry.data fc.expand_data_times(data, metadata) data.local_dt = ecsdlq.get_local_date(data.ts, metadata.time_zone) data.fmt_time = arrow.get(data.ts).to(metadata.time_zone).isoformat() formatted_entry.data = data return formatted_entry
def format(entry): formatted_entry = ad.AttrDict() formatted_entry["_id"] = entry["_id"] formatted_entry.user_id = entry.user_id m = entry.metadata fc.expand_metadata_times(m) formatted_entry.metadata = m data = ad.AttrDict() data.curr_state = state_map[entry.data.currState].value logging.debug("Mapped %s -> %s" % (entry.data.currState, data.curr_state)) # The iOS state diagram is significantly more complex than the android state diagram # So there are a lot more transitions. But some of the intermediate states are # not interesting, so it seems like it should be possible to collapse them to the # simple 2-state android state machine. But that requires looking at a window of # transitions, which we don't have here. Let's focus on simply mapping here and # deal with collapsing later # data.transition_raw = entry.data.transition data.transition = transition_map[entry.data.transition].value if entry.data.transition is not None: data.transition = transition_map[entry.data.transition].value else: data.transition = None logging.debug("Mapped %s -> %s" % (entry.data.transition, data.transition)) if "ts" not in data: data.ts = formatted_entry.metadata.write_ts logging.debug("No existing timestamp, copyied from metadata%s" % data.ts) data.local_dt = formatted_entry.metadata.write_local_dt data.fmt_time = formatted_entry.metadata.write_fmt_time else: logging.debug("Retaining existing timestamp %s" % data.ts) fc.expand_data_times(data, metadata) formatted_entry.data = data return formatted_entry
def format_location_raw(entry): formatted_entry = ad.AttrDict() formatted_entry["_id"] = entry["_id"] formatted_entry.user_id = entry.user_id metadata = entry.metadata metadata.time_zone = "America/Los_Angeles" metadata.write_ts = old_div(float(entry.metadata.write_ts), 1000) fc.expand_metadata_times(metadata) formatted_entry.metadata = metadata data = ad.AttrDict() data.latitude = entry.data.mLatitude data.longitude = entry.data.mLongitude data.loc = geojson.Point((data.longitude, data.latitude)) data.ts = old_div(float(entry.data.mTime), 1000) # convert the ms from the phone to secs fc.expand_data_times(data, metadata) data.altitude = entry.data.mAltitude data.accuracy = entry.data.mAccuracy data.sensed_speed = entry.data.mSpeed data.heading = entry.data.mBearing formatted_entry.data = data return formatted_entry