X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/55fa051d3a7019db62802f6bce29ab2a8f7e9657..8237aba8404202830d538eb9c9ab35bbcae76bd6:/utils/update.php diff --git a/utils/update.php b/utils/update.php old mode 100755 new mode 100644 index 038313f3..3ef12cfb --- a/utils/update.php +++ b/utils/update.php @@ -1,13 +1,15 @@ -#!@PHP_BIN@ -Cq getTotalMemoryMB()) { $iCacheMemory = getCacheMemoryMB(); echo "WARNING: resetting cache memory to $iCacheMemory\n"; } -$sOsm2pgsqlCmd = CONST_Osm2pgsql_Binary.' -klas --number-processes 1 -C '.$iCacheMemory.' -O gazetteer -d '.$aDSNInfo['database'].' -P '.$aDSNInfo['port']; +$sOsm2pgsqlCmd = CONST_Osm2pgsql_Binary.' -klas --number-processes 1 -C '.$iCacheMemory.' -O gazetteer -S '.CONST_Import_Style.' -d '.$aDSNInfo['database'].' -P '.$aDSNInfo['port']; if (isset($aDSNInfo['username']) && $aDSNInfo['username']) { $sOsm2pgsqlCmd .= ' -U ' . $aDSNInfo['username']; } @@ -99,17 +103,15 @@ if ($aResult['init-updates']) { echo "and have set up CONST_Pyosmium_Binary to point to pyosmium-get-changes.\n"; fail('pyosmium-get-changes not found or not usable'); } + if (!$aResult['no-update-functions']) { - $sSetup = CONST_InstallPath.'/utils/setup.php'; - $iRet = -1; - $aCMDResult['create-functions'] = true; - $aCMDResult['enable-diff-updates'] = true; - # passthru($sSetup.' --create-functions --enable-diff-updates', $iRet); - create_functions($aCMDResult); - - if ($iRet != 0) { - fail('Error running setup script'); - } + // instantiate setupClass to use the function therein + $cSetup = new SetupFunctions(array( + 'enable-diff-updates' => true, + 'verbose' => $aResult['verbose'] + )); + $cSetup->connect(); + $cSetup->createFunctions(); } $sDatabaseDate = getDatabaseDate($oDB); @@ -303,6 +305,14 @@ if ($aResult['index']) { } runWithEnv($sCmd, $aProcEnv); + + $oDB->query('update import_status set indexed = true'); +} + +if ($aResult['update-address-levels']) { + echo 'Updating address levels from '.CONST_Address_Level_Config.".\n"; + $oAlParser = new \Nominatim\Setup\AddressLevelParser(CONST_Address_Level_Config); + $oAlParser->createTable($oDB, 'address_levels'); } if ($aResult['import-osmosis'] || $aResult['import-osmosis-all']) { @@ -426,7 +436,7 @@ if ($aResult['import-osmosis'] || $aResult['import-osmosis-all']) { $sSQL = 'INSERT INTO import_osmosis_log'; $sSQL .= '(batchend, batchseq, batchsize, starttime, endtime, event)'; - $sSQL .= " values ('$sBatchEnd',$iEndSequence,$iFileSize,'"; + $sSQL .= " values ('$sBatchEnd',$iEndSequence,NULL,'"; $sSQL .= date('Y-m-d H:i:s', $fCMDStartTime)."','"; $sSQL .= date('Y-m-d H:i:s')."','index')"; var_Dump($sSQL); @@ -435,6 +445,11 @@ if ($aResult['import-osmosis'] || $aResult['import-osmosis-all']) { $sSQL = 'update import_status set indexed = true'; $oDB->query($sSQL); + } else { + if ($aResult['import-osmosis-all']) { + echo "Error: --no-index cannot be used with continuous imports (--import-osmosis-all).\n"; + exit(1); + } } $fDuration = time() - $fStartTime;