]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib/setup/SetupClass.php
move postcode table setup to sql/
[nominatim.git] / lib / setup / SetupClass.php
index f430b6c9b5af2e39cf58765193ca0866976de06d..4e9daaf8dda9a8c4e1d667b773bae0b8e6fde0c4 100755 (executable)
@@ -148,7 +148,9 @@ class SetupFunctions
             // (aka we are running from the build dir).
             $sDest = CONST_InstallDir.'/module';
             if ($sDest != CONST_Default_ModulePath) {
-                mkdir($sDest);
+                if (!file_exists($sDest)) {
+                    mkdir($sDest);
+                }
                 if (!copy(CONST_Default_ModulePath.'/nominatim.so', $sDest.'/nominatim.so')) {
                     echo "Failed to copy database module to $sDest.";
                     exit(1);
@@ -156,8 +158,10 @@ class SetupFunctions
                 chmod($sDest.'/nominatim.so', 0755);
                 info("Database module installed at $sDest.");
             } else {
-                info("Running from build directory. Leaving database module as is.");
+                info('Running from build directory. Leaving database module as is.');
             }
+        } else {
+            info('Using database module from DATABASE_MODULE_PATH ('.getSetting('DATABASE_MODULE_PATH').').');
         }
         // Try accessing the C module, so we know early if something is wrong
         $this->checkModulePresence(); // raises exception on failure
@@ -169,22 +173,6 @@ class SetupFunctions
         }
         $this->pgsqlRunScriptFile(CONST_DataDir.'/data/country_name.sql');
         $this->pgsqlRunScriptFile(CONST_DataDir.'/data/country_osm_grid.sql.gz');
-        $this->pgsqlRunScriptFile(CONST_DataDir.'/data/gb_postcode_table.sql');
-        $this->pgsqlRunScriptFile(CONST_DataDir.'/data/us_postcode_table.sql');
-
-        $sPostcodeFilename = CONST_InstallDir.'/gb_postcode_data.sql.gz';
-        if (file_exists($sPostcodeFilename)) {
-            $this->pgsqlRunScriptFile($sPostcodeFilename);
-        } else {
-            warn('optional external GB postcode table file ('.$sPostcodeFilename.') not found. Skipping.');
-        }
-
-        $sPostcodeFilename = CONST_InstallDir.'/us_postcode_data.sql.gz';
-        if (file_exists($sPostcodeFilename)) {
-            $this->pgsqlRunScriptFile($sPostcodeFilename);
-        } else {
-            warn('optional external US postcode table file ('.$sPostcodeFilename.') not found. Skipping.');
-        }
 
         if ($this->bNoPartitions) {
             $this->pgsqlRunScript('update country_name set partition = 0');
@@ -517,6 +505,23 @@ class SetupFunctions
     public function calculatePostcodes($bCMDResultAll)
     {
         info('Calculate Postcodes');
+        $this->pgsqlRunScriptFile(CONST_DataDir.'/sql/postcode_tables.sql');
+
+        $sPostcodeFilename = CONST_InstallDir.'/gb_postcode_data.sql.gz';
+        if (file_exists($sPostcodeFilename)) {
+            $this->pgsqlRunScriptFile($sPostcodeFilename);
+        } else {
+            warn('optional external GB postcode table file ('.$sPostcodeFilename.') not found. Skipping.');
+        }
+
+        $sPostcodeFilename = CONST_InstallDir.'/us_postcode_data.sql.gz';
+        if (file_exists($sPostcodeFilename)) {
+            $this->pgsqlRunScriptFile($sPostcodeFilename);
+        } else {
+            warn('optional external US postcode table file ('.$sPostcodeFilename.') not found. Skipping.');
+        }
+
+
         $this->db()->exec('TRUNCATE location_postcode');
 
         $sSQL  = 'INSERT INTO location_postcode';