Exemplo n.º 1
0
def make_stops(gps_coordinates: str, scenario: str) -> List[Dict]:

    result = []
    stations_list = []
    cities = []
    cities_list = []
    coords_list = cc.gps_list(gps_coordinates)

    with open("toolkit/visualization/stops/stations.wkt", 'r') as stations:
        stations = stations.readlines()
        stations = wkt.parse_wkt_stops(stations)

    if path.exists("data/" + scenario + "/cities.wkt"):
        with open("toolkit/visualization/stops/cities.wkt", 'r') as cities:
            cities = cities.readlines()
            cities = wkt.parse_wkt_stops(cities)

    for local, gps in coords_list:
        for station in stations:
            if local[0] == station[0] and local[1] == station[1]:
                stations_list.append(gps)
        for city in cities:
            if local[0] == city[0] and local[1] == city[1]:
                cities_list.append(gps)

    result = build_list(stations_list, [0, 255, 255], result)
    result = build_list(cities_list, [255, 0, 0], result)

    return result
Exemplo n.º 2
0
def make_stops(gps_coordinates: str) -> None:

    result = []
    stations_list = []
    cities = []
    cities_list = []
    coords_list = cc.gps_list(gps_coordinates)

    with open("stations.wkt", 'r') as stations:
        stations = stations.readlines()
        stations = wkt.parse_wkt_stops(stations)

    if path.exists("cities.wkt"):
        with open("cities.wkt", 'r') as cities:
            cities = cities.readlines()
            cities = wkt.parse_wkt_stops(cities)

    for local, gps in coords_list:
        for station in stations:
            if local[0] == station[0] and local[1] == station[1]:
                stations_list.append(gps)
        for city in cities:
            if local[0] == city[0] and local[1] == city[1]:
                cities_list.append(gps)

    result = build_list(stations_list, [0, 255, 255], result)
    result = build_list(cities_list, [255, 0, 0], result)

    stops_json = json.dumps(result, indent=2)

    with open("stops.json", "w") as file:
        file.write(stops_json)
Exemplo n.º 3
0
def message_json(local_coordinates: str, gps_coordinates: str):

    message_timestamps = parse_timestamps(local_coordinates)
    message_gps = cc.gps_list(gps_coordinates)
    message_final_coords = combine_lists(message_timestamps, message_gps)

    dict_list = [single_dictionary(entry) for entry in message_final_coords]

    json_file = json.dumps(dict_list, indent=2)

    with open("messages.json", "w") as file:
        file.write(json_file)
Exemplo n.º 4
0
def make_arrivals(local_coordinates: str, gps_coordinates: str) -> None:

    arrivals_timestamps = timestamps_list(local_coordinates)
    arrivals_gps = cc.gps_list(gps_coordinates)
    arrivals_final_coords = final_list(arrivals_timestamps, arrivals_gps)

    dict_list = [single_dictionary(entry) for entry in arrivals_final_coords]

    json_file = json.dumps(dict_list, indent=2)

    with open("arrivals.json", "w") as file:
        file.write(json_file)
Exemplo n.º 5
0
def make_routes(gps_coords: str) -> Union[list, List[Dict]]:
    route_list = []
    coords = cc.gps_list(gps_coords)

    for filename in os.listdir("toolkit/visualization/routes"):
        if filename != ".DS_Store":
            with open("toolkit/visualization/routes/" + filename, 'r') as f:
                nodes = f.read()
                nodes_list = wkt.parse_wkt_route(nodes, coords)
                # color = make_color()
                color = [255, 0, 0]

            route = filename.split('_')
            route = route[0]
            route_list = build_route_list(route, color, nodes_list, route_list)

    return route_list
Exemplo n.º 6
0
def message_json(local_coordinates: str, gps_coordinates: str):
    dict_list = []

    message_timestamps = parse_timestamps(local_coordinates)
    message_gps = cc.gps_list(gps_coordinates)
    message_final_coords = combine_lists(message_timestamps, message_gps)

    for gps, timestamp, action in message_final_coords:
        new_dict = {}
        new_dict["coordinates"] = gps
        new_dict["timestamp"] = timestamp
        new_dict["notification"] = action

        dict_list.append(new_dict)

    json_file = json.dumps(dict_list, indent=2)

    with open("messages.json", "w") as file:
        file.write(json_file)
Exemplo n.º 7
0
def make_routes(gps_coords) -> None:
    route_list = []
    coords = cc.gps_list(gps_coords)

    for filename in os.listdir("routes"):
        if filename != ".DS_Store":
            with open("routes/" + filename, 'r') as f:
                nodes = f.read()
                nodes_list = wkt.parse_wkt_route(nodes, coords)
                # color = make_color()
                color = [255, 0, 0]

            route = filename.split('_')
            route = route[0]
            route_list = build_route_list(route, color, nodes_list, route_list)

    routes_json = json.dumps(route_list, indent=2)

    with open("routes.json", "w") as file:
        file.write(routes_json)
Exemplo n.º 8
0
def carried_messages(local_coordinates: str, gps_coordinates: str):
    dict_list = []

    carried_timestamps = cc.timestamps_list(local_coordinates)
    carried_gps = cc.gps_list(gps_coordinates)
    carried_final_coords = cc.final_list(carried_timestamps, carried_gps)

    for name, gps, timestamp, messages in carried_final_coords:
        new_dict = {}
        new_dict["name"] = name
        new_dict["coordinates"] = gps
        new_dict["timestamp"] = timestamp
        new_dict["messages"] = str(messages)

        dict_list.append(new_dict)

    json_file = json.dumps(dict_list, indent=2)

    with open("carried_messages.json", "w") as file:
        file.write(json_file)
Exemplo n.º 9
0
def make_arrivals(local_coordinates: str, gps_coordinates: str):
    dict_list = []

    arrivals_timestamps = cc.timestamps_list(local_coordinates)
    arrivals_gps = cc.gps_list(gps_coordinates)
    arrivals_final_coords = cc.final_list(arrivals_timestamps, arrivals_gps)

    for name, gps, timestamp, messages in arrivals_final_coords:
        new_dict = {}
        new_dict["name"] = name
        new_dict["coordinates"] = gps
        new_dict["timestamp"] = timestamp
        new_dict["color"] = [253, 128, 93]

        dict_list.append(new_dict)

    json_file = json.dumps(dict_list, indent=2)

    with open("arrivals.json", "w") as file:
        file.write(json_file)