]> git.openstreetmap.org Git - nominatim.git/commitdiff
Merge pull request #2166 from mtmail/tiger-2020
authorSarah Hoffmann <lonvia@denofr.de>
Tue, 16 Feb 2021 13:45:14 +0000 (14:45 +0100)
committerGitHub <noreply@github.com>
Tue, 16 Feb 2021 13:45:14 +0000 (14:45 +0100)
documentation: 2020 TIGER data got released

CMakeLists.txt
nominatim/db/status.py
nominatim/tools/replication.py
test/python/test_db_status.py
vagrant/Install-on-Centos-7.sh
vagrant/Install-on-Centos-8.sh
vagrant/Install-on-Ubuntu-18.sh
vagrant/Install-on-Ubuntu-20.sh [changed mode: 0644->0755]

index 691c9adcaafad309533699558a0d7dc33af85b25..5f8e4611689c003bc9e7221005be9bfbf4d99a4c 100644 (file)
@@ -6,7 +6,7 @@
 #
 #-----------------------------------------------------------------------------
 
-cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
+cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
 list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
 
 
@@ -238,7 +238,14 @@ if (BUILD_IMPORTER)
 endif()
 
 if (BUILD_OSM2PGSQL)
-    install(TARGETS osm2pgsql RUNTIME DESTINATION ${NOMINATIM_LIBDIR})
+    if (${CMAKE_VERSION} VERSION_LESS 3.13)
+        # Installation of subdirectory targets was only introduced in 3.13.
+        # So just copy the osm2pgsql file for older versions.
+        install(PROGRAMS ${PROJECT_BINARY_DIR}/osm2pgsql/osm2pgsql
+                DESTINATION ${NOMINATIM_LIBDIR})
+    else()
+        install(TARGETS osm2pgsql RUNTIME DESTINATION ${NOMINATIM_LIBDIR})
+    endif()
 endif()
 
 if (BUILD_MODULE)
index 75da3c166029fa8cc4266b9a76aed5fe97b7dcdc..225638f4bef3979f4f0b1fec501b90c120b57bfe 100644 (file)
@@ -40,13 +40,19 @@ def compute_database_date(conn):
 
 
 def set_status(conn, date, seq=None, indexed=True):
-    """ Replace the current status with the given status.
+    """ Replace the current status with the given status. If date is `None`
+        then only sequence and indexed will be updated as given. Otherwise
+        the whole status is replaced.
     """
-    assert date.tzinfo == dt.timezone.utc
+    assert date is None or date.tzinfo == dt.timezone.utc
     with conn.cursor() as cur:
-        cur.execute("TRUNCATE TABLE import_status")
-        cur.execute("""INSERT INTO import_status (lastimportdate, sequence_id, indexed)
-                       VALUES (%s, %s, %s)""", (date, seq, indexed))
+        if date is None:
+            cur.execute("UPDATE import_status set sequence_id = %s, indexed = %s",
+                        (seq, indexed))
+        else:
+            cur.execute("TRUNCATE TABLE import_status")
+            cur.execute("""INSERT INTO import_status (lastimportdate, sequence_id, indexed)
+                           VALUES (%s, %s, %s)""", (date, seq, indexed))
 
     conn.commit()
 
index cb201b1ef965a5d3801f4132da6f41570720ea75..a3ef84fef7214c7e865d4e9b6af539bc7e5d9f6e 100644 (file)
@@ -119,6 +119,7 @@ def update(conn, options):
 
     # Write the current status to the file
     endstate = repl.get_state_info(endseq)
-    status.set_status(conn, endstate.timestamp, seq=endseq, indexed=False)
+    status.set_status(conn, endstate.timestamp if endstate else None,
+                      seq=endseq, indexed=False)
 
     return UpdateState.UP_TO_DATE
index 399a0036ba96186597deb1038dd14f9e60da0082..c659147148d4b2d970a5008e984e8fce02cc7242 100644 (file)
@@ -65,7 +65,6 @@ def test_set_status_filled_table(status_table, temp_db_conn, temp_db_cursor):
 
     assert 1 == temp_db_cursor.scalar("SELECT count(*) FROM import_status")
 
-
     date = dt.datetime.fromordinal(1000100).replace(tzinfo=dt.timezone.utc)
     nominatim.db.status.set_status(temp_db_conn, date=date, seq=456, indexed=False)
 
@@ -75,6 +74,20 @@ def test_set_status_filled_table(status_table, temp_db_conn, temp_db_cursor):
     assert temp_db_cursor.fetchone() == [date, 456, False]
 
 
+def test_set_status_missing_date(status_table, temp_db_conn, temp_db_cursor):
+    date = dt.datetime.fromordinal(1000000).replace(tzinfo=dt.timezone.utc)
+    nominatim.db.status.set_status(temp_db_conn, date=date)
+
+    assert 1 == temp_db_cursor.scalar("SELECT count(*) FROM import_status")
+
+    nominatim.db.status.set_status(temp_db_conn, date=None, seq=456, indexed=False)
+
+    temp_db_cursor.execute("SELECT * FROM import_status")
+
+    assert temp_db_cursor.rowcount == 1
+    assert temp_db_cursor.fetchone() == [date, 456, False]
+
+
 def test_get_status_empty_table(status_table, temp_db_conn):
     assert nominatim.db.status.get_status(temp_db_conn) == (None, None, None)
 
index 009152727e3cb7b9150865778ad4023030ddbf5e..eb16f87398d5995a17ce5e801f001781e7122299 100755 (executable)
@@ -106,36 +106,6 @@ sudo chown vagrant /srv/nominatim  #DOCS:
     sudo -u postgres createuser -s $USERNAME
     sudo -u postgres createuser apache
 
-#
-# Setting up the Apache Webserver
-# -------------------------------
-#
-# You need to create an alias to the website directory in your apache
-# configuration. Add a separate nominatim configuration to your webserver:
-
-#DOCS:```sh
-sudo tee /etc/httpd/conf.d/nominatim.conf << EOFAPACHECONF
-<Directory "$USERHOME/build/website">
-  Options FollowSymLinks MultiViews
-  AddType text/html   .php
-  DirectoryIndex search.php
-  Require all granted
-</Directory>
-
-Alias /nominatim $USERHOME/build/website
-EOFAPACHECONF
-#DOCS:```
-
-sudo sed -i 's:#.*::' /etc/httpd/conf.d/nominatim.conf #DOCS:
-
-#
-# Then reload apache
-#
-
-    sudo systemctl enable httpd
-    sudo systemctl restart httpd
-
-
 #
 # Installing Nominatim
 # ====================
@@ -164,11 +134,48 @@ fi                                 #DOCS:
 # then configure and build Nominatim in there:
 
 #DOCS:    :::sh
-    cd $USERHOME
-    mkdir build
-    cd build
+    mkdir $USERHOME/build
+    cd $USERHOME/build
     cmake $USERHOME/Nominatim
     make
+    sudo make install
+
+#
+# Setting up the Apache Webserver
+# -------------------------------
+#
+# The webserver should serve the php scripts from the website directory of your
+# [project directory](../admin/import.md#creating-the-project-directory).
+# Therefore set up a project directory and populate the website directory:
+#
+    mkdir $USERHOME/nominatim-project
+    cd $USERHOME/nominatim-project
+    nominatim refresh --website
+#
+# You need to create an alias to the website directory in your apache
+# configuration. Add a separate nominatim configuration to your webserver:
+
+#DOCS:```sh
+sudo tee /etc/httpd/conf.d/nominatim.conf << EOFAPACHECONF
+<Directory "$USERHOME/nominatim-project/website">
+  Options FollowSymLinks MultiViews
+  AddType text/html   .php
+  DirectoryIndex search.php
+  Require all granted
+</Directory>
+
+Alias /nominatim $USERHOME/nominatim-project/website
+EOFAPACHECONF
+#DOCS:```
+
+sudo sed -i 's:#.*::' /etc/httpd/conf.d/nominatim.conf #DOCS:
+
+#
+# Then reload apache
+#
+
+    sudo systemctl enable httpd
+    sudo systemctl restart httpd
 
 #
 # Adding SELinux Security Settings
@@ -178,11 +185,11 @@ fi                                 #DOCS:
 # with a web server accessible from the Internet. At a minimum the
 # following SELinux labeling should be done for Nominatim:
 
-    sudo semanage fcontext -a -t httpd_sys_content_t "$USERHOME/Nominatim/(website|lib|settings)(/.*)?"
-    sudo semanage fcontext -a -t httpd_sys_content_t "$USERHOME/build/(website|lib|settings)(/.*)?"
-    sudo semanage fcontext -a -t lib_t "$USERHOME/build/module/nominatim.so"
-    sudo restorecon -R -v $USERHOME/Nominatim
-    sudo restorecon -R -v $USERHOME/build
+    sudo semanage fcontext -a -t httpd_sys_content_t "/usr/local/nominatim/lib/lib-php(/.*)?"
+    sudo semanage fcontext -a -t httpd_sys_content_t "$USERHOME/nominatim-project/website(/.*)?"
+    sudo semanage fcontext -a -t lib_t "$USERHOME/nominatim-project/module/nominatim.so"
+    sudo restorecon -R -v /usr/local/lib/nominatim
+    sudo restorecon -R -v $USERHOME/nominatim-project
 
 
 # You need to create a minimal configuration file that tells nominatim
index 548f8c9caf76d33a3dab14c2ee6bac1655b3e1be..1cf93a1f5e58c0241a24730e7b67ea1e077e1b13 100755 (executable)
@@ -100,36 +100,6 @@ sudo chown vagrant /srv/nominatim  #DOCS:
     sudo -u postgres createuser -s $USERNAME
     sudo -u postgres createuser apache
 
-#
-# Setting up the Apache Webserver
-# -------------------------------
-#
-# You need to create an alias to the website directory in your apache
-# configuration. Add a separate nominatim configuration to your webserver:
-
-#DOCS:```sh
-sudo tee /etc/httpd/conf.d/nominatim.conf << EOFAPACHECONF
-<Directory "$USERHOME/build/website">
-  Options FollowSymLinks MultiViews
-  AddType text/html   .php
-  DirectoryIndex search.php
-  Require all granted
-</Directory>
-
-Alias /nominatim $USERHOME/build/website
-EOFAPACHECONF
-#DOCS:```
-
-sudo sed -i 's:#.*::' /etc/httpd/conf.d/nominatim.conf #DOCS:
-
-#
-# Then reload apache
-#
-
-    sudo systemctl enable httpd
-    sudo systemctl restart httpd
-
-
 #
 # Installing Nominatim
 # ====================
@@ -158,11 +128,48 @@ fi                                 #DOCS:
 # then configure and build Nominatim in there:
 
 #DOCS:    :::sh
-    cd $USERHOME
-    mkdir build
-    cd build
+    mkdir $USERHOME/build
+    cd $USERHOME/build
     cmake $USERHOME/Nominatim
     make
+    sudo make install
+
+#
+# Setting up the Apache Webserver
+# -------------------------------
+#
+# The webserver should serve the php scripts from the website directory of your
+# [project directory](../admin/import.md#creating-the-project-directory).
+# Therefore set up a project directory and populate the website directory:
+#
+    mkdir $USERHOME/nominatim-project
+    cd $USERHOME/nominatim-project
+    nominatim refresh --website
+#
+# You need to create an alias to the website directory in your apache
+# configuration. Add a separate nominatim configuration to your webserver:
+
+#DOCS:```sh
+sudo tee /etc/httpd/conf.d/nominatim.conf << EOFAPACHECONF
+<Directory "$USERHOME/nominatim-project/website">
+  Options FollowSymLinks MultiViews
+  AddType text/html   .php
+  DirectoryIndex search.php
+  Require all granted
+</Directory>
+
+Alias /nominatim $USERHOME/nominatim-project/website
+EOFAPACHECONF
+#DOCS:```
+
+sudo sed -i 's:#.*::' /etc/httpd/conf.d/nominatim.conf #DOCS:
+
+#
+# Then reload apache
+#
+
+    sudo systemctl enable httpd
+    sudo systemctl restart httpd
 
 #
 # Adding SELinux Security Settings
@@ -172,11 +179,11 @@ fi                                 #DOCS:
 # with a web server accessible from the Internet. At a minimum the
 # following SELinux labeling should be done for Nominatim:
 
-    sudo semanage fcontext -a -t httpd_sys_content_t "$USERHOME/Nominatim/(website|lib|settings)(/.*)?"
-    sudo semanage fcontext -a -t httpd_sys_content_t "$USERHOME/build/(website|lib|settings)(/.*)?"
-    sudo semanage fcontext -a -t lib_t "$USERHOME/build/module/nominatim.so"
-    sudo restorecon -R -v $USERHOME/Nominatim
-    sudo restorecon -R -v $USERHOME/build
+    sudo semanage fcontext -a -t httpd_sys_content_t "/usr/local/nominatim/lib/lib-php(/.*)?"
+    sudo semanage fcontext -a -t httpd_sys_content_t "$USERHOME/nominatim-project/website(/.*)?"
+    sudo semanage fcontext -a -t lib_t "$USERHOME/nominatim-project/module/nominatim.so"
+    sudo restorecon -R -v /usr/local/lib/nominatim
+    sudo restorecon -R -v $USERHOME/nominatim-project
 
 
 # You need to create a minimal configuration file that tells nominatim
index 8a4d2b7385d940a79ef7eed654054ba08dd206b8..527ded096af4719cb45629b2f47d9301774ec836 100755 (executable)
@@ -29,9 +29,13 @@ export DEBIAN_FRONTEND=noninteractive #DOCS:
                         libbz2-dev libpq-dev libproj-dev \
                         postgresql-server-dev-10 postgresql-10-postgis-2.4 \
                         postgresql-contrib-10 postgresql-10-postgis-scripts \
-                        php php-pgsql php-intl python3-dotenv \
+                        php php-pgsql php-intl python3-pip \
                         python3-psycopg2 git
 
+# The python-dotenv package that comes with Ubuntu 18.04 is too old, so
+# install the latest version from pip:
+
+    pip3 install python-dotenv
 
 #
 # System Configuration
@@ -113,11 +117,11 @@ fi                                 #DOCS:
 # The code must be built in a separate directory. Create this directory,
 # then configure and build Nominatim in there:
 
-    cd $USERHOME
-    mkdir build
-    cd build
+    mkdir $USERHOME/build
+    cd $USERHOME/build
     cmake $USERHOME/Nominatim
     make
+    sudo make install
 
 
 # Nominatim is now ready to use. You can continue with
@@ -127,6 +131,14 @@ fi                                 #DOCS:
 # Setting up a webserver
 # ======================
 #
+# The webserver should serve the php scripts from the website directory of your
+# [project directory](../admin/import.md#creating-the-project-directory).
+# Therefore set up a project directory and populate the website directory:
+
+    mkdir $USERHOME/nominatim-project
+    cd $USERHOME/nominatim-project
+    nominatim refresh --website
+#
 # Option 1: Using Apache
 # ----------------------
 #
@@ -142,14 +154,14 @@ if [ "x$2" == "xinstall-apache" ]; then #DOCS:
 
 #DOCS:```sh
 sudo tee /etc/apache2/conf-available/nominatim.conf << EOFAPACHECONF
-<Directory "$USERHOME/build/website">
+<Directory "$USERHOME/nominatim-project/website">
   Options FollowSymLinks MultiViews
   AddType text/html   .php
   DirectoryIndex search.php
   Require all granted
 </Directory>
 
-Alias /nominatim $USERHOME/build/website
+Alias /nominatim $USERHOME/nominatim-project/website
 EOFAPACHECONF
 #DOCS:```
 
@@ -206,7 +218,7 @@ server {
     listen 80 default_server;
     listen [::]:80 default_server;
 
-    root $USERHOME/build/website;
+    root $USERHOME/nominatim-project/website;
     index search.php index.html;
     location / {
         try_files \$uri \$uri/ @php;
old mode 100644 (file)
new mode 100755 (executable)
index 94afca7..bf8120c
@@ -115,11 +115,11 @@ fi                                 #DOCS:
 # The code must be built in a separate directory. Create this directory,
 # then configure and build Nominatim in there:
 
-    cd $USERHOME
-    mkdir build
-    cd build
+    mkdir $USERHOME/build
+    cd $USERHOME/build
     cmake $USERHOME/Nominatim
     make
+    sudo make install
 
 # Nominatim is now ready to use. You can continue with
 # [importing a database from OSM data](../admin/Import.md). If you want to set up
@@ -127,6 +127,15 @@ fi                                 #DOCS:
 #
 # Setting up a webserver
 # ======================
+#
+# The webserver should serve the php scripts from the website directory of your
+# [project directory](../admin/import.md#creating-the-project-directory).
+# Therefore set up a project directory and populate the website directory:
+
+    mkdir $USERHOME/nominatim-project
+    cd $USERHOME/nominatim-project
+    nominatim refresh --website
+
 #
 # Option 1: Using Apache
 # ----------------------
@@ -143,14 +152,14 @@ if [ "x$2" == "xinstall-apache" ]; then #DOCS:
 
 #DOCS:```sh
 sudo tee /etc/apache2/conf-available/nominatim.conf << EOFAPACHECONF
-<Directory "$USERHOME/build/website">
+<Directory "$USERHOME/nominatim-project/website">
   Options FollowSymLinks MultiViews
   AddType text/html   .php
   DirectoryIndex search.php
   Require all granted
 </Directory>
 
-Alias /nominatim $USERHOME/build/website
+Alias /nominatim $USERHOME/nominatim-project/website
 EOFAPACHECONF
 #DOCS:```
 
@@ -207,7 +216,7 @@ server {
     listen 80 default_server;
     listen [::]:80 default_server;
 
-    root $USERHOME/build/website;
+    root $USERHOME/nominatim-project/website;
     index search.php index.html;
     location / {
         try_files \$uri \$uri/ @php;