$bDidSomething = false;
+ // Check if osm-file is set and points to a valid file if --all or --import-data is given
+ if ($aCMDResult['import-data'] || $aCMDResult['all'])
+ {
+ if (!isset($aCMDResult['osm-file']))
+ {
+ fail('missing --osm-file for data import');
+ }
+
+ if (!file_exists($aCMDResult['osm-file']))
+ {
+ fail('the path supplied to --osm-file does not exist');
+ }
+
+ if (!is_readable($aCMDResult['osm-file']))
+ {
+ fail('osm-file "'.$aCMDResult['osm-file'].'" not readable');
+ }
+ }
+
+
// 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)
passthru('createdb -E UTF-8 '.$aDSNInfo['database']);
}
- if ($aCMDResult['create-db'] || $aCMDResult['all'])
+ if ($aCMDResult['setup-db'] || $aCMDResult['all'])
{
- echo "Create DB (2)\n";
+ echo "Setup DB\n";
$bDidSomething = true;
// TODO: path detection, detection memory, etc.
if ($aCMDResult['load-data'] || $aCMDResult['all'])
{
- echo "Load Data\n";
+ echo "Drop old Data\n";
$bDidSomething = true;
$oDB =& getDB();
echo '.';
}
+ // used by getorcreate_word_id to ignore frequent partial words
+ if (!pg_query($oDB->connection, 'CREATE OR REPLACE FUNCTION get_maxwordfreq() RETURNS integer AS $$ SELECT '.CONST_Max_Word_Frequency.' as maxwordfreq; $$ LANGUAGE SQL IMMUTABLE')) fail(pg_last_error($oDB->connection));
+ echo ".\n";
+
// pre-create the word list
if (!$aCMDResult['disable-token-precalc'])
{
- if (!pg_query($oDB->connection, 'select count(make_keywords(v)) from (select distinct svals(name) as v from place) as w where v is not null;')) fail(pg_last_error($oDB->connection));
- echo '.';
- if (!pg_query($oDB->connection, 'select count(make_keywords(v)) from (select distinct postcode as v from place) as w where v is not null;')) fail(pg_last_error($oDB->connection));
- echo '.';
- if (!pg_query($oDB->connection, 'select count(getorcreate_housenumber_id(v)) from (select distinct housenumber as v from place where housenumber is not null) as w;')) fail(pg_last_error($oDB->connection));
- echo '.';
+ echo "Loading word list\n";
+ pgsqlRunScriptFile(CONST_BasePath.'/data/words.sql');
}
+ echo "Load Data\n";
$aDBInstances = array();
for($i = 0; $i < $iInstances; $i++)
{
if (!file_exists(CONST_Osmosis_Binary)) fail("please download osmosis");
if (file_exists(CONST_BasePath.'/settings/configuration.txt')) echo "settings/configuration.txt already exists\n";
- else passthru(CONST_Osmosis_Binary.' --read-replication-interval-init '.CONST_BasePath.'/settings');
+ else
+ {
+ passthru(CONST_Osmosis_Binary.' --read-replication-interval-init '.CONST_BasePath.'/settings');
+ // server layout changed afer license change, fix path to minutely diffs
+ passthru("sed -i 's:minute-replicate:replication/minute:' ".CONST_BasePath.'/settings/configuration.txt');
+ }
$sDate = $aCMDResult['osmosis-init-date'];
$aDate = date_parse_from_format("Y-m-d\TH-i", $sDate);