$iInstances = isset($aCMDResult['threads'])?$aCMDResult['threads']:(getProcessorCount()-1);
if ($iInstances < 1) {
$iInstances = 1;
- echo "WARNING: resetting threads to $iInstances\n";
+ warn("resetting threads to $iInstances");
}
if ($iInstances > getProcessorCount()) {
$iInstances = getProcessorCount();
- echo "WARNING: resetting threads to $iInstances\n";
+ warn("resetting threads to $iInstances");
}
// Assume we can steal all the cache memory in the box (unless told otherwise)
if (!isset($aDSNInfo['port']) || !$aDSNInfo['port']) $aDSNInfo['port'] = 5432;
if ($aCMDResult['create-db'] || $aCMDResult['all']) {
- echo "Create DB\n";
+ info("Create DB");
$bDidSomething = true;
$oDB = DB::connect(CONST_Database_DSN, false);
if (!PEAR::isError($oDB)) {
}
if ($aCMDResult['setup-db'] || $aCMDResult['all']) {
- echo "Setup DB\n";
+ info("Setup DB");
$bDidSomething = true;
- // TODO: path detection, detection memory, etc.
- //
$oDB =& getDB();
$fPostgresVersion = getPostgresVersion($oDB);
if ($iNumFunc == 0) {
pgsqlRunScript("create function hstore_to_json(dummy hstore) returns text AS 'select null::text' language sql immutable");
- echo "WARNING: Postgresql is too old. extratags and namedetails API not available.";
+ warn('Postgresql is too old. extratags and namedetails API not available.');
}
$fPostgisVersion = getPostgisVersion($oDB);
if (file_exists(CONST_BasePath.'/data/gb_postcode_data.sql.gz')) {
pgsqlRunScriptFile(CONST_BasePath.'/data/gb_postcode_data.sql.gz');
} else {
- echo "WARNING: external UK postcode table not found.\n";
+ warn('external UK postcode table not found.');
}
if (CONST_Use_Extra_US_Postcodes) {
pgsqlRunScriptFile(CONST_BasePath.'/data/us_postcode.sql');
}
if ($aCMDResult['import-data'] || $aCMDResult['all']) {
- echo "Import\n";
+ info('Import data');
$bDidSomething = true;
$osm2pgsql = CONST_Osm2pgsql_Binary;
}
if ($aCMDResult['create-functions'] || $aCMDResult['all']) {
- echo "Functions\n";
+ info('Create Functions');
$bDidSomething = true;
- if (!file_exists(CONST_InstallPath.'/module/nominatim.so')) fail("nominatim module not built");
+ if (!file_exists(CONST_InstallPath.'/module/nominatim.so')) {
+ fail("nominatim module not built");
+ }
create_sql_functions($aCMDResult);
}
if ($aCMDResult['create-tables'] || $aCMDResult['all']) {
+ info('Create Tables');
$bDidSomething = true;
- echo "Tables\n";
$sTemplate = file_get_contents(CONST_BasePath.'/sql/tables.sql');
$sTemplate = str_replace('{www-user}', CONST_Database_Web_User, $sTemplate);
$sTemplate = replace_tablespace(
pgsqlRunScript($sTemplate, false);
// re-run the functions
- echo "Functions\n";
+ info('Recreate Functions');
create_sql_functions($aCMDResult);
}
if ($aCMDResult['create-partition-tables'] || $aCMDResult['all']) {
- echo "Partition Tables\n";
+ info('Create Partition Tables');
$bDidSomething = true;
$sTemplate = file_get_contents(CONST_BasePath.'/sql/partition-tables.src.sql');
if ($aCMDResult['create-partition-functions'] || $aCMDResult['all']) {
- echo "Partition Functions\n";
+ info('Create Partition Functions');
$bDidSomething = true;
$sTemplate = file_get_contents(CONST_BasePath.'/sql/partition-functions.src.sql');
$sWikiArticlesFile = CONST_Wikipedia_Data_Path.'/wikipedia_article.sql.bin';
$sWikiRedirectsFile = CONST_Wikipedia_Data_Path.'/wikipedia_redirect.sql.bin';
if (file_exists($sWikiArticlesFile)) {
- echo "Importing wikipedia articles...";
+ info('Importing wikipedia articles');
pgsqlRunDropAndRestore($sWikiArticlesFile);
- echo "...done\n";
} else {
- echo "WARNING: wikipedia article dump file not found - places will have default importance\n";
+ warn('wikipedia article dump file not found - places will have default importance');
}
if (file_exists($sWikiRedirectsFile)) {
- echo "Importing wikipedia redirects...";
+ info('Importing wikipedia redirects');
pgsqlRunDropAndRestore($sWikiRedirectsFile);
- echo "...done\n";
} else {
- echo "WARNING: wikipedia redirect dump file not found - some place importance values may be missing\n";
+ warn('wikipedia redirect dump file not found - some place importance values may be missing');
}
}
if ($aCMDResult['load-data'] || $aCMDResult['all']) {
- echo "Drop old Data\n";
+ info('Drop old Data');
$bDidSomething = true;
$oDB =& getDB();
// pre-create the word list
if (!$aCMDResult['disable-token-precalc']) {
- echo "Loading word list\n";
+ info('Loading word list');
pgsqlRunScriptFile(CONST_BasePath.'/data/words.sql');
}
- echo "Load Data\n";
+ info('Load Data');
$sColumns = 'osm_type, osm_id, class, type, name, admin_level, address, extratags, geometry';
$aDBInstances = array();
echo '.';
}
echo "\n";
- echo "Reanalysing database...\n";
+ info('Reanalysing database');
pgsqlRunScript('ANALYSE');
$sDatabaseDate = getDatabaseDate($oDB);
pg_query($oDB->connection, 'TRUNCATE import_status');
if ($sDatabaseDate === false) {
- echo "WARNING: could not determine database date.\n";
+ warn('could not determine database date.');
} else {
$sSQL = "INSERT INTO import_status (lastimportdate) VALUES('".$sDatabaseDate."')";
pg_query($oDB->connection, $sSQL);
}
if ($aCMDResult['import-tiger-data']) {
+ info('Import Tiger data');
$bDidSomething = true;
$sTemplate = file_get_contents(CONST_BasePath.'/sql/tiger_import_start.sql');
echo "\n";
}
- echo "Creating indexes\n";
+ info('Creating indexes on Tiger data');
$sTemplate = file_get_contents(CONST_BasePath.'/sql/tiger_import_finish.sql');
$sTemplate = str_replace('{www-user}', CONST_Database_Web_User, $sTemplate);
$sTemplate = replace_tablespace(
}
if ($aCMDResult['calculate-postcodes'] || $aCMDResult['all']) {
+ info('Calculate Postcodes');
$bDidSomething = true;
$oDB =& getDB();
if (!pg_query($oDB->connection, 'TRUNCATE location_postcode')) {
$bDidSomething = true;
$sOutputFile = '';
$sBaseCmd = CONST_InstallPath.'/nominatim/nominatim -i -d '.$aDSNInfo['database'].' -P '.$aDSNInfo['port'].' -t '.$iInstances.$sOutputFile;
+ info('Index ranks 0 - 4');
passthruCheckReturn($sBaseCmd.' -R 4');
if (!$aCMDResult['index-noanalyse']) pgsqlRunScript('ANALYSE');
+ info('Index ranks 5 - 25');
passthruCheckReturn($sBaseCmd.' -r 5 -R 25');
if (!$aCMDResult['index-noanalyse']) pgsqlRunScript('ANALYSE');
+ info('Index ranks 26 - 30');
passthruCheckReturn($sBaseCmd.' -r 26');
- echo "Indexing postcodes....\n";
+ info('Index postcodes');
$oDB =& getDB();
$sSQL = 'UPDATE location_postcode SET indexed_status = 0';
if (!pg_query($oDB->connection, $sSQL)) fail(pg_last_error($oDB->connection));
}
if ($aCMDResult['create-search-indices'] || $aCMDResult['all']) {
- echo "Search indices\n";
+ info('Create Search indices');
$bDidSomething = true;
$sTemplate = file_get_contents(CONST_BasePath.'/sql/indices.src.sql');
}
if ($aCMDResult['create-country-names'] || $aCMDResult['all']) {
- echo 'Creating search index for default country names';
+ info('Create search index for default country names');
$bDidSomething = true;
pgsqlRunScript("select getorcreate_country(make_standard_name('uk'), 'gb')");
}
if ($aCMDResult['drop']) {
+ info('Drop tables only required for updates');
// The implementation is potentially a bit dangerous because it uses
// a positive selection of tables to keep, and deletes everything else.
// Including any tables that the unsuspecting user might have manually
if (!$bDidSomething) {
showUsage($aCMDOptions, true);
} else {
- echo "Setup finished.\n";
+ echo "Summary of warnings:\n\n";
+ repeatWarnings();
+ echo "\n";
+ info('Setup finished.');
}