]> git.openstreetmap.org Git - nominatim.git/blobdiff - utils/setup.php
more partitioning work, os open data postcodes, country list fixes
[nominatim.git] / utils / setup.php
index 72dd9c9a12e40e09ba2afb08c2d02a50ff941729..5e40822309646ae138a30dfd0d50db2b8f3cac3b 100755 (executable)
        {
                $bDidSomething = true;
                pgsqlRunScriptFile(CONST_BasePath.'/sql/tables.sql');
+
+               // re-run the functions
+               $sTemplate = file_get_contents(CONST_BasePath.'/sql/functions.sql');
+               $sTemplate = str_replace('{modulepath}',CONST_BasePath.'/module', $sTemplate);
+               pgsqlRunScript($sTemplate);
        }
 
        if ($aCMDResult['create-partitions'] || isset($aCMDResult['all']))
        if ($aCMDResult['load-data'] || isset($aCMDResult['all']))
        {
                $bDidSomething = true;
-               pgsqlRunScriptFile(CONST_BasePath.'/sql/loaddata.sql');
+
+               $oDB =& getDB();
+               if (!pg_query($oDB->connection, 'TRUNCATE placex')) fail(pg_last_error($oDB->connection));
+               echo '.';
+               if (!pg_query($oDB->connection, 'TRUNCATE place_addressline')) fail(pg_last_error($oDB->connection));
+               echo '.';
+               if (!pg_query($oDB->connection, 'TRUNCATE location_area')) fail(pg_last_error($oDB->connection));
+               echo '.';
+               if (!pg_query($oDB->connection, 'DROP SEQUENCE seq_place')) fail(pg_last_error($oDB->connection));
+               echo '.';
+               if (!pg_query($oDB->connection, 'CREATE SEQUENCE seq_place start 100000')) fail(pg_last_error($oDB->connection));
+               echo '.';
+
+               $iInstances = 16;
+               $aDBInstances = array();
+               for($i = 0; $i < $iInstances; $i++)
+               {
+                       $aDBInstances[$i] =& getDB(true);
+                       $sSQL = 'insert into placex (osm_type, osm_id, class, type, name, admin_level, ';
+                       $sSQL .= 'housenumber, street, isin, postcode, country_code, extratags, ';
+                       $sSQL .= 'geometry) select * from place where osm_id % '.$iInstances.' = '.$i;
+                       if (!pg_send_query($aDBInstances[$i]->connection, $sSQL)) fail(pg_last_error($oDB->connection));
+               }
+               $bAnyBusy = true;
+               while($bAnyBusy)
+               {
+                       $bAnyBusy = false;
+                       for($i = 0; $i < $iInstances; $i++)
+                       {
+                               if (pg_connection_busy($aDBInstances[$i]->connection)) $bAnyBusy = true;
+                       }
+                       sleep(1);
+                       echo '.';
+               }
+               echo "\n";
        }
 
        if (!$bDidSomething)