]> git.openstreetmap.org Git - nominatim.git/commitdiff
Merge remote-tracking branch 'upstream/master'
authorSarah Hoffmann <lonvia@denofr.de>
Fri, 9 Jun 2017 19:54:05 +0000 (21:54 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Fri, 9 Jun 2017 19:54:05 +0000 (21:54 +0200)
docs/install-on-centos-7.md
docs/install-on-ubuntu-16.md
lib/lib.php
utils/osm_file_date.py [new file with mode: 0755]
utils/setup.php
utils/update.php

index 40e8a4042e749b4602752531e2ee3e4cdce0020d..481bd2d0d7d74c8a9fc7194ba86fa05583e5b66e 100644 (file)
@@ -6,7 +6,7 @@ Installing the Required Software
 ================================
 
 These instructions expect that you have a freshly installed CentOS version 7.
-Make sure all packages are are up-to-date by running:
+Make sure all packages are up-to-date by running:
 
     sudo yum update -y
 
@@ -20,7 +20,7 @@ Now you can install all packages needed for Nominatim:
 
     sudo yum install -y postgresql-server postgresql-contrib postgresql-devel postgis postgis-utils \
                         git cmake make gcc gcc-c++ libtool policycoreutils-python \
-                        php-pgsql php php-pear php-pear-DB libpqxx-devel proj-epsg \
+                        php-pgsql php php-pear php-pear-DB php-intl libpqxx-devel proj-epsg \
                         bzip2-devel proj-devel geos-devel libxml2-devel boost-devel expat-devel zlib-devel
 
 If you want to run the test suite, you need to install the following
index 66d82cf0090f2145ddbf0aec9889bf1dd557b0eb..de8468d42a232acadc063ea0efb83bd163e7a40a 100644 (file)
@@ -27,7 +27,7 @@ Now you can install all packages needed for Nominatim:
                             libbz2-dev libpq-dev libgeos-dev libgeos++-dev libproj-dev \
                             postgresql-server-dev-9.5 postgresql-9.5-postgis-2.2 postgresql-contrib-9.5 \
                             apache2 php php-pgsql libapache2-mod-php php-pear php-db \
-                            git
+                            php-intl git
 
 If you want to run the test suite, you need to install the following
 additional packages:
index 941f6a1d9bcdcba817695bc3a13e0005c7618c5c..c6eadc6cd6cd51946b4dbce5b87fbc5881015723 100644 (file)
@@ -38,8 +38,13 @@ function getDatabaseDate(&$oDB)
     // Find the newest node in the DB
     $iLastOSMID = $oDB->getOne("select max(osm_id) from place where osm_type = 'N'");
     // Lookup the timestamp that node was created
-    $sLastNodeURL = 'http://www.openstreetmap.org/api/0.6/node/'.$iLastOSMID."/1";
+    $sLastNodeURL = 'https://www.openstreetmap.org/api/0.6/node/'.$iLastOSMID."/1";
     $sLastNodeXML = file_get_contents($sLastNodeURL);
+
+    if ($sLastNodeXML === false) {
+        return false;
+    }
+
     preg_match('#timestamp="(([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})Z)"#', $sLastNodeXML, $aLastNodeDate);
 
     return $aLastNodeDate[1];
diff --git a/utils/osm_file_date.py b/utils/osm_file_date.py
new file mode 100755 (executable)
index 0000000..6418efb
--- /dev/null
@@ -0,0 +1,33 @@
+#!/usr/bin/python
+
+import osmium
+import sys
+import datetime
+
+
+class Datecounter(osmium.SimpleHandler):
+
+    filedate = None
+
+    def date(self, o):
+        ts = o.timestamp
+        if self.filedate is None or ts > self.filedate:
+            self.filedate = ts
+
+    node = date
+    way = date
+    relation = date
+
+
+if __name__ == '__main__':
+    if len(sys.argv) != 2:
+        print("Usage: python osm_file_date.py <osmfile>")
+        sys.exit(-1)
+
+    h = Datecounter()
+
+    h.apply_file(sys.argv[1])
+
+    print(h.filedate)
+
+
index eeba0a28e23ac79d1bedae806e6533c6a680ae75..7490d820dd212735b23aa5270a70efd39753a9d6 100755 (executable)
@@ -407,9 +407,13 @@ if ($aCMDResult['load-data'] || $aCMDResult['all']) {
 
     $sDatabaseDate = getDatabaseDate($oDB);
     pg_query($oDB->connection, 'TRUNCATE import_status');
-    $sSQL = "INSERT INTO import_status (lastimportdate) VALUES('".$sDatabaseDate."')";
-    pg_query($oDB->connection, $sSQL);
-    echo "Latest data imported from $sDatabaseDate.\n";
+    if ($sDatabaseDate === false) {
+        echo "WARNING: could not determine database date.\n";
+    } else {
+        $sSQL = "INSERT INTO import_status (lastimportdate) VALUES('".$sDatabaseDate."')";
+        pg_query($oDB->connection, $sSQL);
+        echo "Latest data imported from $sDatabaseDate.\n";
+    }
 }
 
 if ($aCMDResult['import-tiger-data']) {
index f7f20aa3f76fc14541e87dd0d5feaccfcd19f449..099ca0b3d8e54848a164da0b2c66d6fd67f9ea13 100755 (executable)
@@ -68,6 +68,9 @@ if ($aResult['init-updates']) {
     }
 
     $sDatabaseDate = getDatabaseDate($oDB);
+    if ($sDatabaseDate === false) {
+        fail("Cannot determine date of database.");
+    }
     $sWindBack = strftime('%Y-%m-%dT%H:%M:%SZ',
                           strtotime($sDatabaseDate) - (3*60*60));
 
@@ -294,7 +297,14 @@ if ($aResult['import-osmosis'] || $aResult['import-osmosis-all']) {
 
             // write the update logs
             $iFileSize = filesize($sImportFile);
-            $sBatchEnd = getDatabaseDate($oDB);
+            // get the newest object from the diff file
+            $sBatchEnd = 0;
+            $iRet = 0;
+            exec(CONST_BasePath.'/utils/osm_file_date.py '.$sImportFile, $sBatchEnd, $iRet);
+            if ($iRet != 0) {
+                fail('Error getting date from diff file.');
+            }
+            $sBatchEnd = $sBatchEnd[0];
             $sSQL = "INSERT INTO import_osmosis_log (batchend, batchseq, batchsize, starttime, endtime, event) values ('$sBatchEnd',$iEndSequence,$iFileSize,'".date('Y-m-d H:i:s', $fCMDStartTime)."','".date('Y-m-d H:i:s')."','import')";
             var_Dump($sSQL);
             chksql($oDB->query($sSQL));