]> git.openstreetmap.org Git - nominatim.git/commitdiff
reorganise path settings in config
authorSarah Hoffmann <lonvia@denofr.de>
Tue, 15 Dec 2020 09:09:55 +0000 (10:09 +0100)
committerSarah Hoffmann <lonvia@denofr.de>
Sat, 19 Dec 2020 13:33:04 +0000 (14:33 +0100)
CONST_BasePath is split into separate configuration variables
for binaries, libraries and data. These variables as well as
the installation path are now set in the executable directly and
no longer configurable via project settings.

This is the first step towards an installable software. The
executables should know per installation where to find their
necessary data to execute. Project configuration needs to be
restricted to settings that really concern the specific Nominatim
installation.

33 files changed:
CMakeLists.txt
cmake/script.tmpl
cmake/website.tmpl
lib/AddressDetails.php
lib/DB.php
lib/Geocode.php
lib/PlaceLookup.php
lib/ReverseGeocode.php
lib/SearchContext.php
lib/SearchDescription.php
lib/TokenList.php
lib/TokenSpecialTerm.php
lib/cmd.php
lib/init-website.php
lib/init.php
lib/setup/SetupClass.php
settings/defaults.php
test/bdd/environment.py
utils/check_import_finished.php
utils/country_languages.php
utils/export.php
utils/query.php
utils/setup.php
utils/specialphrases.php
utils/update.php
utils/warm.php
website/deletable.php
website/details.php
website/lookup.php
website/polygons.php
website/reverse.php
website/search.php
website/status.php

index 59d9e3a632ae7ad8ada5aa7b2542d79cde99be6b..79551ce76a5f12913d81d614e9f7fb6c96c6095d 100644 (file)
@@ -96,20 +96,20 @@ endif()
 
 if (BUILD_IMPORTER)
    set(CUSTOMSCRIPTS
-       utils/check_import_finished.php
-       utils/country_languages.php
-       utils/importWikipedia.php
-       utils/export.php
-       utils/query.php
-       utils/setup.php
-       utils/specialphrases.php
-       utils/update.php
-       utils/warm.php
+       check_import_finished.php
+       country_languages.php
+       importWikipedia.php
+       export.php
+       query.php
+       setup.php
+       specialphrases.php
+       update.php
+       warm.php
       )
 
    foreach (script_source ${CUSTOMSCRIPTS})
        configure_file(${PROJECT_SOURCE_DIR}/cmake/script.tmpl
-                      ${PROJECT_BINARY_DIR}/${script_source})
+                      ${PROJECT_BINARY_DIR}/utils/${script_source})
    endforeach()
 endif()
 
@@ -119,27 +119,20 @@ endif()
 
 if (BUILD_API)
    set(WEBSITESCRIPTS
-       website/deletable.php
-       website/details.php
-       website/lookup.php
-       website/polygons.php
-       website/reverse.php
-       website/search.php
-       website/status.php
+       deletable.php
+       details.php
+       lookup.php
+       polygons.php
+       reverse.php
+       search.php
+       status.php
    )
 
    foreach (script_source ${WEBSITESCRIPTS})
        configure_file(${PROJECT_SOURCE_DIR}/cmake/website.tmpl
-                      ${PROJECT_BINARY_DIR}/${script_source})
+                      ${PROJECT_BINARY_DIR}/website/${script_source})
    endforeach()
 
-   set(WEBPATHS css images js)
-
-   foreach (wp ${WEBPATHS})
-       execute_process(
-           COMMAND ln -sf ${PROJECT_SOURCE_DIR}/website/${wp} ${PROJECT_BINARY_DIR}/website/
-       )
-   endforeach()
 
    add_custom_target(serve
            php -S 127.0.0.1:8088
index 8146ca8b5880b2376d996bbfffe6b9e166617d60..1b0cab64a97ef2ddc90454fbd5816df8c78f7440 100755 (executable)
@@ -1,4 +1,9 @@
 #!@PHP_BIN@ -Cq
 <?php
-require_once(dirname(dirname(__FILE__)).'/settings/settings.php');
-require_once(CONST_BasePath.'/@script_source@');
+@define('CONST_BinDir', '@CMAKE_SOURCE_DIR@/utils');
+@define('CONST_LibDir', '@CMAKE_SOURCE_DIR@/lib');
+@define('CONST_DataDir', '@CMAKE_SOURCE_DIR@');
+@define('CONST_InstallDir', '@CMAKE_BINARY_DIR@');
+
+require_once(CONST_InstallDir.'/settings/settings.php');
+require_once(CONST_BinDir.'/@script_source@');
index 268ded39f12284f51a8ae25842f3d3eecca01b0f..8194a8eb5ea5c787221248f8a25b07622fe91103 100755 (executable)
@@ -1,5 +1,8 @@
 <?php
 @define('CONST_Debug', (isset($_GET['debug']) && $_GET['debug']));
-require_once(dirname(dirname(__FILE__)).'/settings/settings-frontend.php');
+@define('CONST_LibDir', '@CMAKE_SOURCE_DIR@/lib');
+@define('CONST_DataDir', '@CMAKE_SOURCE_DIR@');
+@define('CONST_InstallDir', '@CMAKE_BINARY_DIR@');
+require_once(CONST_InstallDir.'/settings/settings-frontend.php');
 
-require_once(CONST_BasePath.'/@script_source@');
+require_once('@CMAKE_SOURCE_DIR@/website/@script_source@');
index a27d3e797feefd123bbd11ab52c48a630ac14929..3d17ede51cb4d3c605f3d166dca58af542c7a15f 100644 (file)
@@ -2,7 +2,7 @@
 
 namespace Nominatim;
 
-require_once(CONST_BasePath.'/lib/ClassTypes.php');
+require_once(CONST_LibDir.'/ClassTypes.php');
 
 /**
  * Detailed list of address parts for a single result
index 38b3e27ec8102f5ce8daca912a263ee62a311a3d..2b53dba8254dbd230630a1a41ceefb02d4221cff 100644 (file)
@@ -2,7 +2,7 @@
 
 namespace Nominatim;
 
-require_once(CONST_BasePath.'/lib/DatabaseError.php');
+require_once(CONST_LibDir.'/DatabaseError.php');
 
 /**
  * Uses PDO to access the database specified in the CONST_Database_DSN
index ed02848eac4c2c846ea1a655089caa75aca879cd..57e9510f7fc171c2aaa78c73343041bbc47ddfee 100644 (file)
@@ -2,12 +2,12 @@
 
 namespace Nominatim;
 
-require_once(CONST_BasePath.'/lib/PlaceLookup.php');
-require_once(CONST_BasePath.'/lib/Phrase.php');
-require_once(CONST_BasePath.'/lib/ReverseGeocode.php');
-require_once(CONST_BasePath.'/lib/SearchDescription.php');
-require_once(CONST_BasePath.'/lib/SearchContext.php');
-require_once(CONST_BasePath.'/lib/TokenList.php');
+require_once(CONST_LibDir.'/PlaceLookup.php');
+require_once(CONST_LibDir.'/Phrase.php');
+require_once(CONST_LibDir.'/ReverseGeocode.php');
+require_once(CONST_LibDir.'/SearchDescription.php');
+require_once(CONST_LibDir.'/SearchContext.php');
+require_once(CONST_LibDir.'/TokenList.php');
 
 class Geocode
 {
index a2f39ea348ba466e21111a1e6f65395eb8343f57..58510e266f5a99da705c5ca2303d5c4d3a59f26c 100644 (file)
@@ -2,8 +2,8 @@
 
 namespace Nominatim;
 
-require_once(CONST_BasePath.'/lib/AddressDetails.php');
-require_once(CONST_BasePath.'/lib/Result.php');
+require_once(CONST_LibDir.'/AddressDetails.php');
+require_once(CONST_LibDir.'/Result.php');
 
 class PlaceLookup
 {
index 032f442eb03b48051e14ee977efc54883373c3bd..b420e5dd99f8ba69fadc0488684784a7ffcb3794 100644 (file)
@@ -2,7 +2,7 @@
 
 namespace Nominatim;
 
-require_once(CONST_BasePath.'/lib/Result.php');
+require_once(CONST_LibDir.'/Result.php');
 
 class ReverseGeocode
 {
index c2898d274b44266aa567fb74cddfd9790a67df13..8316a01288c58673332640d72e35ef3bbb506ddf 100644 (file)
@@ -2,7 +2,7 @@
 
 namespace Nominatim;
 
-require_once(CONST_BasePath.'/lib/lib.php');
+require_once(CONST_LibDir.'/lib.php');
 
 
 /**
index 15c6bf2302d3304fa2480bc9ebda8d9b5755e767..f010606355144c418de9162747c8fbf104671c56 100644 (file)
@@ -2,9 +2,9 @@
 
 namespace Nominatim;
 
-require_once(CONST_BasePath.'/lib/SpecialSearchOperator.php');
-require_once(CONST_BasePath.'/lib/SearchContext.php');
-require_once(CONST_BasePath.'/lib/Result.php');
+require_once(CONST_LibDir.'/SpecialSearchOperator.php');
+require_once(CONST_LibDir.'/SearchContext.php');
+require_once(CONST_LibDir.'/Result.php');
 
 /**
  * Description of a single interpretation of a search query.
index 1b6a1dcf37f7629667d6a388d4052ff81cc3e1ed..a419da6a9ad3429bc9087070038d491392ba1785 100644 (file)
@@ -2,12 +2,12 @@
 
 namespace Nominatim;
 
-require_once(CONST_BasePath.'/lib/TokenCountry.php');
-require_once(CONST_BasePath.'/lib/TokenHousenumber.php');
-require_once(CONST_BasePath.'/lib/TokenPostcode.php');
-require_once(CONST_BasePath.'/lib/TokenSpecialTerm.php');
-require_once(CONST_BasePath.'/lib/TokenWord.php');
-require_once(CONST_BasePath.'/lib/SpecialSearchOperator.php');
+require_once(CONST_LibDir.'/TokenCountry.php');
+require_once(CONST_LibDir.'/TokenHousenumber.php');
+require_once(CONST_LibDir.'/TokenPostcode.php');
+require_once(CONST_LibDir.'/TokenSpecialTerm.php');
+require_once(CONST_LibDir.'/TokenWord.php');
+require_once(CONST_LibDir.'/SpecialSearchOperator.php');
 
 /**
  * Saves information about the tokens that appear in a search query.
index 64e4b3d4786b591640be21c84dccdb25ece8e70a..b2c312ec90e53d8a52b022aeb01ab057059fbd3f 100644 (file)
@@ -2,7 +2,7 @@
 
 namespace Nominatim\Token;
 
-require_once(CONST_BasePath.'/lib/SpecialSearchOperator.php');
+require_once(CONST_LibDir.'/SpecialSearchOperator.php');
 
 /**
  * A word token describing a place type.
index 72b666088d1248b601d3edcfad521e99c89da139..3eac3e8f5c5a0c0bc108762d48003d454a857e50 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-require_once(CONST_BasePath.'/lib/Shell.php');
+require_once(CONST_LibDir.'/Shell.php');
 
 function getCmdOpt($aArg, $aSpec, &$aResult, $bExitOnError = false, $bExitOnUnknown = false)
 {
index 302a94787cc834e2468c0959b8e4a2c5bf8edbf3..f2d529800f474bc49853b211731f26de91dc0e6e 100644 (file)
@@ -20,7 +20,7 @@ function exception_handler_json($exception)
 {
     http_response_code($exception->getCode());
     header('Content-type: application/json; charset=utf-8');
-    include(CONST_BasePath.'/lib/template/error-json.php');
+    include(CONST_LibDir.'/template/error-json.php');
     exit();
 }
 
@@ -29,7 +29,7 @@ function exception_handler_xml($exception)
     http_response_code($exception->getCode());
     header('Content-type: text/xml; charset=utf-8');
     echo '<?xml version="1.0" encoding="UTF-8" ?>'."\n";
-    include(CONST_BasePath.'/lib/template/error-xml.php');
+    include(CONST_LibDir.'/template/error-xml.php');
     exit();
 }
 
index 082d1bf58dedb7665eb9c62953fafa607a6cfa07..cc50aaf340102854c3090297d9dc4c37e51ea79a 100644 (file)
@@ -1,4 +1,4 @@
 <?php
 
-require_once(CONST_BasePath.'/lib/lib.php');
-require_once(CONST_BasePath.'/lib/DB.php');
+require_once(CONST_LibDir.'/lib.php');
+require_once(CONST_LibDir.'/DB.php');
index f16c9e60cc3a22bcc713046cade8b791a5fc9136..6114689fb3bd79feb48d0ff107e49daee06381fd 100755 (executable)
@@ -2,8 +2,8 @@
 
 namespace Nominatim\Setup;
 
-require_once(CONST_BasePath.'/lib/setup/AddressLevelParser.php');
-require_once(CONST_BasePath.'/lib/Shell.php');
+require_once(CONST_LibDir.'/setup/AddressLevelParser.php');
+require_once(CONST_LibDir.'/Shell.php');
 
 class SetupFunctions
 {
@@ -140,24 +140,24 @@ class SetupFunctions
         // Try accessing the C module, so we know early if something is wrong
         checkModulePresence(); // raises exception on failure
 
-        if (!file_exists(CONST_ExtraDataPath.'/country_osm_grid.sql.gz')) {
+        if (!file_exists(CONST_DataDir.'/data/country_osm_grid.sql.gz')) {
             echo 'Error: you need to download the country_osm_grid first:';
-            echo "\n    wget -O ".CONST_ExtraDataPath."/country_osm_grid.sql.gz https://www.nominatim.org/data/country_grid.sql.gz\n";
+            echo "\n    wget -O ".CONST_DataDir."/data/country_osm_grid.sql.gz https://www.nominatim.org/data/country_grid.sql.gz\n";
             exit(1);
         }
-        $this->pgsqlRunScriptFile(CONST_BasePath.'/data/country_name.sql');
-        $this->pgsqlRunScriptFile(CONST_ExtraDataPath.'/country_osm_grid.sql.gz');
-        $this->pgsqlRunScriptFile(CONST_BasePath.'/data/gb_postcode_table.sql');
-        $this->pgsqlRunScriptFile(CONST_BasePath.'/data/us_postcode_table.sql');
+        $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_BasePath.'/data/gb_postcode_data.sql.gz';
+        $sPostcodeFilename = CONST_DataDir.'/data/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_BasePath.'/data/us_postcode_data.sql.gz';
+        $sPostcodeFilename = CONST_DataDir.'/data/us_postcode_data.sql.gz';
         if (file_exists($sPostcodeFilename)) {
             $this->pgsqlRunScriptFile($sPostcodeFilename);
         } else {
@@ -243,7 +243,7 @@ class SetupFunctions
     {
         info('Create Tables');
 
-        $sTemplate = file_get_contents(CONST_BasePath.'/sql/tables.sql');
+        $sTemplate = file_get_contents(CONST_DataDir.'/sql/tables.sql');
         $sTemplate = $this->replaceSqlPatterns($sTemplate);
 
         $this->pgsqlRunScript($sTemplate, false);
@@ -260,7 +260,7 @@ class SetupFunctions
     {
         info('Create Tables');
 
-        $sTemplate = file_get_contents(CONST_BasePath.'/sql/table-triggers.sql');
+        $sTemplate = file_get_contents(CONST_DataDir.'/sql/table-triggers.sql');
         $sTemplate = $this->replaceSqlPatterns($sTemplate);
 
         $this->pgsqlRunScript($sTemplate, false);
@@ -270,7 +270,7 @@ class SetupFunctions
     {
         info('Create Partition Tables');
 
-        $sTemplate = file_get_contents(CONST_BasePath.'/sql/partition-tables.src.sql');
+        $sTemplate = file_get_contents(CONST_DataDir.'/sql/partition-tables.src.sql');
         $sTemplate = $this->replaceSqlPatterns($sTemplate);
 
         $this->pgsqlRunPartitionScript($sTemplate);
@@ -280,7 +280,7 @@ class SetupFunctions
     {
         info('Create Partition Functions');
 
-        $sTemplate = file_get_contents(CONST_BasePath.'/sql/partition-functions.src.sql');
+        $sTemplate = file_get_contents(CONST_DataDir.'/sql/partition-functions.src.sql');
         $this->pgsqlRunPartitionScript($sTemplate);
     }
 
@@ -342,7 +342,7 @@ class SetupFunctions
         // pre-create the word list
         if (!$bDisableTokenPrecalc) {
             info('Loading word list');
-            $this->pgsqlRunScriptFile(CONST_BasePath.'/data/words.sql');
+            $this->pgsqlRunScriptFile(CONST_DataDir.'/data/words.sql');
         }
 
         info('Load Data');
@@ -434,7 +434,7 @@ class SetupFunctions
             warn('Tiger data import selected but no files found in path '.CONST_Tiger_Data_Path);
             return;
         }
-        $sTemplate = file_get_contents(CONST_BasePath.'/sql/tiger_import_start.sql');
+        $sTemplate = file_get_contents(CONST_DataDir.'/sql/tiger_import_start.sql');
         $sTemplate = $this->replaceSqlPatterns($sTemplate);
 
         $this->pgsqlRunScript($sTemplate, false);
@@ -488,7 +488,7 @@ class SetupFunctions
         }
 
         info('Creating indexes on Tiger data');
-        $sTemplate = file_get_contents(CONST_BasePath.'/sql/tiger_import_finish.sql');
+        $sTemplate = file_get_contents(CONST_DataDir.'/sql/tiger_import_finish.sql');
         $sTemplate = $this->replaceSqlPatterns($sTemplate);
 
         $this->pgsqlRunScript($sTemplate, false);
@@ -544,7 +544,7 @@ class SetupFunctions
     {
         checkModulePresence(); // raises exception on failure
 
-        $oBaseCmd = (new \Nominatim\Shell(CONST_BasePath.'/nominatim/nominatim.py'))
+        $oBaseCmd = (new \Nominatim\Shell(CONST_DataDir.'/nominatim/nominatim.py'))
                     ->addParams('--database', $this->aDSNInfo['database'])
                     ->addParams('--port', $this->aDSNInfo['port'])
                     ->addParams('--threads', $this->iInstances);
@@ -616,12 +616,12 @@ class SetupFunctions
             $this->db()->exec("DROP INDEX $sIndexName;");
         }
 
-        $sTemplate = file_get_contents(CONST_BasePath.'/sql/indices.src.sql');
+        $sTemplate = file_get_contents(CONST_DataDir.'/sql/indices.src.sql');
         if (!$this->bDrop) {
-            $sTemplate .= file_get_contents(CONST_BasePath.'/sql/indices_updates.src.sql');
+            $sTemplate .= file_get_contents(CONST_DataDir.'/sql/indices_updates.src.sql');
         }
         if (!$this->dbReverseOnly()) {
-            $sTemplate .= file_get_contents(CONST_BasePath.'/sql/indices_search.src.sql');
+            $sTemplate .= file_get_contents(CONST_DataDir.'/sql/indices_search.src.sql');
         }
         $sTemplate = $this->replaceSqlPatterns($sTemplate);
 
@@ -709,10 +709,9 @@ class SetupFunctions
      */
     public function setupWebsite()
     {
-        $rOutputFile = fopen(CONST_InstallPath.'/settings/settings-frontend.php', 'w');
+        $rOutputFile = fopen(CONST_InstallDir.'/settings/settings-frontend.php', 'w');
 
         fwrite($rOutputFile, "<?php
-@define('CONST_BasePath', '".CONST_BasePath."');
 if (file_exists(getenv('NOMINATIM_SETTINGS'))) require_once(getenv('NOMINATIM_SETTINGS'));
 
 @define('CONST_Database_DSN', '".CONST_Database_DSN."');
@@ -732,7 +731,7 @@ if (file_exists(getenv('NOMINATIM_SETTINGS'))) require_once(getenv('NOMINATIM_SE
 @define('CONST_Use_US_Tiger_Data', ".(CONST_Use_US_Tiger_Data ? 'true' : 'false').");
 @define('CONST_MapIcon_URL', ".(CONST_MapIcon_URL ? ("'".CONST_MapIcon_URL."'") : 'false').');
 ');
-        info(CONST_InstallPath.'/settings/settings-frontend.php has been set up successfully');
+        info(CONST_InstallDir.'/settings/settings-frontend.php has been set up successfully');
     }
 
     /**
@@ -775,7 +774,7 @@ if (file_exists(getenv('NOMINATIM_SETTINGS'))) require_once(getenv('NOMINATIM_SE
 
     private function createSqlFunctions()
     {
-        $sBasePath = CONST_BasePath.'/sql/functions/';
+        $sBasePath = CONST_DataDir.'/sql/functions/';
         $sTemplate = file_get_contents($sBasePath.'utils.sql');
         $sTemplate .= file_get_contents($sBasePath.'normalization.sql');
         $sTemplate .= file_get_contents($sBasePath.'ranking.sql');
index 2ecbb5141fc9911d69367f3577dfe713e44919c5..49c2d217732bc37f9de5c974fc5c4eeec51d4227 100644 (file)
@@ -1,13 +1,11 @@
 <?php
-@define('CONST_BasePath', '@CMAKE_SOURCE_DIR@');
-@define('CONST_InstallPath', '@CMAKE_BINARY_DIR@');
 if (file_exists(getenv('NOMINATIM_SETTINGS'))) require_once(getenv('NOMINATIM_SETTINGS'));
-if (file_exists(CONST_InstallPath.'/settings/local.php')) require_once(CONST_InstallPath.'/settings/local.php');
+if (file_exists(CONST_InstallDir.'/settings/local.php')) require_once(CONST_InstallDir.'/settings/local.php');
 
 // General settings
 @define('CONST_Database_DSN', 'pgsql:dbname=nominatim'); // or add ;host=...;port=...;user=...;password=...
 @define('CONST_Database_Web_User', 'www-data');
-@define('CONST_Database_Module_Path', CONST_InstallPath.'/module');
+@define('CONST_Database_Module_Path', CONST_InstallDir.'/module');
 @define('CONST_Max_Word_Frequency', '50000');
 @define('CONST_Limit_Reindexing', true);
 // Restrict search languages.
@@ -40,14 +38,13 @@ if (file_exists(CONST_InstallPath.'/settings/local.php')) require_once(CONST_Ins
 @define('CONST_HTTP_Proxy_Password', '');
 
 // Paths
-@define('CONST_ExtraDataPath', CONST_BasePath.'/data');
-@define('CONST_Osm2pgsql_Binary', CONST_InstallPath.'/osm2pgsql/osm2pgsql');
+@define('CONST_Osm2pgsql_Binary', CONST_InstallDir.'/osm2pgsql/osm2pgsql');
 @define('CONST_Pyosmium_Binary', '@PYOSMIUM_PATH@');
-@define('CONST_Tiger_Data_Path', CONST_ExtraDataPath.'/tiger');
-@define('CONST_Wikipedia_Data_Path', CONST_ExtraDataPath);
-@define('CONST_Phrase_Config', CONST_BasePath.'/settings/phrase_settings.php');
-@define('CONST_Address_Level_Config', CONST_BasePath.'/settings/address-levels.json');
-@define('CONST_Import_Style', CONST_BasePath.'/settings/import-full.style');
+@define('CONST_Tiger_Data_Path', CONST_DataDir.'/data/tiger');
+@define('CONST_Wikipedia_Data_Path', CONST_DataDir);
+@define('CONST_Phrase_Config', CONST_DataDir.'/settings/phrase_settings.php');
+@define('CONST_Address_Level_Config', CONST_DataDir.'/settings/address-levels.json');
+@define('CONST_Import_Style', CONST_DataDir.'/settings/import-full.style');
 
 // osm2pgsql settings
 @define('CONST_Osm2pgsql_Flatnode_File', null);
index f0658c335f95530cce4a2d82e6e268e7e6db7030..ba18ef03644c308273746ecf89c6f1eafbd5b60e 100644 (file)
@@ -82,7 +82,8 @@ class NominatimEnvironment(object):
                  (';password=' + self.db_pass) if self.db_pass else ''
                  ))
         f.write("@define('CONST_Osm2pgsql_Flatnode_File', null);\n")
-        f.write("@define('CONST_Import_Style', CONST_BasePath.'/settings/import-full.style');\n")
+        f.write("@define('CONST_Import_Style', CONST_DataDir.'/settings/import-full.style');\n")
+        f.write("@define('CONST_Use_US_Tiger_Data', true);\n")
         f.close()
 
     def cleanup(self):
index 5ec99b81eb2a8164251a12b1888cdc4b0e50ceb5..1eb012d475182d60ac36dff9aa0f9d8fdcfcd101 100755 (executable)
@@ -1,6 +1,6 @@
 <?php
 
-require_once(CONST_BasePath.'/lib/init-cmd.php');
+require_once(CONST_LibDir.'/init-cmd.php');
 
 $term_colors = array(
                 'green' => "\033[92m",
index 63f6525c0b6bf6ba12e7f4177f57b8449c27d577..c9aa391b1490c7c2c9a7a2a24b1918dbd932b400 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-require_once(CONST_BasePath.'/lib/init-cmd.php');
+require_once(CONST_LibDir.'/init-cmd.php');
 
 ini_set('memory_limit', '800M');
 ini_set('display_errors', 'stderr');
index ef55aab27ecb4b48514f782a95af44bcc2e18965..3cf9c651b17be381418da34545946234f4bc59e4 100644 (file)
@@ -3,8 +3,8 @@
     // from a running nominatim instance as CSV data
 
 
-    require_once(CONST_BasePath.'/lib/init-cmd.php');
-    require_once(CONST_BasePath.'/lib/ParameterParser.php');
+    require_once(CONST_LibDir.'/init-cmd.php');
+    require_once(CONST_LibDir.'/ParameterParser.php');
     ini_set('memory_limit', '800M');
 
     $aCMDOptions = array(
index 6068c7c00af9efbd18f68db0fd021a17808472b9..aa7361abd9201c8426cfba0c5f962ab221487d11 100644 (file)
@@ -1,8 +1,8 @@
 <?php
 
-require_once(CONST_BasePath.'/lib/init-cmd.php');
-require_once(CONST_BasePath.'/lib/Geocode.php');
-require_once(CONST_BasePath.'/lib/ParameterParser.php');
+require_once(CONST_LibDir.'/init-cmd.php');
+require_once(CONST_LibDir.'/Geocode.php');
+require_once(CONST_LibDir.'/ParameterParser.php');
 ini_set('memory_limit', '800M');
 
 $aCMDOptions
index 7f476d5c7eb72972d539ba9eac170ddfe3b09e54..82c821eb0a93b247b7002f6eec037cbba4b45f33 100644 (file)
@@ -1,8 +1,8 @@
 <?php
 
-require_once(CONST_BasePath.'/lib/init-cmd.php');
-require_once(CONST_BasePath.'/lib/setup/SetupClass.php');
-require_once(CONST_BasePath.'/lib/setup_functions.php');
+require_once(CONST_LibDir.'/init-cmd.php');
+require_once(CONST_LibDir.'/setup/SetupClass.php');
+require_once(CONST_LibDir.'/setup_functions.php');
 ini_set('memory_limit', '800M');
 
 use Nominatim\Setup\SetupFunctions as SetupFunctions;
index 9e6c9d76c757a38c70ba4a722207881c13368e98..d6979d582a422a1ceafe2166028b443c40488ecc 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-require_once(CONST_BasePath.'/lib/init-cmd.php');
+require_once(CONST_LibDir.'/init-cmd.php');
 ini_set('memory_limit', '800M');
 ini_set('display_errors', 'stderr');
 
index 135bf19361e0e54c8694de19be422ea48cd8e652..7e020b4291080804af10c2acd1bca024eec3d527 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 
-require_once(CONST_BasePath.'/lib/init-cmd.php');
-require_once(CONST_BasePath.'/lib/setup_functions.php');
-require_once(CONST_BasePath.'/lib/setup/SetupClass.php');
-require_once(CONST_BasePath.'/lib/setup/AddressLevelParser.php');
+require_once(CONST_LibDir.'/init-cmd.php');
+require_once(CONST_LibDir.'/setup_functions.php');
+require_once(CONST_LibDir.'/setup/SetupClass.php');
+require_once(CONST_LibDir.'/setup/AddressLevelParser.php');
 
 ini_set('memory_limit', '800M');
 
@@ -99,7 +99,7 @@ if ($fPostgresVersion >= 11.0) {
 }
 
 
-$oIndexCmd = (new \Nominatim\Shell(CONST_BasePath.'/nominatim/nominatim.py'))
+$oIndexCmd = (new \Nominatim\Shell(CONST_DataDir.'/nominatim/nominatim.py'))
              ->addParams('--database', $aDSNInfo['database'])
              ->addParams('--port', $aDSNInfo['port'])
              ->addParams('--threads', $aResult['index-instances']);
@@ -193,7 +193,7 @@ if ($aResult['check-for-updates']) {
         fail('Updates not set up. Please run ./utils/update.php --init-updates.');
     }
 
-    $oCmd = (new \Nominatim\Shell(CONST_BasePath.'/utils/check_server_for_updates.py'))
+    $oCmd = (new \Nominatim\Shell(CONST_BinDir.'/check_server_for_updates.py'))
             ->addParams(CONST_Replication_Url)
             ->addParams($aLastState['sequence_id']);
     $iRet = $oCmd->run();
@@ -223,11 +223,11 @@ if (isset($aResult['import-diff']) || isset($aResult['import-file'])) {
 
 if ($aResult['calculate-postcodes']) {
     info('Update postcodes centroids');
-    $sTemplate = file_get_contents(CONST_BasePath.'/sql/update-postcodes.sql');
+    $sTemplate = file_get_contents(CONST_DataDir.'/sql/update-postcodes.sql');
     runSQLScript($sTemplate, true, true);
 }
 
-$sTemporaryFile = CONST_BasePath.'/data/osmosischange.osc';
+$sTemporaryFile = CONST_InstallDir.'/osmosischange.osc';
 $bHaveDiff = false;
 $bUseOSMApi = isset($aResult['import-from-main-api']) && $aResult['import-from-main-api'];
 $sContentURL = '';
@@ -274,7 +274,7 @@ if ($bHaveDiff) {
 
 if ($aResult['recompute-word-counts']) {
     info('Recompute frequency of full-word search terms');
-    $sTemplate = file_get_contents(CONST_BasePath.'/sql/words_from_search_name.sql');
+    $sTemplate = file_get_contents(CONST_DataDir.'/sql/words_from_search_name.sql');
     runSQLScript($sTemplate, true, true);
 }
 
@@ -320,7 +320,7 @@ if ($aResult['import-osmosis'] || $aResult['import-osmosis-all']) {
              "Please check install documentation (https://nominatim.org/release-docs/latest/admin/Import-and-Update#setting-up-the-update-process)\n");
     }
 
-    $sImportFile = CONST_InstallPath.'/osmosischange.osc';
+    $sImportFile = CONST_InstallDir.'/osmosischange.osc';
 
     $oCMDDownload = (new \Nominatim\Shell(CONST_Pyosmium_Binary))
                     ->addParams('--server', CONST_Replication_Url)
@@ -379,7 +379,7 @@ if ($aResult['import-osmosis'] || $aResult['import-osmosis-all']) {
             // get the newest object from the diff file
             $sBatchEnd = 0;
             $iRet = 0;
-            $oCMD = new \Nominatim\Shell(CONST_BasePath.'/utils/osm_file_date.py', $sImportFile);
+            $oCMD = new \Nominatim\Shell(CONST_BinDir.'/osm_file_date.py', $sImportFile);
             exec($oCMD->escapedCmd(), $sBatchEnd, $iRet);
             if ($iRet == 5) {
                 echo "Diff file is empty. skipping import.\n";
index 5476eae04ffe014bfb7243e8982d6bac5a2be3ac..f86e0dd5821fb0feedb032d7df82cb38215a5961 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-require_once(CONST_BasePath.'/lib/init-cmd.php');
+require_once(CONST_LibDir.'/init-cmd.php');
 ini_set('memory_limit', '800M');
 
 $aCMDOptions = array(
@@ -13,10 +13,10 @@ $aCMDOptions = array(
                );
 getCmdOpt($_SERVER['argv'], $aCMDOptions, $aResult, true, true);
 
-require_once(CONST_BasePath.'/lib/log.php');
-require_once(CONST_BasePath.'/lib/Geocode.php');
-require_once(CONST_BasePath.'/lib/PlaceLookup.php');
-require_once(CONST_BasePath.'/lib/ReverseGeocode.php');
+require_once(CONST_LibDir.'/log.php');
+require_once(CONST_LibDir.'/Geocode.php');
+require_once(CONST_LibDir.'/PlaceLookup.php');
+require_once(CONST_LibDir.'/ReverseGeocode.php');
 
 $oDB = new Nominatim\DB();
 $oDB->connect();
index 2028cbdd8fa9c513cb7a48ccea21d6c1585e47ac..9a0ea0d859a9a7927e343a09aafbaceffca68cc7 100644 (file)
@@ -1,8 +1,8 @@
 <?php
 
-require_once(CONST_BasePath.'/lib/init-website.php');
-require_once(CONST_BasePath.'/lib/log.php');
-require_once(CONST_BasePath.'/lib/output.php');
+require_once(CONST_LibDir.'/init-website.php');
+require_once(CONST_LibDir.'/log.php');
+require_once(CONST_LibDir.'/output.php');
 ini_set('memory_limit', '200M');
 
 $oParams = new Nominatim\ParameterParser();
index 77e74969240cf9dab25ffefffd20e008165c3378..2f91b2bb4de2b9aa81b2f0e21dc0668285dc283f 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 
-require_once(CONST_BasePath.'/lib/init-website.php');
-require_once(CONST_BasePath.'/lib/log.php');
-require_once(CONST_BasePath.'/lib/output.php');
-require_once(CONST_BasePath.'/lib/AddressDetails.php');
+require_once(CONST_LibDir.'/init-website.php');
+require_once(CONST_LibDir.'/log.php');
+require_once(CONST_LibDir.'/output.php');
+require_once(CONST_LibDir.'/AddressDetails.php');
 ini_set('memory_limit', '200M');
 
 $oParams = new Nominatim\ParameterParser();
@@ -77,7 +77,7 @@ if ($sOsmType && $iOsmId > 0) {
                 $aPointDetails['error_x'] = 0;
                 $aPointDetails['error_y'] = 0;
             }
-            include(CONST_BasePath.'/lib/template/details-error-'.$sOutputFormat.'.php');
+            include(CONST_LibDir.'/template/details-error-'.$sOutputFormat.'.php');
             exit;
         }
     }
@@ -247,4 +247,4 @@ if ($bIncludeKeywords) {
 
 logEnd($oDB, $hLog, 1);
 
-include(CONST_BasePath.'/lib/template/details-'.$sOutputFormat.'.php');
+include(CONST_LibDir.'/template/details-'.$sOutputFormat.'.php');
index db2c01d647fd0afb4ceea11f0da84c718ee02806..e4a98939b93bf4b2ca0acfd810966061da1f8de2 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 
-require_once(CONST_BasePath.'/lib/init-website.php');
-require_once(CONST_BasePath.'/lib/log.php');
-require_once(CONST_BasePath.'/lib/PlaceLookup.php');
-require_once(CONST_BasePath.'/lib/output.php');
+require_once(CONST_LibDir.'/init-website.php');
+require_once(CONST_LibDir.'/log.php');
+require_once(CONST_LibDir.'/PlaceLookup.php');
+require_once(CONST_LibDir.'/output.php');
 ini_set('memory_limit', '200M');
 
 $oParams = new Nominatim\ParameterParser();
@@ -84,4 +84,4 @@ $sMoreURL = '';
 logEnd($oDB, $hLog, 1);
 
 $sOutputTemplate = ($sOutputFormat == 'jsonv2') ? 'json' : $sOutputFormat;
-include(CONST_BasePath.'/lib/template/search-'.$sOutputTemplate.'.php');
+include(CONST_LibDir.'/template/search-'.$sOutputTemplate.'.php');
index 9c657a1d68b2c00ff510c860ddac63002a8ce4bb..418bec09b4ce09ed1a3cea6214109c52423ec4d7 100644 (file)
@@ -1,8 +1,8 @@
 <?php
 
-require_once(CONST_BasePath.'/lib/init-website.php');
-require_once(CONST_BasePath.'/lib/log.php');
-require_once(CONST_BasePath.'/lib/output.php');
+require_once(CONST_LibDir.'/init-website.php');
+require_once(CONST_LibDir.'/log.php');
+require_once(CONST_LibDir.'/output.php');
 ini_set('memory_limit', '200M');
 
 $oParams = new Nominatim\ParameterParser();
index 640ea2abc15691491a63dfb5fabd0191a5fe372d..556808c1d649881123cd0564f9c08ecea591f85e 100644 (file)
@@ -1,10 +1,10 @@
 <?php
 
-require_once(CONST_BasePath.'/lib/init-website.php');
-require_once(CONST_BasePath.'/lib/log.php');
-require_once(CONST_BasePath.'/lib/PlaceLookup.php');
-require_once(CONST_BasePath.'/lib/ReverseGeocode.php');
-require_once(CONST_BasePath.'/lib/output.php');
+require_once(CONST_LibDir.'/init-website.php');
+require_once(CONST_LibDir.'/log.php');
+require_once(CONST_LibDir.'/PlaceLookup.php');
+require_once(CONST_LibDir.'/ReverseGeocode.php');
+require_once(CONST_LibDir.'/output.php');
 ini_set('memory_limit', '200M');
 
 $oParams = new Nominatim\ParameterParser();
@@ -84,4 +84,4 @@ if ($sOutputFormat == 'geocodejson') {
 }
 
 $sOutputTemplate = ($sOutputFormat == 'jsonv2') ? 'json' : $sOutputFormat;
-include(CONST_BasePath.'/lib/template/address-'.$sOutputTemplate.'.php');
+include(CONST_LibDir.'/template/address-'.$sOutputTemplate.'.php');
index 43c9fd010ac8389c3f67f8143de1545399bef667..05d0e444e52130d7a02750d1272213db65c29d71 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 
-require_once(CONST_BasePath.'/lib/init-website.php');
-require_once(CONST_BasePath.'/lib/log.php');
-require_once(CONST_BasePath.'/lib/Geocode.php');
-require_once(CONST_BasePath.'/lib/output.php');
+require_once(CONST_LibDir.'/init-website.php');
+require_once(CONST_LibDir.'/log.php');
+require_once(CONST_LibDir.'/Geocode.php');
+require_once(CONST_LibDir.'/output.php');
 ini_set('memory_limit', '200M');
 
 $oDB = new Nominatim\DB();
@@ -41,7 +41,7 @@ if (CONST_Search_BatchMode && isset($_GET['batch'])) {
         $aSearchResults = $oBatchGeocode->lookup();
         $aBatchResults[] = $aSearchResults;
     }
-    include(CONST_BasePath.'/lib/template/search-batch-json.php');
+    include(CONST_LibDir.'/template/search-batch-json.php');
     exit;
 }
 
@@ -89,4 +89,4 @@ if (isset($_SERVER['REQUEST_SCHEME'])
 if (CONST_Debug) exit;
 
 $sOutputTemplate = ($sOutputFormat == 'jsonv2') ? 'json' : $sOutputFormat;
-include(CONST_BasePath.'/lib/template/search-'.$sOutputTemplate.'.php');
+include(CONST_LibDir.'/template/search-'.$sOutputTemplate.'.php');
index 0d48354492b7155602edffa369ef8f05f97cc783..dc497ff5668bc84202327b925091b838ceb776d8 100644 (file)
@@ -1,8 +1,8 @@
 <?php
 
-require_once(CONST_BasePath.'/lib/init-website.php');
-require_once(CONST_BasePath.'/lib/ParameterParser.php');
-require_once(CONST_BasePath.'/lib/Status.php');
+require_once(CONST_LibDir.'/init-website.php');
+require_once(CONST_LibDir.'/ParameterParser.php');
+require_once(CONST_LibDir.'/Status.php');
 
 $oParams = new Nominatim\ParameterParser();
 $sOutputFormat = $oParams->getSet('format', array('text', 'json'), 'text');