Beispiel #1
0
def get_filtered_place(raw_place):
    filtered_place_data = ecwcp.Cleanedplace()

    _copy_non_excluded(old_data=raw_place.data,
                       new_data=filtered_place_data,
                       excluded_list=filtered_place_excluded)

    filtered_place_data.raw_places = []
    filtered_place_data.append_raw_place(raw_place.get_id())

    try:
        reverse_geocoded_json = eco.Geocoder.get_json_reverse(
            filtered_place_data.location.coordinates[1],
            filtered_place_data.location.coordinates[0])
        if reverse_geocoded_json is not None:
            filtered_place_data.display_name = format_result(
                reverse_geocoded_json)
    except:
        logging.exception(
            "Unable to pre-fill reverse geocoded information, client has to do it"
        )

    curr_cleaned_end_place = ecwe.Entry.create_entry(raw_place.user_id,
                                                     esda.CLEANED_PLACE_KEY,
                                                     filtered_place_data,
                                                     create_id=True)
    return curr_cleaned_end_place
Beispiel #2
0
def _createTripEntry(self, start_ts, end_ts, start_loc, end_loc):
    t = ecwct.Cleanedtrip()
    sp = ecwcp.Cleanedplace()
    ep = ecwcp.Cleanedplace()

    t.start_ts = start_ts
    t.end_ts = end_ts

    if start_loc is not None:
        t.start_loc = gj.Point(start_loc)
        sp.location = t.start_loc

    if end_loc is not None:
        t.end_loc = gj.Point(end_loc)
        ep.location = t.end_loc

    sp.exit_ts = start_ts
    ep.enter_ts = end_ts

    spe = ecwe.Entry.create_entry(self.testUUID,
                                  "analysis/cleaned_place",
                                  sp,
                                  create_id=True)
    epe = ecwe.Entry.create_entry(self.testUUID,
                                  "analysis/cleaned_place",
                                  ep,
                                  create_id=True)
    t.start_place = spe.get_id()
    t.end_place = epe.get_id()
    te = ecwe.Entry.create_entry(self.testUUID,
                                 "analysis/cleaned_trip",
                                 t,
                                 create_id=True)
    self.ts.insert(spe)
    self.ts.insert(epe)
    self.ts.insert(te)
    return te