예제 #1
0
def main():
    from optparse import OptionParser
    usage = """usage: python gtfToVisum.py config_file gtfs_feed"""
    parser = OptionParser(usage=usage)
    (options, args) = parser.parse_args()

    if len(args) != 2 or not os.path.exists(args[0]) or not os.path.exists(args[1]):
        parser.print_help()
        exit(-1)


    defaults = { 'psql-host':'localhost',
                 'psql-port':'5432',
                 'psql-user':'******',
                 'psql-password':'',
                 'psql-database':'graphserver',
                 'date':'2011.01.01' }

    config = utils.read_config(args[0], defaults, True)

    psql_connect_string = 'dbname=%s user=%s password=%s host=%s port=%s' % ( config['psql-database'],
                                                                              config['psql-user'],
                                                                              config['psql-password'],
                                                                              config['psql-host'],
                                                                              config['psql-port']
                                                                            )
    feed = args[1]

    transformer = GtfsToVisum(psql_connect_string, recreate_tables=False)
    transformer.feed = feed
    transformer.date = config['date'].replace('.','')

    transformer.transform()

    print 'done'
예제 #2
0
def read_config(file_path):

    defaults = { 'time-step':'240',
                 'max-walk':'11080',
                 'walking-reluctance':'20',
                 'walking-speed':'1.2',
                 'parallel-calculations': '4',
                 'psql-host':'localhost',
                 'psql-port':'5432',
                 'psql-user':'******',
                 'psql-password':'',
                 'psql-database':'graphserver',
                 'routes':'routes.csv',
                 'times':'times.csv',
                 'points':'points.csv',
                 'transit-feed':'transit_data.zip',
                 'osm-data':'streets.osm',
                 'results':'results.csv',
                 'result-details':'result-details.csv' }

    if not os.path.exists(file_path): raise Exception()

    config = utils.read_config(file_path, defaults, True)

    psql_connect_string = 'dbname=%s user=%s password=%s host=%s port=%s' % ( config['psql-database'],
                                                                              config['psql-user'],
                                                                              config['psql-password'],
                                                                              config['psql-host'],
                                                                              config['psql-port']       )

    config['routes'] = os.path.join(os.path.dirname(file_path), config['routes'])
    config['times'] = os.path.join(os.path.dirname(file_path), config['times'])
    config['points'] = os.path.join(os.path.dirname(file_path), config['points'])

    config['transit-feed'] = os.path.join(os.path.dirname(file_path), config['transit-feed'])
    config['osm-data'] = os.path.join(os.path.dirname(file_path), config['osm-data'])

    config['results'] = os.path.join(os.path.dirname(file_path), config['results'])
    config['result-details'] = os.path.join(os.path.dirname(file_path), config['result-details'])


    if DEBUG: print(config)

    return config, psql_connect_string
예제 #3
0
def main():
    from optparse import OptionParser
    usage = """usage: python ivuToVisum.py [options] config_file ivu_folder"""
    parser = OptionParser(usage=usage)

    parser.add_option("-e", "--export-only", action="store_true", help="converts the data in the database into the visum format (NO READING OF IVU DATA)", dest="export_only", default=False)
    parser.add_option("-i", "--import-only", action="store_true", help="imports the ivu data into the database (NO CONVERSION INTO VISUM DATA)", dest="import_only", default=False)

    (options, args) = parser.parse_args()

    if len(args) != 2 or not os.path.exists(args[0]) or not os.path.exists(args[1]) or (options.import_only and options.export_only):
        parser.print_help()
        exit(-1)


    defaults = { 'psql-host':'localhost',
                 'psql-port':'5432',
                 'psql-user':'******',
                 'psql-password':'',
                 'psql-database':'graphserver',
                 'date':'2011.01.01' }

    config = utils.read_config(args[0], defaults, True)

    psql_connect_string = 'dbname=%s user=%s password=%s host=%s port=%s' % ( config['psql-database'],
                                                                              config['psql-user'],
                                                                              config['psql-password'],
                                                                              config['psql-host'],
                                                                              config['psql-port']       )

    ivu_folder = args[1]

    read_ivu_data = not options.export_only

    transformer = IvuToVisum(psql_connect_string, recreate_tables=False, read_ivu_data=read_ivu_data)
    transformer.ivu_data = ivu_folder
    transformer.date = datetime.date(int(config['date'][:4]), int(config['date'][5:7]), int(config['date'][8:]))

    if not options.import_only:
        print 'converting data'
        transformer.transform()

    print 'done'