From: Sarah Hoffmann Date: Fri, 9 Jun 2017 19:54:05 +0000 (+0200) Subject: Merge remote-tracking branch 'upstream/master' X-Git-Tag: deploy~381 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/c504ec523cd815d920528bcdc9b915a83f2fd64a?ds=inline;hp=-c Merge remote-tracking branch 'upstream/master' --- c504ec523cd815d920528bcdc9b915a83f2fd64a diff --combined lib/lib.php index 941f6a1d,cb599ae8..c6eadc6c --- a/lib/lib.php +++ b/lib/lib.php @@@ -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 f7f20aa3,f4716768..099ca0b3 --- a/utils/update.php +++ b/utils/update.php @@@ -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));