2 Implementation of the 'add-data' subcommand.
6 # Do not repeat documentation of subcommand classes.
7 # pylint: disable=C0111
8 # Using non-top-level imports to avoid eventually unused imports.
9 # pylint: disable=E0012,C0415
11 LOG = logging.getLogger()
15 Add additional data from a file or an online source.
17 This command allows to add or update the search data in the database.
18 The data can come either from an OSM file or single OSM objects can
19 directly be downloaded from the OSM API. This function only loads the
20 data into the database. Afterwards it still needs to be integrated
21 in the search index. Use the `nominatim index` command for that.
23 The command can also be used to add external non-OSM data to the
24 database. At the moment the only supported format is TIGER housenumber
25 data. See the online documentation at
26 https://nominatim.org/release-docs/latest/admin/Import/#installing-tiger-housenumber-data-for-the-us
32 group_name = parser.add_argument_group('Source')
33 group = group_name.add_mutually_exclusive_group(required=True)
34 group.add_argument('--file', metavar='FILE',
35 help='Import data from an OSM file or diff file')
36 group.add_argument('--diff', metavar='FILE',
37 help='Import data from an OSM diff file (deprecated: use --file)')
38 group.add_argument('--node', metavar='ID', type=int,
39 help='Import a single node from the API')
40 group.add_argument('--way', metavar='ID', type=int,
41 help='Import a single way from the API')
42 group.add_argument('--relation', metavar='ID', type=int,
43 help='Import a single relation from the API')
44 group.add_argument('--tiger-data', metavar='DIR',
45 help='Add housenumbers from the US TIGER census database')
46 group = parser.add_argument_group('Extra arguments')
47 group.add_argument('--use-main-api', action='store_true',
48 help='Use OSM API instead of Overpass to download objects')
49 group.add_argument('--osm2pgsql-cache', metavar='SIZE', type=int,
50 help='Size of cache to be used by osm2pgsql (in MB)')
51 group.add_argument('--socket-timeout', dest='socket_timeout', type=int, default=60,
52 help='Set timeout for file downloads')
56 from nominatim.tokenizer import factory as tokenizer_factory
57 from nominatim.tools import tiger_data, add_osm_data
60 tokenizer = tokenizer_factory.get_tokenizer_for_db(args.config)
61 return tiger_data.add_tiger_data(args.tiger_data,
62 args.config, args.threads or 1,
65 osm2pgsql_params = args.osm2pgsql_options(default_cache=1000, default_threads=1)
66 if args.file or args.diff:
67 return add_osm_data.add_data_from_file(args.file or args.diff,
71 return add_osm_data.add_osm_object('node', args.node,
76 return add_osm_data.add_osm_object('way', args.way,
81 return add_osm_data.add_osm_object('relation', args.relation,