mirror of
https://github.com/osm-search/Nominatim.git
synced 2024-12-27 23:15:12 +03:00
switch all utils to initialising dotenv
This commit is contained in:
parent
0947b61808
commit
992d3faac8
@ -4,10 +4,6 @@ require('Symfony/Component/Dotenv/autoload.php');
|
|||||||
|
|
||||||
function loadSettings($sProjectDir)
|
function loadSettings($sProjectDir)
|
||||||
{
|
{
|
||||||
if (!$sProjectDir) {
|
|
||||||
$sProjectDir = getcwd();
|
|
||||||
}
|
|
||||||
|
|
||||||
@define('CONST_InstallDir', $sProjectDir);
|
@define('CONST_InstallDir', $sProjectDir);
|
||||||
|
|
||||||
$dotenv = new \Symfony\Component\Dotenv\Dotenv();
|
$dotenv = new \Symfony\Component\Dotenv\Dotenv();
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
require_once(CONST_LibDir.'/init-cmd.php');
|
require_once(CONST_LibDir.'/init-cmd.php');
|
||||||
|
|
||||||
loadSettings(false);
|
loadSettings(getcwd());
|
||||||
|
|
||||||
$term_colors = array(
|
$term_colors = array(
|
||||||
'green' => "\033[92m",
|
'green' => "\033[92m",
|
||||||
|
@ -11,9 +11,11 @@ $aCMDOptions
|
|||||||
array('help', 'h', 0, 1, 0, 0, false, 'Show Help'),
|
array('help', 'h', 0, 1, 0, 0, false, 'Show Help'),
|
||||||
array('quiet', 'q', 0, 1, 0, 0, 'bool', 'Quiet output'),
|
array('quiet', 'q', 0, 1, 0, 0, 'bool', 'Quiet output'),
|
||||||
array('verbose', 'v', 0, 1, 0, 0, 'bool', 'Verbose output'),
|
array('verbose', 'v', 0, 1, 0, 0, 'bool', 'Verbose output'),
|
||||||
|
array('project-dir', '', 0, 1, 1, 1, 'realpath', 'Base directory of the Nominatim installation (default: .)'),
|
||||||
);
|
);
|
||||||
getCmdOpt($_SERVER['argv'], $aCMDOptions, $aCMDResult, true, true);
|
getCmdOpt($_SERVER['argv'], $aCMDOptions, $aCMDResult, true, true);
|
||||||
|
|
||||||
|
loadSettings($aCMDResult['project-dir'] ?? getcwd());
|
||||||
setupHTTPProxy();
|
setupHTTPProxy();
|
||||||
|
|
||||||
if (true) {
|
if (true) {
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
array('restrict-to-osm-node', '', 0, 1, 1, 1, 'int', 'Export only objects that are children of this OSM node'),
|
array('restrict-to-osm-node', '', 0, 1, 1, 1, 'int', 'Export only objects that are children of this OSM node'),
|
||||||
array('restrict-to-osm-way', '', 0, 1, 1, 1, 'int', 'Export only objects that are children of this OSM way'),
|
array('restrict-to-osm-way', '', 0, 1, 1, 1, 'int', 'Export only objects that are children of this OSM way'),
|
||||||
array('restrict-to-osm-relation', '', 0, 1, 1, 1, 'int', 'Export only objects that are children of this OSM relation'),
|
array('restrict-to-osm-relation', '', 0, 1, 1, 1, 'int', 'Export only objects that are children of this OSM relation'),
|
||||||
|
array('project-dir', '', 0, 1, 1, 1, 'realpath', 'Base directory of the Nominatim installation (default: .)'),
|
||||||
"\nAddress ranks: continent, country, state, county, city, suburb, street, path",
|
"\nAddress ranks: continent, country, state, county, city, suburb, street, path",
|
||||||
'Additional output types: postcode, placeid (placeid for each object)',
|
'Additional output types: postcode, placeid (placeid for each object)',
|
||||||
"\noutput-format must be a semicolon-separated list of address ranks. Multiple ranks",
|
"\noutput-format must be a semicolon-separated list of address ranks. Multiple ranks",
|
||||||
@ -30,6 +31,8 @@
|
|||||||
);
|
);
|
||||||
getCmdOpt($_SERVER['argv'], $aCMDOptions, $aCMDResult, true, true);
|
getCmdOpt($_SERVER['argv'], $aCMDOptions, $aCMDResult, true, true);
|
||||||
|
|
||||||
|
loadSettings($aCMDResult['project-dir'] ?? getcwd());
|
||||||
|
|
||||||
$aRankmap = array(
|
$aRankmap = array(
|
||||||
'continent' => 1,
|
'continent' => 1,
|
||||||
'country' => 4,
|
'country' => 4,
|
||||||
|
@ -28,10 +28,14 @@ $aCMDOptions
|
|||||||
array('exclude_place_ids', '', 0, 1, 1, 1, 'string', 'Comma-separated list of place ids to exclude from results'),
|
array('exclude_place_ids', '', 0, 1, 1, 1, 'string', 'Comma-separated list of place ids to exclude from results'),
|
||||||
array('featureType', '', 0, 1, 1, 1, 'string', 'Restrict results to certain features (country, state,city,settlement)'),
|
array('featureType', '', 0, 1, 1, 1, 'string', 'Restrict results to certain features (country, state,city,settlement)'),
|
||||||
array('countrycodes', '', 0, 1, 1, 1, 'string', 'Comma-separated list of countries to restrict search to'),
|
array('countrycodes', '', 0, 1, 1, 1, 'string', 'Comma-separated list of countries to restrict search to'),
|
||||||
array('viewbox', '', 0, 1, 1, 1, 'string', 'Prefer results in given view box')
|
array('viewbox', '', 0, 1, 1, 1, 'string', 'Prefer results in given view box'),
|
||||||
|
|
||||||
|
array('project-dir', '', 0, 1, 1, 1, 'realpath', 'Base directory of the Nominatim installation (default: .)'),
|
||||||
);
|
);
|
||||||
getCmdOpt($_SERVER['argv'], $aCMDOptions, $aCMDResult, true, true);
|
getCmdOpt($_SERVER['argv'], $aCMDOptions, $aCMDResult, true, true);
|
||||||
|
|
||||||
|
loadSettings($aCMDResult['project-dir'] ?? getcwd());
|
||||||
|
|
||||||
$oDB = new Nominatim\DB;
|
$oDB = new Nominatim\DB;
|
||||||
$oDB->connect();
|
$oDB->connect();
|
||||||
|
|
||||||
|
@ -44,13 +44,13 @@ $aCMDOptions
|
|||||||
array('create-country-names', '', 0, 1, 0, 0, 'bool', 'Create default list of searchable country names'),
|
array('create-country-names', '', 0, 1, 0, 0, 'bool', 'Create default list of searchable country names'),
|
||||||
array('drop', '', 0, 1, 0, 0, 'bool', 'Drop tables needed for updates, making the database readonly (EXPERIMENTAL)'),
|
array('drop', '', 0, 1, 0, 0, 'bool', 'Drop tables needed for updates, making the database readonly (EXPERIMENTAL)'),
|
||||||
array('setup-website', '', 0, 1, 0, 0, 'bool', 'Used to compile environment variables for the website'),
|
array('setup-website', '', 0, 1, 0, 0, 'bool', 'Used to compile environment variables for the website'),
|
||||||
array('project-dir', '', 0, 1, 1, 1, 'realpath', 'Base directory for this Nominatim installation'),
|
array('project-dir', '', 0, 1, 1, 1, 'realpath', 'Base directory of the Nominatim installation (default: .)'),
|
||||||
);
|
);
|
||||||
|
|
||||||
// $aCMDOptions passed to getCmdOpt by reference
|
// $aCMDOptions passed to getCmdOpt by reference
|
||||||
getCmdOpt($_SERVER['argv'], $aCMDOptions, $aCMDResult, true, true);
|
getCmdOpt($_SERVER['argv'], $aCMDOptions, $aCMDResult, true, true);
|
||||||
|
|
||||||
loadSettings($aCMDResult['project-dir'] ?? false);
|
loadSettings($aCMDResult['project-dir'] ?? getcwd());
|
||||||
setupHTTPProxy();
|
setupHTTPProxy();
|
||||||
|
|
||||||
$bDidSomething = false;
|
$bDidSomething = false;
|
||||||
|
@ -11,9 +11,11 @@ $aCMDOptions
|
|||||||
array('quiet', 'q', 0, 1, 0, 0, 'bool', 'Quiet output'),
|
array('quiet', 'q', 0, 1, 0, 0, 'bool', 'Quiet output'),
|
||||||
array('verbose', 'v', 0, 1, 0, 0, 'bool', 'Verbose output'),
|
array('verbose', 'v', 0, 1, 0, 0, 'bool', 'Verbose output'),
|
||||||
array('wiki-import', '', 0, 1, 0, 0, 'bool', 'Create import script for search phrases '),
|
array('wiki-import', '', 0, 1, 0, 0, 'bool', 'Create import script for search phrases '),
|
||||||
|
array('project-dir', '', 0, 1, 1, 1, 'realpath', 'Base directory of the Nominatim installation (default: .)'),
|
||||||
);
|
);
|
||||||
getCmdOpt($_SERVER['argv'], $aCMDOptions, $aCMDResult, true, true);
|
getCmdOpt($_SERVER['argv'], $aCMDOptions, $aCMDResult, true, true);
|
||||||
|
|
||||||
|
loadSettings($aCMDResult['project-dir'] ?? getcwd());
|
||||||
setupHTTPProxy();
|
setupHTTPProxy();
|
||||||
|
|
||||||
include(getSettingConfig('PHRASE_CONFIG', 'phrase_settings.php'));
|
include(getSettingConfig('PHRASE_CONFIG', 'phrase_settings.php'));
|
||||||
|
@ -41,11 +41,14 @@ $aCMDOptions
|
|||||||
|
|
||||||
array('recompute-word-counts', '', 0, 1, 0, 0, 'bool', 'Compute frequency of full-word search terms'),
|
array('recompute-word-counts', '', 0, 1, 0, 0, 'bool', 'Compute frequency of full-word search terms'),
|
||||||
array('update-address-levels', '', 0, 1, 0, 0, 'bool', 'Reimport address level configuration (EXPERT)'),
|
array('update-address-levels', '', 0, 1, 0, 0, 'bool', 'Reimport address level configuration (EXPERT)'),
|
||||||
array('recompute-importance', '', 0, 1, 0, 0, 'bool', 'Recompute place importances')
|
array('recompute-importance', '', 0, 1, 0, 0, 'bool', 'Recompute place importances'),
|
||||||
|
|
||||||
|
array('project-dir', '', 0, 1, 1, 1, 'realpath', 'Base directory of the Nominatim installation (default: .)'),
|
||||||
);
|
);
|
||||||
|
|
||||||
getCmdOpt($_SERVER['argv'], $aCMDOptions, $aResult, true, true);
|
getCmdOpt($_SERVER['argv'], $aCMDOptions, $aResult, true, true);
|
||||||
|
|
||||||
|
loadSettings($aCMDResult['project-dir'] ?? getcwd());
|
||||||
setupHTTPProxy();
|
setupHTTPProxy();
|
||||||
|
|
||||||
if (!isset($aResult['index-instances'])) $aResult['index-instances'] = 1;
|
if (!isset($aResult['index-instances'])) $aResult['index-instances'] = 1;
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once(CONST_LibDir.'/init-cmd.php');
|
require_once(CONST_LibDir.'/init-cmd.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');
|
||||||
|
|
||||||
ini_set('memory_limit', '800M');
|
ini_set('memory_limit', '800M');
|
||||||
|
|
||||||
$aCMDOptions = array(
|
$aCMDOptions = array(
|
||||||
@ -10,13 +15,11 @@ $aCMDOptions = array(
|
|||||||
array('verbose', 'v', 0, 1, 0, 0, 'bool', 'Verbose output'),
|
array('verbose', 'v', 0, 1, 0, 0, 'bool', 'Verbose output'),
|
||||||
array('reverse-only', '', 0, 1, 0, 0, 'bool', 'Warm reverse only'),
|
array('reverse-only', '', 0, 1, 0, 0, 'bool', 'Warm reverse only'),
|
||||||
array('search-only', '', 0, 1, 0, 0, 'bool', 'Warm search only'),
|
array('search-only', '', 0, 1, 0, 0, 'bool', 'Warm search only'),
|
||||||
|
array('project-dir', '', 0, 1, 1, 1, 'realpath', 'Base directory of the Nominatim installation (default: .)'),
|
||||||
);
|
);
|
||||||
getCmdOpt($_SERVER['argv'], $aCMDOptions, $aResult, true, true);
|
getCmdOpt($_SERVER['argv'], $aCMDOptions, $aResult, true, true);
|
||||||
|
|
||||||
require_once(CONST_LibDir.'/log.php');
|
loadSettings($aCMDResult['project-dir'] ?? getcwd());
|
||||||
require_once(CONST_LibDir.'/Geocode.php');
|
|
||||||
require_once(CONST_LibDir.'/PlaceLookup.php');
|
|
||||||
require_once(CONST_LibDir.'/ReverseGeocode.php');
|
|
||||||
|
|
||||||
$oDB = new Nominatim\DB();
|
$oDB = new Nominatim\DB();
|
||||||
$oDB->connect();
|
$oDB->connect();
|
||||||
|
Loading…
Reference in New Issue
Block a user