def __show_visit_heatmap(city_name: str, radius: float, user_id: str): checkin_point_layer = __get_checkin_layer("CPLH", city_name, radius, user_id) heatmap_layer = create_heatmap( checkin_point_layer, persistency_folder, "Heatmap of visits from {} in {}".format(user_id, city_name), QColor("green") ) add_layer_to_project(heatmap_layer)
def __show_order_of_visits(user_id: str, date: str): temp_filename = persistency_folder + "{}_{}_visit_order.csv".format( user_id, date) filter_and_group_calls(call_layer_filename, temp_filename, user_id, date) order_layer_name = "Order of visits for {} on {}".format(user_id, date) layer = create_vector_layer_from_csv(filename_to_uri(temp_filename), order_layer_name) set_font_symbology(layer, "index", 6, QColor("black")) add_layer_to_project(layer)
def __show_movement(user_id: str, date: str): csv_data = read_csv_file(call_layer_filename, delimiter=",") csv_data = filter_id_date(csv_data, user_id, date) geometry = create_line_geometry(csv_data) memory_line_layer = create_line_layer( geometry, "{} movement on {}".format(user_id, date)) persistent_line_layer = persistify_vector_layer(persistency_folder, memory_line_layer) set_linestring_arrow_symbology(persistent_line_layer) add_layer_to_project(persistent_line_layer)
def __show_heatmap(user_id: str, time_bracket: str, color: QColor): id_tb_filter = create_id_and_time_bracket_filter(user_id, time_bracket) temp_layer_name = "heatmap tmp layer {} {}".format(user_id, time_bracket) temp_layer = create_vector_layer_from_csv(call_layer_uri, temp_layer_name, id_tb_filter) heatmap_layer_name = "{} heatmap for {}".format(time_bracket.capitalize(), user_id) heatmap_layer = create_heatmap(temp_layer, persistency_folder, heatmap_layer_name, color) add_layer_to_project(heatmap_layer)
def __show_movement(user_id: str, date: str): point_selection_query = \ "SELECT the_geom FROM checkins WHERE user_id = '{}' AND timestamp::date = '{}' ORDER BY timestamp" point_selection_query = point_selection_query.format(user_id, date) ewkt_line_query = point_selection_to_ewkt_query(point_selection_query) ewkt = __execute_single_cell_result_query(lambda cursor: cursor.execute(ewkt_line_query)) geometry = create_line_geometry_postgis(ewkt) memory_line_layer = create_line_layer(geometry, "Movement of {} on {}".format(user_id, date)) persistent_line_layer = persistify_vector_layer(persistency_folder, memory_line_layer) set_linestring_arrow_symbology(persistent_line_layer) add_layer_to_project(persistent_line_layer)
def __load_outgoing_call_layer(user_id: str): uri_filter = create_id_and_direction_filter(user_id, "outgoing") outgoing_calls_layer = create_vector_layer_from_csv( call_layer_uri, "Calls from " + user_id, uri_filter) set_arrow_symbology(outgoing_calls_layer, "red", 0) add_layer_to_project(outgoing_calls_layer)
def __load_incoming_call_layer(user_id: str): uri_filter = create_id_and_direction_filter(user_id, "incoming") incoming_calls_layer = create_vector_layer_from_csv( call_layer_uri, "Calls to " + user_id, uri_filter) set_arrow_symbology(incoming_calls_layer, "green", 180) add_layer_to_project(incoming_calls_layer)
def __load_cell_tower_layer(): cell_tower_uri = filename_to_uri(cell_tower_filename) cell_tower_layer = create_vector_layer_from_csv(cell_tower_uri, "Porto Cell Towers") set_cross_symbol(cell_tower_layer, "black") add_layer_to_project(cell_tower_layer)
def __show_checkins(city: str, radius: float, user_id: str): checkin_point_layer = __get_checkin_layer("Check-Ins of {} in {}".format(user_id, city), city, radius, user_id) add_layer_to_project(checkin_point_layer)
def __show_pois(city_name: str, radius: float): origin = __get_geometry_from_city(city_name) uri = get_full_uri(__distance_where_clause(origin, radius), "pois") add_layer_to_project(layer_from_database_uri(uri, "POIs in {}".format(city_name)))