X-Git-Url: https://git.openstreetmap.org/nominatim.git/blobdiff_plain/b11718699ede4fc152dae5f2dd14a27d739b4cf3..8fc2f9551bb056f2dcdd8f85f168ca956015e266:/utils/setup.php diff --git a/utils/setup.php b/utils/setup.php index c842ba33..bfc7c720 100755 --- a/utils/setup.php +++ b/utils/setup.php @@ -43,6 +43,26 @@ $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) @@ -89,9 +109,9 @@ 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. @@ -251,7 +271,7 @@ if ($aCMDResult['load-data'] || $aCMDResult['all']) { - echo "Load Data\n"; + echo "Drop old Data\n"; $bDidSomething = true; $oDB =& getDB(); @@ -287,17 +307,18 @@ 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++) { @@ -357,6 +378,8 @@ { $bDidSomething = true; + pgsqlRunScriptFile(CONST_BasePath.'/sql/tiger_import_start.sql'); + $aDBInstances = array(); for($i = 0; $i < $iInstances; $i++) { @@ -405,6 +428,9 @@ } echo "\n"; } + + echo "Creating indexes\n"; + pgsqlRunScriptFile(CONST_BasePath.'/sql/tiger_import_finish.sql'); } if ($aCMDResult['calculate-postcodes'] || $aCMDResult['all']) @@ -432,7 +458,12 @@ 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);