def _append_visit_to_memory(self, outcome): id_stay_point = 0 if outcome.event_type == GeoFencingOutcome.TYPE_ARRIVING_STAY_POINT: id_stay_point = outcome.stay_point.id_stay_point elif outcome.event_type == GeoFencingOutcome.TYPE_LEAVING_AND_ARRIVING: id_stay_point = outcome.stay_point_2.id_stay_point visit = Visit(0, id_stay_point, pivot_arrival_fix=outcome.event_fix, pivot_departure_fix=outcome.event_fix, detection_arrival_fix=outcome.detection_fix, detection_departure_fix=outcome.detection_fix) self._visits_dal.add(visit)
def build_visit_from_line(line: Dict) -> Visit: """ Builds a Visit object parsing the specified line :param line: The line to parse :return: A Visit object """ id_visit = int(line["_id"]) id_stay_point = int(line["idStayPoint"]) arrival_time = datetime.strptime(line["arrivalTime"], '%Y-%m-%d %H:%M:%S') fake_arrival_fix = GpsFix(0, 0, arrival_time, 0, 0, 0) departure_time = datetime.strptime(line["departureTime"], '%Y-%m-%d %H:%M:%S') fake_departure_fix = GpsFix(0, 0, departure_time, 0, 0, 0) # visit = Visit(id_visit, id_stay_point, arrival_time, departure_time) visit = Visit(id_visit, id_stay_point, fake_arrival_fix, fake_departure_fix, fake_arrival_fix, fake_departure_fix) return visit
def _insert_visit_from_new_stay_point( self, stay_point_id, live_stay_point: LiveStayPoint) -> Visit: self.is_last_visit_because_new_stay_point = True fake_arrival_fix = GpsFix(live_stay_point.latitude, live_stay_point.longitude, live_stay_point.arrival_time) fake_departure_fix = GpsFix(live_stay_point.latitude, live_stay_point.longitude, live_stay_point.departure_time) visit = Visit(0, stay_point_id, pivot_arrival_fix=fake_arrival_fix, pivot_departure_fix=fake_departure_fix, detection_arrival_fix=fake_arrival_fix, detection_departure_fix=fake_departure_fix) added_visit = self._visits_dal.add(visit) return added_visit