+
+ if args.import_data:
+ LOG.warning('Import data')
+ if not args.osm_file:
+ raise UsageError('Missing required --osm-file argument')
+ database_import.import_osm_data(Path(args.osm_file),
+ args.osm2pgsql_options(0, 1),
+ drop=args.drop,
+ ignore_errors=args.ignore_errors)
+
+ if args.create_tables:
+ LOG.warning('Create Tables')
+ with connect(args.config.get_libpq_dsn()) as conn:
+ database_import.create_tables(conn, args.config, args.sqllib_dir, args.reverse_only)
+ refresh.load_address_levels_from_file(conn, Path(args.config.ADDRESS_LEVEL_CONFIG))
+ refresh.create_functions(conn, args.config, args.sqllib_dir,
+ enable_diff_updates=False)
+ database_import.create_table_triggers(conn, args.config, args.sqllib_dir)
+
+ if args.create_partition_tables:
+ LOG.warning('Create Partition Tables')
+ with connect(args.config.get_libpq_dsn()) as conn:
+ database_import.create_partition_tables(conn, args.config, args.sqllib_dir)
+
+ if args.load_data:
+ LOG.warning('Load data')
+ with connect(args.config.get_libpq_dsn()) as conn:
+ database_import.truncate_data_tables(conn, args.config.MAX_WORD_FREQUENCY)
+ database_import.load_data(args.config.get_libpq_dsn(),
+ args.data_dir,
+ args.threads or 1)
+
+ with connect(args.config.get_libpq_dsn()) as conn:
+ try:
+ status.set_status(conn, status.compute_database_date(conn))
+ except Exception as exc: # pylint: disable=broad-except
+ LOG.error('Cannot determine date of database: %s', exc)
+
+ if args.index:
+ LOG.warning('Indexing')
+ from ..indexer.indexer import Indexer
+ indexer = Indexer(args.config.get_libpq_dsn(), args.threads or 1)
+ indexer.index_full()
+
+ if args.create_search_indices:
+ LOG.warning('Create Search indices')
+ with connect(args.config.get_libpq_dsn()) as conn:
+ database_import.create_search_indices(conn, args.config, args.sqllib_dir, args.drop)
+
+ if args.tiger_data:
+ LOG.warning('Tiger data')
+ tiger_data.add_tiger_data(args.config.get_libpq_dsn(),
+ args.tiger_data,
+ args.threads or 1,
+ args.config,
+ args.sqllib_dir)
+
+ if args.create_country_names:
+ LOG.warning('Create search index for default country names.')
+ with connect(args.config.get_libpq_dsn()) as conn:
+ database_import.create_country_names(conn, args.config)