]> git.openstreetmap.org Git - nominatim.git/commitdiff
Merge pull request #2228 from AntoJvlt/import-special-phrases-porting-python
authorSarah Hoffmann <lonvia@denofr.de>
Mon, 29 Mar 2021 07:49:35 +0000 (09:49 +0200)
committerGitHub <noreply@github.com>
Mon, 29 Mar 2021 07:49:35 +0000 (09:49 +0200)
Import special phrases porting python

lib-sql/indices.sql
lib-sql/tables.sql
nominatim/clicmd/api.py
nominatim/indexer/progress.py
test/bdd/steps/steps_db_ops.py

index cb77e02b60b8ca0c9525e0af3ae6327888955543..f8c9d2ce86511ef993231507883aa64998ef2eee 100644 (file)
@@ -35,9 +35,6 @@ CREATE INDEX {{sql.if_index_not_exists}} idx_osmline_parent_place_id
 CREATE INDEX {{sql.if_index_not_exists}} idx_osmline_parent_osm_id
   ON location_property_osmline USING BTREE (osm_id) {{db.tablespace.search_index}};
 
-CREATE UNIQUE INDEX {{sql.if_index_not_exists}} idx_postcode_id
-  ON location_postcode USING BTREE (place_id) {{db.tablespace.search_index}};
-
 CREATE INDEX {{sql.if_index_not_exists}} idx_postcode_postcode
   ON location_postcode USING BTREE (postcode) {{db.tablespace.search_index}};
 
index 0895c6dd3b83b812fb0575384c2ea85ff5f47f4e..329eb7a1ab9491f8fb063b92747dd0abfcf9c2d2 100644 (file)
@@ -209,6 +209,7 @@ CREATE TABLE location_postcode (
   postcode TEXT,
   geometry GEOMETRY(Geometry, 4326)
   );
+CREATE UNIQUE INDEX idx_postcode_id ON location_postcode USING BTREE (place_id) {{db.tablespace.search_index}};
 CREATE INDEX idx_postcode_geometry ON location_postcode USING GIST (geometry) {{db.tablespace.address_index}};
 GRANT SELECT ON location_postcode TO "{{config.DATABASE_WEBUSER}}" ;
 
index e50c00dc7f6b836d32cb8e1e0cbf15daa31c488e..7185d97c14bf659f406e56d6c1b10e916467a278 100644 (file)
@@ -154,7 +154,7 @@ class APIReverse:
 
 class APILookup:
     """\
-    Execute API reverse query.
+    Execute API lookup query.
     """
 
     @staticmethod
@@ -189,7 +189,7 @@ class APILookup:
 
 class APIDetails:
     """\
-    Execute API lookup query.
+    Execute API details query.
     """
 
     @staticmethod
index c9d8816be989fb99675341a512c6806efcf06465..177e67b812aef0ea05116928c214ed5434f5a622 100644 (file)
@@ -57,8 +57,14 @@ class ProgressLogger:
         """ Print final statistics about the progress.
         """
         rank_end_time = datetime.now()
-        diff_seconds = (rank_end_time-self.rank_start_time).total_seconds()
+
+        if rank_end_time == self.rank_start_time:
+            diff_seconds = 0
+            places_per_sec = self.done_places
+        else:
+            diff_seconds = (rank_end_time - self.rank_start_time).total_seconds()
+            places_per_sec = self.done_places/diff_seconds
 
         LOG.warning("Done %d/%d in %d @ %.3f per second - FINISHED %s\n",
                     self.done_places, self.total_places, int(diff_seconds),
-                    self.done_places/diff_seconds, self.name)
+                    places_per_sec, self.name)
index 465eed6589f013b523a043fa71949b40f6db2837..72a610eb123733db313ee74d510b633afdac5fb3 100644 (file)
@@ -1,3 +1,4 @@
+import logging
 from itertools import chain
 
 import psycopg2.extras
@@ -5,7 +6,7 @@ import psycopg2.extras
 from place_inserter import PlaceColumn
 from table_compare import NominatimID, DBRow
 
-from nominatim.indexer.indexer import Indexer
+from nominatim.indexer import indexer
 
 def check_database_integrity(context):
     """ Check some generic constraints on the tables.
@@ -103,8 +104,8 @@ def import_and_index_data_from_place_table(context):
              GROUP BY country_code, pc""")
 
     # Call directly as the refresh function does not include postcodes.
-    indexer = Indexer(context.nominatim.get_libpq_dsn(), 1)
-    indexer.index_full(analyse=False)
+    indexer.LOG.setLevel(logging.ERROR)
+    indexer.Indexer(context.nominatim.get_libpq_dsn(), 1).index_full(analyse=False)
 
     check_database_integrity(context)