Пример #1
0
def get_nodes_and_edges_for_agentpolisdemo(
        json_dict) -> List[FeatureCollection]:
    """

    :param json_dict:
    :return: [edges,nodes] list
    """

    # graph = load_graph(json_dict)
    # biggest_subgraph = roadmaptools.sanitize.get_biggest_component(graph)
    # new_graph = traverse_and_create_graph(graph, biggest_subgraph)
    #
    # detect_parallel_edges(new_graph)
    # id_iter = find_max_id(json_dict) + 1  # new id iterator
    # for edge in temp_edges:
    #     add_new_edges(json_dict, edge, id_iter)
    #     id_iter += 2
    # json_dict['features'] = [i for i in json_dict["features"] if i]  # remove empty dicts
    # prepare_to_saving_optimized(new_graph, json_dict)
    # json_dict['features'].extend(temp_features)
    get_ids(json_dict)
    nodes = get_node_collection(json_dict)

    # gr = load_graph(json_dict) # remove duplicated edges
    # gr = create_DiGraph(gr)
    # prepare_to_saving_optimized(gr, json_dict)
    return [json_dict, nodes]
Пример #2
0
def prepare_graph_to_agentpolisdemo():
    json_dict = roadmaptools.inout.load_geojson(
        config.simplified_file_with_speed)
    graph = load_graph(json_dict)
    # biggest_subgraph = roadmaptools.sanitize.get_biggest_component(graph)
    # new_graph = traverse_and_create_graph(graph, biggest_subgraph)

    # detect_parallel_edges(new_graph)
    id_iter = find_max_id(json_dict) + 1  # new id iterator
    for edge in temp_edges:
        add_new_edges(json_dict, edge, id_iter)
        id_iter += 2
    json_dict['features'] = [i for i in json_dict["features"]
                             if i]  # remove empty dicts
    _prepare_to_saving_optimized(graph, json_dict)
    json_dict['features'].extend(temp_features)
    get_ids(json_dict)
    nodes = get_node_collection(json_dict)
    # print len(json_dict['features'])
    # output_stream = open("/home/martin/MOBILITY/GITHUB/smaz/agentpolis-demo/python_scripts/data/nodes.geojson",'w')
    roadmaptools.inout.save_geojson(nodes, config.ap_nodes_file)
    # output_stream.close()
    # for item in json_dict['features']:
    #     item['properties']['length']=1
    #     item['properties']['speed']=1
    # output_stream = open("/home/martin/MOBILITY/GITHUB/smaz/agentpolis-demo/python_scripts/data/edges.geojson",'w')
    roadmaptools.inout.save_geojson(json_dict, config.ap_edges_file)