]> 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)
1  2 
lib/lib.php
utils/update.php

diff --combined lib/lib.php
index 941f6a1d9bcdcba817695bc3a13e0005c7618c5c,cb599ae8b1c46ed758b9f0d52fe3e3a01b571c42..c6eadc6cd6cd51946b4dbce5b87fbc5881015723
@@@ -38,8 -38,13 +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];
@@@ -626,10 -631,10 +631,10 @@@ function geometryText2Points($geometry_
          //
          preg_match_all('/(-?[0-9.]+) (-?[0-9.]+)/', $aMatch[1], $aPolyPoints, PREG_SET_ORDER);
          //
 -    } elseif (preg_match('#MULTIPOLYGON\\(\\(\\(([- 0-9.,]+)#', $geometry_as_text, $aMatch)) {
 +/*    } elseif (preg_match('#MULTIPOLYGON\\(\\(\\(([- 0-9.,]+)#', $geometry_as_text, $aMatch)) {
          //
          preg_match_all('/(-?[0-9.]+) (-?[0-9.]+)/', $aMatch[1], $aPolyPoints, PREG_SET_ORDER);
 -        //
 +        */
      } elseif (preg_match('#POINT\\((-?[0-9.]+) (-?[0-9.]+)\\)#', $geometry_as_text, $aMatch)) {
          //
          $aPolyPoints = createPointsAroundCenter($aMatch[1], $aMatch[2], $fRadius);
diff --combined utils/update.php
index f7f20aa3f76fc14541e87dd0d5feaccfcd19f449,f47167687a756e1200d628cd763411baa06eb6b9..099ca0b3d8e54848a164da0b2c66d6fd67f9ea13
@@@ -38,7 -38,6 +38,7 @@@ $aCMDOption
  getCmdOpt($_SERVER['argv'], $aCMDOptions, $aResult, true, true);
  
  if (!isset($aResult['index-instances'])) $aResult['index-instances'] = 1;
 +
  if (!isset($aResult['index-rank'])) $aResult['index-rank'] = 0;
  
  date_default_timezone_set('Etc/UTC');
@@@ -68,6 -67,9 +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 -296,14 +297,14 @@@ if ($aResult['import-osmosis'] || $aRes
  
              // 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));