array('osmosis-init', '', 0, 1, 0, 0, 'bool', 'Generate default osmosis configuration'),
array('osmosis-init-date', '', 0, 1, 1, 1, 'string', 'Generate default osmosis configuration'),
array('index', '', 0, 1, 0, 0, 'bool', 'Index the data'),
- array('index-noanalyse', '', 0, 1, 0, 0, 'bool', 'Do not perform analyse opertions during index (EXPERT)'),
+ array('index-noanalyse', '', 0, 1, 0, 0, 'bool', 'Do not perform analyse operations during index (EXPERT)'),
array('index-output', '', 0, 1, 1, 1, 'string', 'File to dump index information to'),
array('create-search-indices', '', 0, 1, 0, 0, 'bool', 'Create additional indices required for search and update'),
array('create-website', '', 0, 1, 1, 1, 'realpath', 'Create symlinks to setup web directory'),
$bDidSomething = false;
- // This is a pretty hard core defult - the number of processors in the box - 1
+ // This is a pretty hard core default - the number of processors in the box - 1
$iInstances = isset($aCMDResult['threads'])?$aCMDResult['threads']:(getProcessorCount()-1);
if ($iInstances < 1)
{
echo "Please download and build osm2pgsql.\nIf it is already installed, check the path in your local settings (settings/local.php) file.\n";
fail("osm2pgsql not found in '$osm2pgsql'");
}
+ $osm2pgsql .= ' --tablespace-slim-index ssd --tablespace-main-index ssd --tablespace-main-data ssd --tablespace-slim-data data';
$osm2pgsql .= ' -lsc -O gazetteer --hstore';
- $osm2pgsql .= ' -C '.$iCacheMemory;
+ $osm2pgsql .= ' -C 16000';
$osm2pgsql .= ' -d '.$aDSNInfo['database'].' '.$aCMDResult['osm-file'];
- passthru($osm2pgsql);
+ passthruCheckReturn($osm2pgsql);
$oDB =& getDB();
$x = $oDB->getRow('select * from place limit 1');
if (!pg_query($oDB->connection, 'CREATE SEQUENCE seq_place start 100000')) fail(pg_last_error($oDB->connection));
echo '.';
+ $sSQL = 'select partition from country_name order by country_code';
+ $aPartitions = $oDB->getCol($sSQL);
+ if (PEAR::isError($aPartitions))
+ {
+ fail($aPartitions->getMessage());
+ }
+ $aPartitions[] = 0;
+ foreach($aPartitions as $sPartition)
+ {
+ if (!pg_query($oDB->connection, 'TRUNCATE location_road_'.$sPartition)) fail(pg_last_error($oDB->connection));
+ echo '.';
+ }
+
// pre-create the word list
if (!$aCMDResult['disable-token-precalc'])
{
echo '.';
}
echo "\n";
+ pgsqlRunScript('ALTER TABLE place SET TABLESPACE "data"');
echo "Reanalysing database...\n";
pgsqlRunScript('ANALYSE');
}
{
$bDidSomething = true;
+ pgsqlRunScriptFile(CONST_BasePath.'/sql/tiger_import_start.sql');
+
$aDBInstances = array();
for($i = 0; $i < $iInstances; $i++)
{
}
echo "\n";
}
+
+ echo "Creating indexes\n";
+ pgsqlRunScriptFile(CONST_BasePath.'/sql/tiger_import_finish.sql');
}
if ($aCMDResult['calculate-postcodes'] || $aCMDResult['all'])
$sOutputFile = '';
if (isset($aCMDResult['index-output'])) $sOutputFile = ' -F '.$aCMDResult['index-output'];
$sBaseCmd = CONST_BasePath.'/nominatim/nominatim -i -d '.$aDSNInfo['database'].' -t '.$iInstances.$sOutputFile;
- passthru($sBaseCmd.' -R 4');
+ passthruCheckReturn($sBaseCmd.' -R 4');
if (!$aCMDResult['index-noanalyse']) pgsqlRunScript('ANALYSE');
- passthru($sBaseCmd.' -r 5 -R 25');
+ passthruCheckReturn($sBaseCmd.' -r 5 -R 25');
if (!$aCMDResult['index-noanalyse']) pgsqlRunScript('ANALYSE');
- passthru($sBaseCmd.' -r 26');
+ passthruCheckReturn($sBaseCmd.' -r 26');
}
if ($aCMDResult['create-search-indices'] || $aCMDResult['all'])
{
if (!file_exists($sFilename)) fail('unable to find '.$sFilename);
- // Convert database DSN to psql paramaters
+ // Convert database DSN to psql parameters
$aDSNInfo = DB::parseDSN(CONST_Database_DSN);
if (!isset($aDSNInfo['port']) || !$aDSNInfo['port']) $aDSNInfo['port'] = 5432;
$sCMD = 'psql -p '.$aDSNInfo['port'].' -d '.$aDSNInfo['database'].' -f '.$sFilename;
function pgsqlRunScript($sScript)
{
- // Convert database DSN to psql paramaters
+ // Convert database DSN to psql parameters
$aDSNInfo = DB::parseDSN(CONST_Database_DSN);
if (!isset($aDSNInfo['port']) || !$aDSNInfo['port']) $aDSNInfo['port'] = 5432;
$sCMD = 'psql -p '.$aDSNInfo['port'].' -d '.$aDSNInfo['database'];
function pgsqlRunRestoreData($sDumpFile)
{
- // Convert database DSN to psql paramaters
+ // Convert database DSN to psql parameters
$aDSNInfo = DB::parseDSN(CONST_Database_DSN);
if (!isset($aDSNInfo['port']) || !$aDSNInfo['port']) $aDSNInfo['port'] = 5432;
$sCMD = 'pg_restore -p '.$aDSNInfo['port'].' -d '.$aDSNInfo['database'].' -Fc -a '.$sDumpFile;
function pgsqlRunDropAndRestore($sDumpFile)
{
- // Convert database DSN to psql paramaters
+ // Convert database DSN to psql parameters
$aDSNInfo = DB::parseDSN(CONST_Database_DSN);
if (!isset($aDSNInfo['port']) || !$aDSNInfo['port']) $aDSNInfo['port'] = 5432;
$sCMD = 'pg_restore -p '.$aDSNInfo['port'].' -d '.$aDSNInfo['database'].' -Fc --clean '.$sDumpFile;
proc_close($hProcess);
}
+
+ function passthruCheckReturn($cmd)
+ {
+ $result = -1;
+ passthru($cmd, $result);
+ if ($result != 0) fail('Error executing external command: '.$cmd);
+ }