]> git.openstreetmap.org Git - nominatim.git/blobdiff - utils/setup.php
create_sql_functions() needs the commandline parameters
[nominatim.git] / utils / setup.php
index 60fe5dace6734689bfc03aa8e45bfc99f25ceef5..5a6366e70ccfbd5de3cfa8cf763ba7ac7fccf813 100755 (executable)
                {
                        echo "WARNING: external UK postcode table not found.\n";
                }
-               pgsqlRunScriptFile(CONST_BasePath.'/data/us_statecounty.sql');
-               pgsqlRunScriptFile(CONST_BasePath.'/data/us_state.sql');
-               pgsqlRunScriptFile(CONST_BasePath.'/data/us_postcode.sql');
+               if (CONST_Use_Extra_US_Postcodes)
+               {
+                       pgsqlRunScriptFile(CONST_BasePath.'/data/us_postcode.sql');
+               }
 
                if ($aCMDResult['no-partitions'])
                {
                echo "Functions\n";
                $bDidSomething = true;
                if (!file_exists(CONST_InstallPath.'/module/nominatim.so')) fail("nominatim module not built");
-               $sTemplate = file_get_contents(CONST_BasePath.'/sql/functions.sql');
-               $sTemplate = str_replace('{modulepath}', CONST_InstallPath.'/module', $sTemplate);
-               if ($aCMDResult['enable-diff-updates']) $sTemplate = str_replace('RETURN NEW; -- @DIFFUPDATES@', '--', $sTemplate);
-               if ($aCMDResult['enable-debug-statements']) $sTemplate = str_replace('--DEBUG:', '', $sTemplate);
-               if (CONST_Limit_Reindexing) $sTemplate = str_replace('--LIMIT INDEXING:', '', $sTemplate);
-               pgsqlRunScript($sTemplate);
+               create_sql_functions($aCMDResult);
        }
 
        if ($aCMDResult['create-tables'] || $aCMDResult['all'])
 
                // re-run the functions
                echo "Functions\n";
-               $sTemplate = file_get_contents(CONST_BasePath.'/sql/functions.sql');
-               $sTemplate = str_replace('{modulepath}',
-                                            CONST_InstallPath.'/module', $sTemplate);
-               pgsqlRunScript($sTemplate);
+               create_sql_functions($aCMDResult);
        }
 
        if ($aCMDResult['create-partition-tables'] || $aCMDResult['all'])
                $sSQL .= "from placex where postcode is not null group by calculated_country_code,postcode) as x";
                if (!pg_query($oDB->connection, $sSQL)) fail(pg_last_error($oDB->connection));
 
-               $sSQL = "insert into placex (osm_type,osm_id,class,type,postcode,calculated_country_code,geometry) ";
-               $sSQL .= "select 'P',nextval('seq_postcodes'),'place','postcode',postcode,'us',";
-               $sSQL .= "ST_SetSRID(ST_Point(x,y),4326) as geometry from us_postcode";
-               if (!pg_query($oDB->connection, $sSQL)) fail(pg_last_error($oDB->connection));
+               if (CONST_Use_Extra_US_Postcodes)
+               {
+                       $sSQL = "insert into placex (osm_type,osm_id,class,type,postcode,calculated_country_code,geometry) ";
+                       $sSQL .= "select 'P',nextval('seq_postcodes'),'place','postcode',postcode,'us',";
+                       $sSQL .= "ST_SetSRID(ST_Point(x,y),4326) as geometry from us_postcode";
+                       if (!pg_query($oDB->connection, $sSQL)) fail(pg_last_error($oDB->connection));
+               }
        }
 
        if ($aCMDResult['osmosis-init'] || ($aCMDResult['all'] && !$aCMDResult['drop'])) // no use doing osmosis-init when dropping update tables
                return $sSql;
        }
 
+       function create_sql_functions($aCMDResult)
+       {
+               $sTemplate = file_get_contents(CONST_BasePath.'/sql/functions.sql');
+               $sTemplate = str_replace('{modulepath}', CONST_InstallPath.'/module', $sTemplate);
+               if ($aCMDResult['enable-diff-updates'])
+               {
+                       $sTemplate = str_replace('RETURN NEW; -- %DIFFUPDATES%', '--', $sTemplate);
+               }
+               if ($aCMDResult['enable-debug-statements'])
+               {
+                       $sTemplate = str_replace('--DEBUG:', '', $sTemplate);
+               }
+               if (CONST_Limit_Reindexing)
+               {
+                       $sTemplate = str_replace('--LIMIT INDEXING:', '', $sTemplate);
+               }
+               if (!CONST_Use_US_Tiger_Data)
+               {
+                       $sTemplate = str_replace('-- %NOTIGERDATA% ', '', $sTemplate);
+               }
+               if (!CONST_Use_Aux_Location_data)
+               {
+                       $sTemplate = str_replace('-- %NOAUXDATA% ', '', $sTemplate);
+               }
+               pgsqlRunScript($sTemplate);
+
+       }
+