$bDidSomething = false;
$oNominatimCmd = new \Nominatim\Shell(getSetting('NOMINATIM_TOOL'));
-if (isset($aCMDResult['quiet']) && $aCMDResult['quiet']) {
- $oNominatimCmd->addParams('--quiet');
-}
-if ($aCMDResult['verbose']) {
- $oNominatimCmd->addParams('--verbose');
-}
// by default, use all but one processor, but never more than 15.
$iInstances = max(1, $aCMDResult['threads'] ?? (min(16, getProcessorCount()) - 1));
-function run($oCmd) {
+function run($oCmd)
+{
global $iInstances;
global $aCMDResult;
$oCmd->addParams('--threads', $iInstances);
if ($aCMDResult['ignore-errors'] ?? false) {
$oCmd->addParams('--ignore-errors');
}
+ if ($aCMDResult['quiet'] ?? false) {
+ $oCmd->addParams('--quiet');
+ }
+ if ($aCMDResult['verbose'] ?? false) {
+ $oCmd->addParams('--verbose');
+ }
$oCmd->run(true);
}
}
$oNominatimCmd = new \Nominatim\Shell(getSetting('NOMINATIM_TOOL'));
-if ($aResult['quiet']) {
- $oNominatimCmd->addParams('--quiet');
-}
-if ($aResult['verbose']) {
- $oNominatimCmd->addParams('--verbose');
+
+function run($oCmd)
+{
+ global $aCMDResult;
+ if ($aCMDResult['quiet'] ?? false) {
+ $oCmd->addParams('--quiet');
+ }
+ if ($aCMDResult['verbose'] ?? false) {
+ $oCmd->addParams('--verbose');
+ }
+ $oCmd->run(true);
}
$oCmd->addParams('--no-update-functions');
}
- $oCmd->run();
+ run($oCmd);
}
if ($aResult['check-for-updates']) {
}
if ($aResult['calculate-postcodes']) {
- (clone($oNominatimCmd))->addParams('refresh', '--postcodes')->run();
+ run((clone($oNominatimCmd))->addParams('refresh', '--postcodes'));
}
$sTemporaryFile = CONST_InstallDir.'/osmosischange.osc';
}
if ($aResult['recompute-word-counts']) {
- (clone($oNominatimCmd))->addParams('refresh', '--word-counts')->run();
+ run((clone($oNominatimCmd))->addParams('refresh', '--word-counts'));
}
if ($aResult['index']) {
- (clone $oNominatimCmd)
+ run((clone $oNominatimCmd)
->addParams('index', '--minrank', $aResult['index-rank'])
- ->addParams('--threads', $aResult['index-instances'])
- ->run();
+ ->addParams('--threads', $aResult['index-instances']));
}
if ($aResult['update-address-levels']) {
- (clone($oNominatimCmd))->addParams('refresh', '--address-levels')->run();
+ run((clone($oNominatimCmd))->addParams('refresh', '--address-levels'));
}
if ($aResult['recompute-importance']) {
- (clone($oNominatimCmd))->addParams('refresh', '--importance')->run(true);
+ run((clone($oNominatimCmd))->addParams('refresh', '--importance'));
}
if ($aResult['import-osmosis'] || $aResult['import-osmosis-all']) {
$oCmd->addParams('--no-index');
}
- exit($oCmd->run());
+ run($oCmd);
}