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)
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)
import osm2gmns as og import os map_folder = r'..\maps\asu' net = og.getNetFromOSMFile(os.path.join(map_folder, 'asu.osm'), network_type=('auto', 'railway', 'aeroway'), POIs=True, default_lanes=True, default_speed=True) og.connectPOIWithNet(net) og.outputNetToCSV(net, output_folder=map_folder)