コード例 #1
0
ファイル: ways_exporter.py プロジェクト: aSpnt/rosavto
def main():
    #parse args
    parser = argparser_prepare()
    args = parser.parse_args()


    setup_logging(args.config_uri)
    getLogger('sqlalchemy.engine').setLevel(ERROR)
    settings = get_appsettings(args.config_uri)
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)

    log(INFO, "Export started...")
    if args.simple_roads:
        SimpleRoad.export_to_geojson_file(args.output_path)
    else:
        Way.export_to_geojson_file(args.output_path)

    if args.zip:
        log(INFO, "Zip file...")
        import zipfile
        zf = zipfile.ZipFile(args.output_path+'.zip', 'w',  zipfile.ZIP_DEFLATED, allowZip64=True)
        zf.write(args.output_path)
        zf.close()
        os.remove(args.output_path)

    log(INFO, "Export successful!")
コード例 #2
0
ファイル: initializedb.py プロジェクト: aSpnt/rosavto
def main(argv=sys.argv):
    if len(argv) != 2:
        usage(argv)
    config_uri = argv[1]
    setup_logging(config_uri)
    settings = get_appsettings(config_uri)
    engine = engine_from_config(settings, "sqlalchemy.")
    DBSession.configure(bind=engine)
    Base.metadata.drop_all(engine)
    Base.metadata.create_all(engine)
    with transaction.manager:
        GasStation.import_from_geojson_file("rosavto/initializedb/data/fuel.geojson")
        Bridge.import_from_geojson_file("rosavto/initializedb/data/bridges.geojson")
        # load ways for routing
        json_path = "rosavto/initializedb/data/ways.geojson"
        zf_path = "rosavto/initializedb/data/ways.geojson.zip"
        if os.path.isfile(zf_path):  # try open zip
            zf = zipfile.ZipFile(zf_path)
            zf.extractall(path="rosavto/initializedb/data/")
        Way.import_from_geojson_file(json_path)
        # load simple_roads
        json_path = "rosavto/initializedb/data/simple_roads.geojson"
        SimpleRoad.import_from_geojson_file(json_path)