Exemple #1
0
def osm_2_gmns():
    import osm2gmns as og
    net = og.getNetFromOSMFile('map.osm', default_lanes=True, POIs=True)
    og.connectPOIWithNet(net)
    og.generateNodeActivityInfo(net)
    og.consolidateComplexIntersections(net)
    og.outputNetToCSV(net, output_folder='consolidated')
    og.generateMovements(net)
    og.outputNetToCSV(net)
    og.show(net)
Exemple #2
0
def getInitialNet():
    # choose link_types from 'motorway', 'trunk','primary','secondary', 'tertiary', 'residential'. default: 'all'
    net = og.getNetFromFile(filename=os.path.join(map_folder, 'map.osm'),
                            link_types=('motorway', 'trunk', 'primary',
                                        'secondary', 'tertiary'),
                            default_lanes=True,
                            default_speed=True,
                            default_capacity=True)

    og.consolidateComplexIntersections(net, auto_identify=True)
    og.generateNodeActivityInfo(net)
    og.buildMultiResolutionNets(net)

    og.outputNetToCSV(net, output_folder=map_folder)
Exemple #3
0
def mapmatch(tmc_path, osm_path):
    "Get the OSM Network"
    import osm2gmns as og
    files = os.listdir(osm_path)
    for file in files:
        if file[-3:] == 'osm':
            net = og.getNetFromOSMFile(osm_path + os.sep + file,
                                       network_type=('auto'),
                                       default_lanes=True,
                                       default_speed=True)
            og.consolidateComplexIntersections(net)
            og.outputNetToCSV(net, output_folder=osm_path)
        break

    create_folder(
        os.path.join(os.path.dirname(os.path.realpath('__file__')),
                     'data/testdata'))  #to local

    import shutil
    source_link_osm = os.path.join(
        os.path.join(os.path.dirname(os.path.realpath('__file__')), osm_path),
        'link.csv')
    source_node_osm = os.path.join(
        os.path.join(os.path.dirname(os.path.realpath('__file__')), osm_path),
        'node.csv')
    source_trace = os.path.join(
        os.path.join(os.path.dirname(os.path.realpath('__file__')), tmc_path),
        'trace.csv')
    source_list = [source_link_osm, source_node_osm, source_trace]

    destination_1 = os.path.join(os.path.dirname(os.path.realpath('__file__')),
                                 'data/testdata')
    destination_2 = os.path.dirname(os.path.realpath('__file__'))
    destination_list = [destination_1, destination_2]

    for i in range(len(source_list)):
        for j in range(len(destination_list)):
            shutil.copy(source_list[i], destination_list[j])

    MapMatching4GMNS.map_match()
    print("Map matching is completed!")
Exemple #4
0
def main():
    parser = argparse.ArgumentParser()
    # Input and output paths must be absolute
    parser.add_argument('--input_osm', type=str, required=True)
    parser.add_argument('--output_csv', type=str, required=True)
    parser.add_argument('--latitude', type=float, required=True)
    parser.add_argument('--x_blocks', type=int, required=True)
    parser.add_argument('--y_blocks', type=int, required=True)
    args = parser.parse_args()

    # Both libraries write lots of files to the current directory, so isolate them
    with tempfile.TemporaryDirectory() as tmpdir:
        os.chdir(tmpdir)

        net = osm2gmns.getNetFromFile(args.input_osm, POIs=True)
        osm2gmns.connectPOIWithNet(net)
        osm2gmns.generateNodeActivityInfo(net)
        osm2gmns.consolidateComplexIntersections(net)
        # grid2demand.ReadNetworkFiles just assumes the current directory has the
        # network CSV files; there's no way to pass in the network we already have.
        osm2gmns.outputNetToCSV(net)

        grid2demand.ReadNetworkFiles()
        zone = grid2demand.PartitionGrid(number_of_x_blocks=args.x_blocks,
                                         number_of_y_blocks=args.y_blocks,
                                         latitude=args.latitude)
        triprate = grid2demand.GetPoiTripRate()
        nodedemand = grid2demand.GetNodeDemand()
        accessibility = grid2demand.ProduceAccessMatrix(latitude=args.latitude)
        demand = grid2demand.RunGravityModel(trip_purpose=1,
                                             a=None,
                                             b=None,
                                             c=None)
        # This writes more csv files, including input_agent.csv
        demand = grid2demand.GenerateAgentBasedDemand()

        os.rename('input_agent.csv', args.output_csv)
Exemple #5
0
# -*- coding:utf-8 -*-
import osm2gmns as og
"""
Step 1: get network from .osm file
Step 2: consolidate complex intersections based on automatically identified complex intersection information
Step 3: output the network with intersections consolidated
"""
# net = og.getNetFromOSMFile('map.osm', strict_mode=True, remove_isolated=True, simplify=True, int_buffer=18.0)
# og.consolidateComplexIntersections(net)
# og.outputNetToCSV(net)
"""
Step 1: get network from .osm file
Step 2: output the network to CSV files
Step 3: modify complex intersection information manually according to the network topology
Step 4: load network from CSV files
Step 5: consolidate complex intersections based on the modified complex intersection information
Step 6: output the network with intersections consolidated
"""

net = og.getNetFromOSMFile('map.osm',
                           network_type=('auto'),
                           default_lanes=True,
                           default_speed=True)
og.outputNetToCSV(net)

net = og.getNetFromCSV()
og.consolidateComplexIntersections(net)
og.generateMovements(net)
og.outputNetToCSV(net)