]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib/setup/SetupClass.php
Merge remote-tracking branch 'upstream/master'
[nominatim.git] / lib / setup / SetupClass.php
index 38f361e74e72b3952a4363b44a4a82601fe584d2..34ece8e0f7567d327793a002782c320fb2bcebca 100755 (executable)
@@ -10,6 +10,7 @@ class SetupFunctions
     protected $iInstances;
     protected $sModulePath;
     protected $aDSNInfo;
     protected $iInstances;
     protected $sModulePath;
     protected $aDSNInfo;
+    protected $bQuiet;
     protected $bVerbose;
     protected $sIgnoreErrors;
     protected $bEnableDiffUpdates;
     protected $bVerbose;
     protected $sIgnoreErrors;
     protected $bEnableDiffUpdates;
@@ -49,6 +50,7 @@ class SetupFunctions
         }
 
         // setting member variables based on command line options stored in $aCMDResult
         }
 
         // setting member variables based on command line options stored in $aCMDResult
+        $this->bQuiet = $aCMDResult['quiet'];
         $this->bVerbose = $aCMDResult['verbose'];
 
         //setting default values which are not set by the update.php array
         $this->bVerbose = $aCMDResult['verbose'];
 
         //setting default values which are not set by the update.php array
@@ -235,6 +237,16 @@ class SetupFunctions
         $oAlParser->createTable($this->oDB, 'address_levels');
     }
 
         $oAlParser->createTable($this->oDB, 'address_levels');
     }
 
+    public function createTableTriggers()
+    {
+        info('Create Tables');
+
+        $sTemplate = file_get_contents(CONST_BasePath.'/sql/table-triggers.sql');
+        $sTemplate = $this->replaceSqlPatterns($sTemplate);
+
+        $this->pgsqlRunScript($sTemplate, false);
+    }
+
     public function createPartitionTables()
     {
         info('Create Partition Tables');
     public function createPartitionTables()
     {
         info('Create Partition Tables');
@@ -508,10 +520,16 @@ class SetupFunctions
     public function index($bIndexNoanalyse)
     {
         $sOutputFile = '';
     public function index($bIndexNoanalyse)
     {
         $sOutputFile = '';
-        $sBaseCmd = CONST_InstallPath.'/nominatim/nominatim -i'
+        $sBaseCmd = CONST_BasePath.'/nominatim/nominatim.py'
             .' -d '.escapeshellarg($this->aDSNInfo['database'])
             .' -P '.escapeshellarg($this->aDSNInfo['port'])
             .' -t '.escapeshellarg($this->iInstances.$sOutputFile);
             .' -d '.escapeshellarg($this->aDSNInfo['database'])
             .' -P '.escapeshellarg($this->aDSNInfo['port'])
             .' -t '.escapeshellarg($this->iInstances.$sOutputFile);
+        if (!$this->bQuiet) {
+            $sBaseCmd .= ' -v';
+        }
+        if ($this->bVerbose) {
+            $sBaseCmd .= ' -v';
+        }
         if (isset($this->aDSNInfo['hostspec'])) {
             $sBaseCmd .= ' -H '.escapeshellarg($this->aDSNInfo['hostspec']);
         }
         if (isset($this->aDSNInfo['hostspec'])) {
             $sBaseCmd .= ' -H '.escapeshellarg($this->aDSNInfo['hostspec']);
         }
@@ -648,7 +666,21 @@ class SetupFunctions
 
     private function createSqlFunctions()
     {
 
     private function createSqlFunctions()
     {
-        $sTemplate = file_get_contents(CONST_BasePath.'/sql/functions.sql');
+        $sBasePath = CONST_BasePath.'/sql/functions/';
+        $sTemplate = file_get_contents($sBasePath.'utils.sql');
+        $sTemplate .= file_get_contents($sBasePath.'normalization.sql');
+        $sTemplate .= file_get_contents($sBasePath.'importance.sql');
+        $sTemplate .= file_get_contents($sBasePath.'address_lookup.sql');
+        $sTemplate .= file_get_contents($sBasePath.'interpolation.sql');
+        if ($this->oDB->tableExists('place')) {
+            $sTemplate .= file_get_contents($sBasePath.'place_triggers.sql');
+        }
+        if ($this->oDB->tableExists('placex')) {
+            $sTemplate .= file_get_contents($sBasePath.'placex_triggers.sql');
+        }
+        if ($this->oDB->tableExists('location_postcode')) {
+            $sTemplate .= file_get_contents($sBasePath.'postcode_triggers.sql');
+        }
         $sTemplate = str_replace('{modulepath}', $this->sModulePath, $sTemplate);
         if ($this->bEnableDiffUpdates) {
             $sTemplate = str_replace('RETURN NEW; -- %DIFFUPDATES%', '--', $sTemplate);
         $sTemplate = str_replace('{modulepath}', $this->sModulePath, $sTemplate);
         if ($this->bEnableDiffUpdates) {
             $sTemplate = str_replace('RETURN NEW; -- %DIFFUPDATES%', '--', $sTemplate);