]> git.openstreetmap.org Git - nominatim.git/commitdiff
Merge remote-tracking branch 'upstream/master'
authorSarah Hoffmann <lonvia@denofr.de>
Thu, 19 May 2022 08:37:59 +0000 (10:37 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Thu, 19 May 2022 08:37:59 +0000 (10:37 +0200)
nominatim/clicmd/setup.py
settings/address-levels.json
test/bdd/steps/nominatim_environment.py
test/bdd/steps/steps_db_ops.py

index b643c5baa4cf3a439740944eb1b9f45d17b5165f..7b5f379739e5f7269975970d05ef182cee403b4b 100644 (file)
@@ -53,6 +53,8 @@ class SetupAll:
         group.add_argument('--no-updates', action='store_true',
                            help="Do not keep tables that are only needed for "
                                 "updating the database later")
+        group.add_argument('--offline', action='store_true',
+                           help="Do not attempt to load any additional data from the internet")
         group = parser.add_argument_group('Expert options')
         group.add_argument('--ignore-errors', action='store_true',
                            help='Continue import even when errors in SQL are present')
@@ -139,7 +141,7 @@ class SetupAll:
         with connect(args.config.get_libpq_dsn()) as conn:
             refresh.setup_website(webdir, args.config, conn)
 
-        SetupAll._set_database_date(args.config.get_libpq_dsn())
+        SetupAll._finalize_database(args.config.get_libpq_dsn(), args.offline)
 
         return 0
 
@@ -202,15 +204,16 @@ class SetupAll:
 
 
     @staticmethod
-    def _set_database_date(dsn):
+    def _finalize_database(dsn, offline):
         """ Determine the database date and set the status accordingly.
         """
         with connect(dsn) as conn:
-            try:
-                dbdate = status.compute_database_date(conn)
-                status.set_status(conn, dbdate)
-                LOG.info('Database is at %s.', dbdate)
-            except Exception as exc: # pylint: disable=broad-except
-                LOG.error('Cannot determine date of database: %s', exc)
+            if not offline:
+                try:
+                    dbdate = status.compute_database_date(conn)
+                    status.set_status(conn, dbdate)
+                    LOG.info('Database is at %s.', dbdate)
+                except Exception as exc: # pylint: disable=broad-except
+                    LOG.error('Cannot determine date of database: %s', exc)
 
             properties.set_property(conn, 'database_version', version_str())
index 67bca991929d6e1974e52d98994f414b685b1651..b63eac4efa065de8c3782cd1d75658af0197283c 100644 (file)
       }
   }
 },
+{ "countries" : [ "ca" ],
+  "tags" : {
+      "place" : {
+          "county" : [12, 0]
+      }
+  }
+},
 { "countries" : [ "de" ],
   "tags" : {
       "place" : {
index 70a03e6ec31e37a148f1ea0255c3b283913704b5..6b83c2e4e8a25d6cb9bbf9b7eb002875a66eb2a4 100644 (file)
@@ -95,6 +95,7 @@ class NominatimEnvironment:
 
         self.test_env = dict(self.default_config)
         self.test_env['NOMINATIM_DATABASE_DSN'] = dsn
+        self.test_env['NOMINATIM_LANGUAGES'] = 'en,de,fr,ja'
         self.test_env['NOMINATIM_FLATNODE_FILE'] = ''
         self.test_env['NOMINATIM_IMPORT_STYLE'] = 'full'
         self.test_env['NOMINATIM_USE_US_TIGER_DATA'] = 'yes'
@@ -172,22 +173,23 @@ class NominatimEnvironment:
 
         self.template_db_done = True
 
-        if self._reuse_or_drop_db(self.template_db):
-            return
-
         self.write_nominatim_config(self.template_db)
 
-        try:
-            # execute nominatim import on an empty file to get the right tables
-            with tempfile.NamedTemporaryFile(dir='/tmp', suffix='.xml') as fd:
-                fd.write(b'<osm version="0.6"></osm>')
-                fd.flush()
-                self.run_nominatim('import', '--osm-file', fd.name,
-                                             '--osm2pgsql-cache', '1',
-                                             '--ignore-errors')
-        except:
-            self.db_drop_database(self.template_db)
-            raise
+        if not self._reuse_or_drop_db(self.template_db):
+            try:
+                # execute nominatim import on an empty file to get the right tables
+                with tempfile.NamedTemporaryFile(dir='/tmp', suffix='.xml') as fd:
+                    fd.write(b'<osm version="0.6"></osm>')
+                    fd.flush()
+                    self.run_nominatim('import', '--osm-file', fd.name,
+                                                 '--osm2pgsql-cache', '1',
+                                                 '--ignore-errors',
+                                                 '--offline', '--index-noanalyse')
+            except:
+                self.db_drop_database(self.template_db)
+                raise
+
+        self.run_nominatim('refresh', '--functions')
 
 
     def setup_api_db(self):
index 4c711b725b34588599fa01fe27cbbf16698fde6a..63c5120e88a894c99970a218a7b864fe48f1055d 100644 (file)
@@ -93,9 +93,9 @@ def add_data_to_planet_ways(context):
 def import_and_index_data_from_place_table(context):
     """ Import data previously set up in the place table.
     """
-    context.nominatim.run_nominatim('refresh', '--functions')
     context.nominatim.run_nominatim('import', '--continue', 'load-data',
-                                              '--index-noanalyse', '-q')
+                                              '--index-noanalyse', '-q',
+                                              '--offline')
 
     check_database_integrity(context)