mirror of
https://github.com/osm-search/Nominatim.git
synced 2024-11-23 05:35:13 +03:00
format change revert, removed bogus CL options, SetupClass to a new dir
This commit is contained in:
parent
aa6ac5a751
commit
d10f63b666
18
lib/SetupClass.php → lib/classes/SetupClass.php
Normal file → Executable file
18
lib/SetupClass.php → lib/classes/SetupClass.php
Normal file → Executable file
@ -45,10 +45,24 @@ class SetupFunctions
|
||||
|
||||
// setting member variables based on command line options stored in $aCMDResult
|
||||
$this->sVerbose = $aCMDResult['verbose'];
|
||||
$this->sIgnoreErrors = $aCMDResult['ignore-errors'];
|
||||
$this->bEnableDiffUpdates = $aCMDResult['enable-diff-updates'];
|
||||
|
||||
//setting default values which are not set by the update.php array
|
||||
if (isset($aCMDResult['ignore-errors'])) {
|
||||
$this->sIgnoreErrors = $aCMDResult['ignore-errors'];
|
||||
} else {
|
||||
$this->sIgnoreErrors = false;
|
||||
}
|
||||
if (isset($aCMDResult['enable-debug-statements'])) {
|
||||
$this->bEnableDebugStatements = $aCMDResult['enable-debug-statements'];
|
||||
} else {
|
||||
$this->bEnableDebugStatements = false;
|
||||
}
|
||||
if (isset($aCMDResult['no-partitions'])) {
|
||||
$this->bNoPartitions = $aCMDResult['no-partitions'];
|
||||
} else {
|
||||
$this->bNoPartitions = false;
|
||||
}
|
||||
}
|
||||
|
||||
public function createDB()
|
||||
@ -402,7 +416,7 @@ class SetupFunctions
|
||||
// PGSQL_EMPTY_QUERY, PGSQL_COMMAND_OK, PGSQL_TUPLES_OK,
|
||||
// PGSQL_COPY_OUT, PGSQL_COPY_IN, PGSQL_BAD_RESPONSE,
|
||||
// PGSQL_NONFATAL_ERROR and PGSQL_FATAL_ERROR
|
||||
echo 'Query result ' . $i . ' is: ' . $resultStatus . "\n";
|
||||
// echo 'Query result ' . $i . ' is: ' . $resultStatus . "\n";
|
||||
if ($resultStatus != PGSQL_COMMAND_OK && $resultStatus != PGSQL_TUPLES_OK) {
|
||||
$resultError = pg_result_error($hPGresult);
|
||||
echo '-- error text ' . $i . ': ' . $resultError . "\n";
|
@ -118,9 +118,6 @@ function createUpdateArgvArray()
|
||||
|
||||
array('create-functions', '', 0, 1, 1, 1, 'bool', 'Create functions'),
|
||||
array('enable-diff-updates', '', 0, 1, 1, 1, 'bool', 'Turn on the code required to make diff updates work'),
|
||||
array('ignore-errors', '', 0, 1, 0, 0, 'bool', 'Continue import even when errors in SQL are present (EXPERT)'),
|
||||
array('enable-debug-statements', '', 0, 1, 0, 0, 'bool', 'Include debug warning statements in pgsql commands'),
|
||||
array('no-partitions', '', 0, 1, 0, 0, 'bool', 'Do not partition search indices (speeds up import of single country extracts)'),
|
||||
);
|
||||
return $aCMDOptions;
|
||||
}
|
||||
|
@ -1,13 +1,12 @@
|
||||
#!@PHP_BIN@ -Cq
|
||||
<?php
|
||||
|
||||
require_once dirname(dirname(__FILE__)) . '/settings/settings.php';
|
||||
require_once CONST_BasePath . '/lib/init-cmd.php';
|
||||
require_once CONST_BasePath . '/lib/SetupClass.php';
|
||||
require_once(dirname(dirname(__FILE__)).'/settings/settings.php');
|
||||
require_once(CONST_BasePath.'/lib/init-cmd.php');
|
||||
require_once(CONST_BasePath.'/lib/classes/SetupClass.php');
|
||||
// ->indirect via init-cmd.php->/lib/cmd.php for runWithEnv, getCmdOpt
|
||||
// ->indirect via init-cmd.php->/lib/init.php->db.php for &getDB()
|
||||
|
||||
require_once CONST_BasePath . '/lib/setup_functions.php';
|
||||
require_once(CONST_BasePath.'/lib/setup_functions.php');
|
||||
ini_set('memory_limit', '800M');
|
||||
|
||||
use Nominatim\Setup\SetupFunctions as SetupFunctions;
|
||||
@ -25,7 +24,6 @@ $bDidSomething = false;
|
||||
if ($aCMDResult['import-data'] || $aCMDResult['all']) {
|
||||
// to remain in /lib/setup_functions.php function
|
||||
checkInFile($aCMDResult['osm-file']);
|
||||
echo $aCMDResult['osm-file'];
|
||||
}
|
||||
|
||||
// osmosis init is no longer supported
|
||||
|
@ -1,34 +1,27 @@
|
||||
#!@PHP_BIN@ -Cq
|
||||
<?php
|
||||
|
||||
require_once dirname(dirname(__FILE__)) . '/settings/settings.php';
|
||||
require_once CONST_BasePath . '/lib/init-cmd.php';
|
||||
require_once CONST_BasePath . '/lib/setup_functions.php';
|
||||
require_once CONST_BasePath . '/lib/SetupClass.php';
|
||||
require_once(dirname(dirname(__FILE__)).'/settings/settings.php');
|
||||
require_once(CONST_BasePath.'/lib/init-cmd.php');
|
||||
require_once(CONST_BasePath.'/lib/setup_functions.php');
|
||||
require_once(CONST_BasePath.'/lib/classes/SetupClass.php');
|
||||
|
||||
ini_set('memory_limit', '800M');
|
||||
|
||||
use Nominatim\Setup\SetupFunctions as SetupFunctions;
|
||||
|
||||
$aCMDOptions = createUpdateArgvArray();
|
||||
|
||||
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;
|
||||
}
|
||||
if (!isset($aResult['index-instances'])) $aResult['index-instances'] = 1;
|
||||
if (!isset($aResult['index-rank'])) $aResult['index-rank'] = 0;
|
||||
|
||||
date_default_timezone_set('Etc/UTC');
|
||||
|
||||
$oDB =& getDB();
|
||||
|
||||
$aDSNInfo = DB::parseDSN(CONST_Database_DSN);
|
||||
if (!isset($aDSNInfo['port']) || !$aDSNInfo['port']) {
|
||||
$aDSNInfo['port'] = 5432;
|
||||
}
|
||||
if (!isset($aDSNInfo['port']) || !$aDSNInfo['port']) $aDSNInfo['port'] = 5432;
|
||||
|
||||
// cache memory to be used by osm2pgsql, should not be more than the available memory
|
||||
$iCacheMemory = (isset($aResult['osm2pgsql-cache'])?$aResult['osm2pgsql-cache']:2000);
|
||||
@ -78,8 +71,11 @@ if ($aResult['init-updates']) {
|
||||
}
|
||||
|
||||
if (!$aResult['no-update-functions']) {
|
||||
// instatiate setupClass to use the function therein
|
||||
// instantiate Setup class
|
||||
// Try accessing the C module,
|
||||
if (!checkModulePresence()) {
|
||||
fail('error loading nominatim.so module');
|
||||
}
|
||||
// instantiate setupClass to use the function therein
|
||||
$cSetup = new SetupFunctions($aResult);
|
||||
$cSetup->createFunctions();
|
||||
}
|
||||
@ -213,10 +209,7 @@ if ($aResult['deduplicate']) {
|
||||
$sSQL .= ' group by word_token having count(*) > 1 order by word_token';
|
||||
$aDuplicateTokens = chksql($oDB->getAll($sSQL));
|
||||
foreach ($aDuplicateTokens as $aToken) {
|
||||
if (trim($aToken['word_token']) == '' || trim($aToken['word_token']) == '-') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (trim($aToken['word_token']) == '' || trim($aToken['word_token']) == '-') continue;
|
||||
echo 'Deduping '.$aToken['word_token']."\n";
|
||||
$sSQL = 'select word_id,';
|
||||
$sSQL .= ' (select count(*) from search_name where nameaddress_vector @> ARRAY[word_id]) as num';
|
||||
@ -414,8 +407,6 @@ if ($aResult['import-osmosis'] || $aResult['import-osmosis-all']) {
|
||||
|
||||
$fDuration = time() - $fStartTime;
|
||||
echo date('Y-m-d H:i:s')." Completed all for $sBatchEnd in ".round($fDuration/60, 2)." minutes\n";
|
||||
if (!$aResult['import-osmosis-all']) {
|
||||
exit(0);
|
||||
}
|
||||
if (!$aResult['import-osmosis-all']) exit(0);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user