switch remaining settings to dotenv format

CONST_Search_AreaPolygons and CONST_Search_ReversePlanForAll have
been removed completely.
This commit is contained in:
Sarah Hoffmann
2020-12-15 15:37:31 +01:00
parent d43f30903c
commit 0947b61808
14 changed files with 400 additions and 272 deletions

View File

@@ -18,7 +18,7 @@ class Geocode
protected $aLangPrefOrder = array();
protected $aExcludePlaceIDs = array();
protected $bReverseInPlan = false;
protected $bReverseInPlan = true;
protected $iLimit = 20;
protected $iFinalLimit = 10;

View File

@@ -486,65 +486,63 @@ class PlaceLookup
$aOutlineResult = array();
if (!$iPlaceID) return $aOutlineResult;
if (CONST_Search_AreaPolygons) {
// Get the bounding box and outline polygon
$sSQL = 'select place_id,0 as numfeatures,st_area(geometry) as area,';
if ($fLonReverse != null && $fLatReverse != null) {
$sSQL .= ' ST_Y(closest_point) as centrelat,';
$sSQL .= ' ST_X(closest_point) as centrelon,';
} else {
$sSQL .= ' ST_Y(centroid) as centrelat, ST_X(centroid) as centrelon,';
}
$sSQL .= ' ST_YMin(geometry) as minlat,ST_YMax(geometry) as maxlat,';
$sSQL .= ' ST_XMin(geometry) as minlon,ST_XMax(geometry) as maxlon';
if ($this->bIncludePolygonAsGeoJSON) $sSQL .= ',ST_AsGeoJSON(geometry) as asgeojson';
if ($this->bIncludePolygonAsKML) $sSQL .= ',ST_AsKML(geometry) as askml';
if ($this->bIncludePolygonAsSVG) $sSQL .= ',ST_AsSVG(geometry) as assvg';
if ($this->bIncludePolygonAsText) $sSQL .= ',ST_AsText(geometry) as astext';
if ($fLonReverse != null && $fLatReverse != null) {
$sFrom = ' from (SELECT * , CASE WHEN (class = \'highway\') AND (ST_GeometryType(geometry) = \'ST_LineString\') THEN ';
$sFrom .=' ST_ClosestPoint(geometry, ST_SetSRID(ST_Point('.$fLatReverse.','.$fLonReverse.'),4326))';
$sFrom .=' ELSE centroid END AS closest_point';
$sFrom .= ' from placex where place_id = '.$iPlaceID.') as plx';
} else {
$sFrom = ' from placex where place_id = '.$iPlaceID;
}
if ($this->fPolygonSimplificationThreshold > 0) {
$sSQL .= ' from (select place_id,centroid,ST_SimplifyPreserveTopology(geometry,'.$this->fPolygonSimplificationThreshold.') as geometry'.$sFrom.') as plx';
} else {
$sSQL .= $sFrom;
// Get the bounding box and outline polygon
$sSQL = 'select place_id,0 as numfeatures,st_area(geometry) as area,';
if ($fLonReverse != null && $fLatReverse != null) {
$sSQL .= ' ST_Y(closest_point) as centrelat,';
$sSQL .= ' ST_X(closest_point) as centrelon,';
} else {
$sSQL .= ' ST_Y(centroid) as centrelat, ST_X(centroid) as centrelon,';
}
$sSQL .= ' ST_YMin(geometry) as minlat,ST_YMax(geometry) as maxlat,';
$sSQL .= ' ST_XMin(geometry) as minlon,ST_XMax(geometry) as maxlon';
if ($this->bIncludePolygonAsGeoJSON) $sSQL .= ',ST_AsGeoJSON(geometry) as asgeojson';
if ($this->bIncludePolygonAsKML) $sSQL .= ',ST_AsKML(geometry) as askml';
if ($this->bIncludePolygonAsSVG) $sSQL .= ',ST_AsSVG(geometry) as assvg';
if ($this->bIncludePolygonAsText) $sSQL .= ',ST_AsText(geometry) as astext';
if ($fLonReverse != null && $fLatReverse != null) {
$sFrom = ' from (SELECT * , CASE WHEN (class = \'highway\') AND (ST_GeometryType(geometry) = \'ST_LineString\') THEN ';
$sFrom .=' ST_ClosestPoint(geometry, ST_SetSRID(ST_Point('.$fLatReverse.','.$fLonReverse.'),4326))';
$sFrom .=' ELSE centroid END AS closest_point';
$sFrom .= ' from placex where place_id = '.$iPlaceID.') as plx';
} else {
$sFrom = ' from placex where place_id = '.$iPlaceID;
}
if ($this->fPolygonSimplificationThreshold > 0) {
$sSQL .= ' from (select place_id,centroid,ST_SimplifyPreserveTopology(geometry,'.$this->fPolygonSimplificationThreshold.') as geometry'.$sFrom.') as plx';
} else {
$sSQL .= $sFrom;
}
$aPointPolygon = $this->oDB->getRow($sSQL, null, 'Could not get outline');
if ($aPointPolygon && $aPointPolygon['place_id']) {
if ($aPointPolygon['centrelon'] !== null && $aPointPolygon['centrelat'] !== null) {
$aOutlineResult['lat'] = $aPointPolygon['centrelat'];
$aOutlineResult['lon'] = $aPointPolygon['centrelon'];
}
$aPointPolygon = $this->oDB->getRow($sSQL, null, 'Could not get outline');
if ($this->bIncludePolygonAsGeoJSON) $aOutlineResult['asgeojson'] = $aPointPolygon['asgeojson'];
if ($this->bIncludePolygonAsKML) $aOutlineResult['askml'] = $aPointPolygon['askml'];
if ($this->bIncludePolygonAsSVG) $aOutlineResult['assvg'] = $aPointPolygon['assvg'];
if ($this->bIncludePolygonAsText) $aOutlineResult['astext'] = $aPointPolygon['astext'];
if ($aPointPolygon && $aPointPolygon['place_id']) {
if ($aPointPolygon['centrelon'] !== null && $aPointPolygon['centrelat'] !== null) {
$aOutlineResult['lat'] = $aPointPolygon['centrelat'];
$aOutlineResult['lon'] = $aPointPolygon['centrelon'];
}
if ($this->bIncludePolygonAsGeoJSON) $aOutlineResult['asgeojson'] = $aPointPolygon['asgeojson'];
if ($this->bIncludePolygonAsKML) $aOutlineResult['askml'] = $aPointPolygon['askml'];
if ($this->bIncludePolygonAsSVG) $aOutlineResult['assvg'] = $aPointPolygon['assvg'];
if ($this->bIncludePolygonAsText) $aOutlineResult['astext'] = $aPointPolygon['astext'];
if (abs($aPointPolygon['minlat'] - $aPointPolygon['maxlat']) < 0.0000001) {
$aPointPolygon['minlat'] = $aPointPolygon['minlat'] - $fRadius;
$aPointPolygon['maxlat'] = $aPointPolygon['maxlat'] + $fRadius;
}
if (abs($aPointPolygon['minlon'] - $aPointPolygon['maxlon']) < 0.0000001) {
$aPointPolygon['minlon'] = $aPointPolygon['minlon'] - $fRadius;
$aPointPolygon['maxlon'] = $aPointPolygon['maxlon'] + $fRadius;
}
$aOutlineResult['aBoundingBox'] = array(
(string)$aPointPolygon['minlat'],
(string)$aPointPolygon['maxlat'],
(string)$aPointPolygon['minlon'],
(string)$aPointPolygon['maxlon']
);
if (abs($aPointPolygon['minlat'] - $aPointPolygon['maxlat']) < 0.0000001) {
$aPointPolygon['minlat'] = $aPointPolygon['minlat'] - $fRadius;
$aPointPolygon['maxlat'] = $aPointPolygon['maxlat'] + $fRadius;
}
if (abs($aPointPolygon['minlon'] - $aPointPolygon['maxlon']) < 0.0000001) {
$aPointPolygon['minlon'] = $aPointPolygon['minlon'] - $fRadius;
$aPointPolygon['maxlon'] = $aPointPolygon['maxlon'] + $fRadius;
}
$aOutlineResult['aBoundingBox'] = array(
(string)$aPointPolygon['minlat'],
(string)$aPointPolygon['maxlat'],
(string)$aPointPolygon['minlon'],
(string)$aPointPolygon['maxlon']
);
}
// as a fallback we generate a bounding box without knowing the size of the geometry

View File

@@ -198,19 +198,18 @@ function runSQLScript($sScript, $bfatal = true, $bVerbose = false, $bIgnoreError
function setupHTTPProxy()
{
if (!CONST_HTTP_Proxy) {
if (!getSettingBool('HTTP_PROXY')) {
return;
}
$sProxy = 'tcp://'.CONST_HTTP_Proxy_Host.':'.CONST_HTTP_Proxy_Port;
$sProxy = 'tcp://'.getSetting('HTTP_PROXY_HOST').':'.getSetting('HTTP_PROXY_PROT');
$aHeaders = array();
if (CONST_HTTP_Proxy_Login != null
&& CONST_HTTP_Proxy_Login != ''
&& CONST_HTTP_Proxy_Password != null
&& CONST_HTTP_Proxy_Password != ''
) {
$sAuth = base64_encode(CONST_HTTP_Proxy_Login.':'.CONST_HTTP_Proxy_Password);
$sLogin = getSetting('HTTP_PROXY_LOGIN');
$sPassword = getSetting('HTTP_PROXY_PASSWORD');
if ($sLogin && $sPassword) {
$sAuth = base64_encode($sLogin.':'.$sPassword);
$aHeaders = array('Proxy-Authorization: Basic '.$sAuth);
}

View File

@@ -18,9 +18,35 @@ function loadSettings($sProjectDir)
$dotenv->load(CONST_DataDir.'/settings/env.defaults');
}
function getSetting($sConfName)
function getSetting($sConfName, $sDefault = null)
{
return $_ENV['NOMINATIM_'.$sConfName];
$sValue = $_ENV['NOMINATIM_'.$sConfName];
if ($sDefault !== null && !$sValue) {
return $sDefault;
}
return $sValue;
}
function getSettingBool($sConfName)
{
$sVal = strtolower(getSetting($sConfName));
return strcmp($sVal, 'yes') == 0
|| strcmp($sVal, 'true') == 0
|| strcmp($sVal, '1') == 0;
}
function getSettingConfig($sConfName, $sSystemConfig)
{
$sValue = $_ENV['NOMINATIM_'.$sConfName];
if (!$sValue) {
return CONST_DataDir.'/settings/'.$sSystemConfig;
}
return $sValue;
}
function fail($sError, $sUserError = false)

View File

@@ -34,7 +34,7 @@ class SetupFunctions
if (isset($aCMDResult['osm2pgsql-cache'])) {
$this->iCacheMemory = $aCMDResult['osm2pgsql-cache'];
} elseif (!is_null(CONST_Osm2pgsql_Flatnode_File)) {
} elseif (getSetting('FLATNODE_FILE')) {
// When flatnode files are enabled then disable cache per default.
$this->iCacheMemory = 0;
} else {
@@ -42,10 +42,7 @@ class SetupFunctions
$this->iCacheMemory = getCacheMemoryMB();
}
$this->sModulePath = getSetting('DATABASE_MODULE_PATH');
if (strlen($this->sModulePath) == 0 || $this->sModulePath[0] != '/') {
$this->sModulePath = CONST_InstallDir.'/'.$this->sModulePath;
}
$this->sModulePath = getSetting('DATABASE_MODULE_PATH', CONST_InstallDir.'/module');
info('module path: ' . $this->sModulePath);
// parse database string
@@ -177,29 +174,29 @@ class SetupFunctions
{
info('Import data');
if (!file_exists(CONST_Osm2pgsql_Binary)) {
echo "Check CONST_Osm2pgsql_Binary in your local settings file.\n";
if (!file_exists(getOsm2pgsqlBinary())) {
echo "Check NOMINATIM_OSM2PGSQL_BINARY in your local .env file.\n";
echo "Normally you should not need to set this manually.\n";
fail("osm2pgsql not found in '".CONST_Osm2pgsql_Binary."'");
fail("osm2pgsql not found in '".getOsm2pgsqlBinary()."'");
}
$oCmd = new \Nominatim\Shell(CONST_Osm2pgsql_Binary);
$oCmd->addParams('--style', CONST_Import_Style);
$oCmd = new \Nominatim\Shell(getOsm2pgsqlBinary());
$oCmd->addParams('--style', getImportStyle());
if (!is_null(CONST_Osm2pgsql_Flatnode_File) && CONST_Osm2pgsql_Flatnode_File) {
$oCmd->addParams('--flat-nodes', CONST_Osm2pgsql_Flatnode_File);
if (getSetting('FLATNODE_FILE')) {
$oCmd->addParams('--flat-nodes', getSetting('FLATNODE_FILE'));
}
if (CONST_Tablespace_Osm2pgsql_Data) {
$oCmd->addParams('--tablespace-slim-data', CONST_Tablespace_Osm2pgsql_Data);
if (getSetting('TABLESPACE_OSM_DATA')) {
$oCmd->addParams('--tablespace-slim-data', getSetting('TABLESPACE_OSM_DATA'));
}
if (CONST_Tablespace_Osm2pgsql_Index) {
$oCmd->addParams('--tablespace-slim-index', CONST_Tablespace_Osm2pgsql_Index);
if (getSetting('TABLESPACE_OSM_INDEX')) {
$oCmd->addParams('--tablespace-slim-index', getSetting('TABLESPACE_OSM_INDEX'));
}
if (CONST_Tablespace_Place_Data) {
$oCmd->addParams('--tablespace-main-data', CONST_Tablespace_Place_Data);
if (getSetting('TABLESPACE_PLACE_DATA')) {
$oCmd->addParams('--tablespace-main-data', getSetting('TABLESPACE_PLACE_DATA'));
}
if (CONST_Tablespace_Place_Index) {
$oCmd->addParams('--tablespace-main-index', CONST_Tablespace_Place_Index);
if (getSetting('TABLESPACE_PLACE_INDEX')) {
$oCmd->addParams('--tablespace-main-index', getSetting('TABLESPACE_PLACE_INDEX'));
}
$oCmd->addParams('--latlong', '--slim', '--create');
$oCmd->addParams('--output', 'gazetteer');
@@ -256,7 +253,7 @@ class SetupFunctions
$this->dropTable('search_name');
}
$oAlParser = new AddressLevelParser(CONST_Address_Level_Config);
$oAlParser = new AddressLevelParser(getSettingConfig('ADDRESS_LEVEL_CONFIG', 'address-levels.json'));
$oAlParser->createTable($this->db(), 'address_levels');
}
@@ -290,7 +287,8 @@ class SetupFunctions
public function importWikipediaArticles()
{
$sWikiArticlesFile = CONST_Wikipedia_Data_Path.'/wikimedia-importance.sql.gz';
$sWikiArticlePath = getSettings('WIKIPEDIA_DATA_PATH', CONST_DataDir.'/data');
$sWikiArticlesFile = $sWikiArticlePath.'/wikimedia-importance.sql.gz';
if (file_exists($sWikiArticlesFile)) {
info('Importing wikipedia articles and redirects');
$this->dropTable('wikipedia_article');
@@ -339,7 +337,7 @@ class SetupFunctions
// used by getorcreate_word_id to ignore frequent partial words
$sSQL = 'CREATE OR REPLACE FUNCTION get_maxwordfreq() RETURNS integer AS ';
$sSQL .= '$$ SELECT '.CONST_Max_Word_Frequency.' as maxwordfreq; $$ LANGUAGE SQL IMMUTABLE';
$sSQL .= '$$ SELECT '.getSetting('MAX_WORD_FREQUENCY').' as maxwordfreq; $$ LANGUAGE SQL IMMUTABLE';
$oDB->exec($sSQL);
echo ".\n";
@@ -428,14 +426,14 @@ class SetupFunctions
}
}
public function importTigerData()
public function importTigerData($sTigerPath)
{
info('Import Tiger data');
$aFilenames = glob(CONST_Tiger_Data_Path.'/*.sql');
info('Found '.count($aFilenames).' SQL files in path '.CONST_Tiger_Data_Path);
$aFilenames = glob($sTigerPath.'/*.sql');
info('Found '.count($aFilenames).' SQL files in path '.$sTigerPath);
if (empty($aFilenames)) {
warn('Tiger data import selected but no files found in path '.CONST_Tiger_Data_Path);
warn('Tiger data import selected but no files found in path '.$sTigerPath);
return;
}
$sTemplate = file_get_contents(CONST_DataDir.'/sql/tiger_import_start.sql');
@@ -642,10 +640,11 @@ class SetupFunctions
$this->pgsqlRunScript("select count(*) from (select getorcreate_country(make_standard_name(name->'name'), country_code) from country_name where name ? 'name') as x");
$sSQL = 'select count(*) from (select getorcreate_country(make_standard_name(v),'
.'country_code) from (select country_code, skeys(name) as k, svals(name) as v from country_name) x where k ';
if (CONST_Languages) {
$sLanguages = getSetting('LANGUAGES');
if ($sLanguages) {
$sSQL .= 'in ';
$sDelim = '(';
foreach (explode(',', CONST_Languages) as $sLang) {
foreach (explode(',', $sLanguages) as $sLang) {
$sSQL .= $sDelim."'name:$sLang'";
$sDelim = ',';
}
@@ -716,24 +715,20 @@ class SetupFunctions
$rOutputFile = fopen(CONST_InstallDir.'/settings/settings-frontend.php', 'w');
fwrite($rOutputFile, "<?php
if (file_exists(getenv('NOMINATIM_SETTINGS'))) require_once(getenv('NOMINATIM_SETTINGS'));
@define('CONST_Database_DSN', '".getSetting('DATABASE_DSN')."');
@define('CONST_Default_Language', ".(CONST_Default_Language ? ("'".CONST_Default_Language."'") : 'false').");
@define('CONST_Log_DB', ".(CONST_Log_DB ? 'true' : 'false').");
@define('CONST_Log_File', ".(CONST_Log_File ? ("'".CONST_Log_File."'") : 'false').");
@define('CONST_Max_Word_Frequency', '".CONST_Max_Word_Frequency."');
@define('CONST_NoAccessControl', ".CONST_NoAccessControl.");
@define('CONST_Places_Max_ID_count', ".CONST_Places_Max_ID_count.");
@define('CONST_PolygonOutput_MaximumTypes', ".CONST_PolygonOutput_MaximumTypes.");
@define('CONST_Search_AreaPolygons', ".CONST_Search_AreaPolygons.");
@define('CONST_Search_BatchMode', ".(CONST_Search_BatchMode ? 'true' : 'false').");
@define('CONST_Search_NameOnlySearchFrequencyThreshold', ".CONST_Search_NameOnlySearchFrequencyThreshold.");
@define('CONST_Search_ReversePlanForAll', ".CONST_Search_ReversePlanForAll.");
@define('CONST_Term_Normalization_Rules', \"".CONST_Term_Normalization_Rules."\");
@define('CONST_Use_Aux_Location_data', ".(CONST_Use_Aux_Location_data ? 'true' : 'false').");
@define('CONST_Use_US_Tiger_Data', ".(CONST_Use_US_Tiger_Data ? 'true' : 'false').");
@define('CONST_MapIcon_URL', ".(CONST_MapIcon_URL ? ("'".CONST_MapIcon_URL."'") : 'false').');
@define('CONST_Default_Language', ".getSetting('DEFAULT_LANGUAGE', 'false').");
@define('CONST_Log_DB', ".(getSettingBool('LOG_DB') ? 'true' : 'false').");
@define('CONST_Log_File', ".getSetting('LOG_FILE', 'false').");
@define('CONST_Max_Word_Frequency', '".getSetting('MAX_WORD_FREQUENCY')."');
@define('CONST_NoAccessControl', ".(getSettingBool('CORS_NOACCESSCONTROL') ? 'true' : 'false').");
@define('CONST_Places_Max_ID_count', ".getSetting('LOOKUP_MAX_COUNT').");
@define('CONST_PolygonOutput_MaximumTypes', ".getSetting('POLYGON_OUTPUT_MAX_TYPES').");
@define('CONST_Search_BatchMode', ".(getSettingBool('SEARCH_BATCH_MODE' ? 'true' : 'false').");
@define('CONST_Search_NameOnlySearchFrequencyThreshold', ".getSetting('SEARCH_NAME_ONLY_THRESHOLD').");
@define('CONST_Term_Normalization_Rules', \"".getSetting('TERM_NORMALIZATION')."\");
@define('CONST_Use_Aux_Location_data', ".(getSettingBool('USE_AUX_LOCATION_DATA') ? 'true' : 'false').");
@define('CONST_Use_US_Tiger_Data', ".(getSettingBool('USE_US_TIGER_DATA') ? 'true' : 'false').");
@define('CONST_MapIcon_URL', ".(getSetting('MAPICON_URL', 'false').');
');
info(CONST_InstallDir.'/settings/settings-frontend.php has been set up successfully');
}
@@ -758,10 +753,10 @@ if (file_exists(getenv('NOMINATIM_SETTINGS'))) require_once(getenv('NOMINATIM_SE
private function removeFlatnodeFile()
{
if (!is_null(CONST_Osm2pgsql_Flatnode_File) && CONST_Osm2pgsql_Flatnode_File) {
if (file_exists(CONST_Osm2pgsql_Flatnode_File)) {
if ($this->bVerbose) echo 'Deleting '.CONST_Osm2pgsql_Flatnode_File."\n";
unlink(CONST_Osm2pgsql_Flatnode_File);
$sFName = getSetting('FLATNODE_FILE');
if ($sFName && file_exists($sFName)) {
if ($this->bVerbose) echo 'Deleting '.$sFName."\n";
unlink($sFName);
}
}
}
@@ -801,13 +796,13 @@ if (file_exists(getenv('NOMINATIM_SETTINGS'))) require_once(getenv('NOMINATIM_SE
if ($this->bEnableDebugStatements) {
$sTemplate = str_replace('--DEBUG:', '', $sTemplate);
}
if (CONST_Limit_Reindexing) {
if (getSettingBool('LIMIT_REINDEXING')) {
$sTemplate = str_replace('--LIMIT INDEXING:', '', $sTemplate);
}
if (!CONST_Use_US_Tiger_Data) {
if (!getSettingBool('USE_US_TIGER_DATA')) {
$sTemplate = str_replace('-- %NOTIGERDATA% ', '', $sTemplate);
}
if (!CONST_Use_Aux_Location_data) {
if (!getSettingBool('USE_AUX_LOCATION_DATA')) {
$sTemplate = str_replace('-- %NOAUXDATA% ', '', $sTemplate);
}
@@ -901,12 +896,12 @@ if (file_exists(getenv('NOMINATIM_SETTINGS'))) require_once(getenv('NOMINATIM_SE
$sSql = str_replace('{www-user}', getSetting('DATABASE_WEBUSER'), $sSql);
$aPatterns = array(
'{ts:address-data}' => CONST_Tablespace_Address_Data,
'{ts:address-index}' => CONST_Tablespace_Address_Index,
'{ts:search-data}' => CONST_Tablespace_Search_Data,
'{ts:search-index}' => CONST_Tablespace_Search_Index,
'{ts:aux-data}' => CONST_Tablespace_Aux_Data,
'{ts:aux-index}' => CONST_Tablespace_Aux_Index,
'{ts:address-data}' => getSetting('TABLESPACE_ADDRESS_DATA'),
'{ts:address-index}' => getSetting('TABLESPACE_ADDRESS_INDEX'),
'{ts:search-data}' => getSetting('TABLESPACE_SEARCH_DATA'),
'{ts:search-index}' => getSetting('TABLESPACE_SEARCH_INDEX'),
'{ts:aux-data}' => getSetting('TABLESPACE_AUX_DATA'),
'{ts:aux-index}' => getSetting('TABLESPACE_AUX_INDEX')
);
foreach ($aPatterns as $sPattern => $sTablespace) {

View File

@@ -14,3 +14,24 @@ function checkInFile($sOSMFile)
fail('osm-file "' . $aCMDResult['osm-file'] . '" not readable');
}
}
function getOsm2pgsqlBinary()
{
$sBinary = getSetting('OSM2PGSQL_BINARY');
if (!$sBinary) {
$sBinary = CONST_InstallDir.'/osm2pgsql/osm2pgsql';
}
return $sBinary;
}
function getImportStyle()
{
$sStyle = getSetting('IMPORT_STYLE');
if (in_array($sStyle, array('admin', 'street', 'address', 'full', 'extratags'))) {
return CONST_DataDir.'/settings/import-'.$sStyle.'.style';
}
return $sStyle;
}

View File

@@ -2,7 +2,6 @@
if (file_exists(getenv('NOMINATIM_SETTINGS'))) require_once(getenv('NOMINATIM_SETTINGS'));
if (file_exists(CONST_InstallDir.'/settings/local.php')) require_once(CONST_InstallDir.'/settings/local.php');
@define('CONST_Max_Word_Frequency', '50000');
@define('CONST_Limit_Reindexing', true);
// Restrict search languages.
// Normally Nominatim will include all language variants of name:XX

View File

@@ -1,9 +1,11 @@
# .env
# Default configuration settings for Nominatim
# Default configuration settings for Nominatim.
# This file uses the dotenv format.
# Database connection string.
# Add host, port, user etc through additional semicolon-separated attributes.
# e.g. ;host=...;port=...;user=...;password=...
# Changing this variable requires to run 'setup.php --setup-website'.
NOMINATIM_DATABASE_DSN="pgsql:dbname=nominatim"
# Database web user.
@@ -11,115 +13,201 @@ NOMINATIM_DATABASE_DSN="pgsql:dbname=nominatim"
NOMINATIM_DATABASE_WEBUSER="www-data"
# Directory where to find the PostgreSQL server module.
# When a relative path is given, it will be searched relative to the project
# directory.
NOMINATIM_DATABASE_MODULE_PATH="module"
# When empty the module is expected to be located in the 'module' subdirectory
# in the project directory.
# Changing this value requires to run ./utils/setup --create-functions.
NOMINATIM_DATABASE_MODULE_PATH=
#@define('CONST_Max_Word_Frequency', '50000');
#@define('CONST_Limit_Reindexing', true);
#// Restrict search languages.
#// Normally Nominatim will include all language variants of name:XX
#// in the search index. Set this to a comma separated list of language
#// codes, to restrict import to a subset of languages.
#// Currently only affects the import of country names and special phrases.
#@define('CONST_Languages', false);
#// Rules for normalizing terms for comparison before doing comparisons.
#// The default is to remove accents and punctuation and to lower-case the
#// term. Spaces are kept but collapsed to one standard space.
#@define('CONST_Term_Normalization_Rules', ":: NFD (); [[:Nonspacing Mark:] [:Cf:]] >; :: lower (); [[:Punctuation:][:Space:]]+ > ' '; :: NFC ();");
# Number of occurances of a word before it is considered frequent.
# Similar to the concept of stop words. Frequent partial words get ignored
# or handled differently during search.
# Changing this value requires a reimport.
NOMINATIM_MAX_WORD_FREQUENCY=50000
# If true, admin level changes on places with many contained children are blocked.
NOMINATIM_LIMIT_REINDEXING=yes
# Restrict search languages.
# Normally Nominatim will include all language variants of name:XX
# in the search index. Set this to a comma separated list of language
# codes, to restrict import to a subset of languages.
# Currently only affects the initial import of country names and special phrases.
NOMINATIM_LANGUAGES=
# Rules for normalizing terms for comparisons.
# The default is to remove accents and punctuation and to lower-case the
# term. Spaces are kept but collapsed to one standard space.
# Changing this value requires a reimport.
NOMINATIM_TERM_NORMALIZATION=":: NFD (); [[:Nonspacing Mark:] [:Cf:]] >; :: lower (); [[:Punctuation:][:Space:]]+ > ' '; :: NFC ();"
# Search in the Tiger house number data for the US.
# Note: The tables must already exist or queries will throw errors.
# Changing this value requires to run ./utils/setup --create-functions --setup-website.
NOMINATIM_USE_US_TIGER_DATA=no
# Search in the auxilary housenumber table.
# Changing this value requires to run ./utils/setup --create-functions --setup-website.
NOMINATIM_USE_AUX_LOCATION_DATA=no
# Proxy settings
# The following settings allow to set a proxy to use when remotely downloading
# data. Host and port are required. Login and password are optional.
NOMINATIM_HTTP_PROXY=no
NOMINATIM_HTTP_PROXY_HOST=proxy.mydomain.com
NOMINATIM_HTTP_PROXY_PORT=3128
NOMINATIM_HTTP_PROXY_LOGIN=
NOMINATIM_HTTP_PROXY_PASSWORD=
# Location of the osm2pgsql binary.
# When empty, osm2pgsql is expected to reside in the osm2pgsql directory in
# the project directory.
# EXPERT ONLY. You should usually use the supplied osm2pgsql.
NOMINATIM_OSM2PGSQL_BINARY=
# Location of pyosmium-get-changes.
# Only needed when running updates.
NOMINATIM_PYOSMIUM_BINARY=
# Directory where to find US Tiger data files to import.
# Used with setup.php --import-tiger-data. When unset, the data is expected
# to be located under 'data/tiger' in the source tree.
NOMINATIM_TIGER_DATA_PATH=
# Directory where to find pre-computed Wikipedia importance files.
# When unset, the data is expected to be located in the 'data' directory
# in the source tree.
NOMINATIM_WIKIPEDIA_DATA_PATH=
# Configuration file for special phrase import.
# When unset, the internal default settings from 'settings/phrase_settings.php'
# are used.
NOMINATIM_PHRASE_CONFIG=
# Configuration file for rank assignments.
# When unset, the internal default settings from 'settings/address-levels.json'
# are used.
NOMINATIM_ADDRESS_LEVEL_CONFIG=
# Configuration file for OSM data import.
# This may either be the name of one of an internal style or point
# to a file with a custom style.
# Internal styles are: admin, street, address, full, extratags
NOMNIATIM_IMPORT_STYLE=extratags
# Location of the flatnode file used by osm2pgsql to store node locations.
# When unset, osm2pgsql stores the location in the PostgreSQL database. This
# is especially useful for imports of larger areas, like continents or the
# full planet. The file needs at least 70GB storage.
NOMINATIM_FLATNODE_FILE=
### Tablespace settings
#
#/* Set to true after importing Tiger house number data for the US.
# Note: The tables must already exist or queries will throw errors.
# After changing this setting run ./utils/setup --create-functions
# again. */
#@define('CONST_Use_US_Tiger_Data', false);
#/* Set to true after importing other external house number data.
# Note: the aux tables must already exist or queries will throw errors.
# After changing this setting run ./utils/setup --create-functions
# again. */
#@define('CONST_Use_Aux_Location_data', false);
# The following settings allow to move parts of the database tables into
# different tablespaces. This is especially interesting if you have disks
# with different speeds. When unset, the default tablespace is used.
# Only has an effect during import.
# Tablespace used for tables used when searching.
NOMINATIM_TABLESPACE_SEARCH_DATA=
# Tablespace used for indexes used when searching.
NOMINATIM_TABLESPACE_SEARCH_INDEX=
# Tablespace used for the OSM data cache tables. Used for import and update only.
NOMINATIM_TABLESPACE_OSM_DATA=
# Tablespace used for the OSM data cache indexes. Used for import and update only.
NOMINATIM_TABLESPACE_OSM_INDEX=
# Tablespace used for place import table. Used for import and update only.
NOMINATIM_TABLESPACE_PLACE_DATA=
# Tablespace used for place import indexes. Used for import and update only.
NOMINATIM_TABLESPACE_PLACE_INDEX=
# Tablespace for tables used during address computation. Used for import and update only.
NOMINATIM_TABLESPACE_ADDRESS_DATA=
# Tablespace for indexes used during address computation. Used for import and update only.
NOMINATIM_TABLESPACE_ADDRESS_INDEX=
# Tablespace for tables for auxilary data, e.g. TIGER data, postcodes.
NOMINATIM_TABLESPACE_AUX_DATA=
# Tablespace for indexes for auxilary data, e.g. TIGER data, postcodes.
NOMINATIM_TABLESPACE_AUX_INDEX=
### Replication settings
#
#// Proxy settings
#@define('CONST_HTTP_Proxy', false);
#@define('CONST_HTTP_Proxy_Host', 'proxy.mydomain.com');
#@define('CONST_HTTP_Proxy_Port', '3128');
#@define('CONST_HTTP_Proxy_Login', '');
#@define('CONST_HTTP_Proxy_Password', '');
# The following settings control where and how updates for the database are
# retrieved.
#
#// Paths
#@define('CONST_ExtraDataPath', CONST_BasePath.'/data');
#@define('CONST_Osm2pgsql_Binary', CONST_InstallPath.'/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');
#
#// osm2pgsql settings
#@define('CONST_Osm2pgsql_Flatnode_File', null);
# Base URL of replication service.
# A replication service provides change files of OSM data at regular intervals.
# These are used to keep the database up to date. Per default it points to
# the minutely updates for the main OSM database. There are other services
# geared towards larger update intervals or data extracts.
# Changing this value requires to rerun 'update/php --init-updates'.
NOMINATIM_REPLICATION_URL="https://planet.openstreetmap.org/replication/minute"
# Maximum amount of data to download per batch.
# Size is in MB.
NOMINATIM_REPLICATION_MAX_DIFF=50
# Publication interval of the replication service.
# Determines when Nominatim will attempt again to download again a new
# update. The time is computed from the publication date of the last diff
# downloaded. Setting this to a slightly higher value than the actual
# publication interval avoids unnecessary rechecks.
NOMINATIM_REPLICATION_UPDATE_INTERVAL=75
# Wait time to recheck for a pending update.
# Time to wait after an expected update was not available on the server.
NOMINATIM_REPLICATION_RECHECK_INTERVAL=60
### API settings
#
#// tablespace settings
#// osm2pgsql caching tables (aka slim mode tables) - update only
#@define('CONST_Tablespace_Osm2pgsql_Data', false);
#@define('CONST_Tablespace_Osm2pgsql_Index', false);
#// osm2pgsql output tables (aka main table) - update only
#@define('CONST_Tablespace_Place_Data', false);
#@define('CONST_Tablespace_Place_Index', false);
#// address computation tables - update only
#@define('CONST_Tablespace_Address_Data', false);
#@define('CONST_Tablespace_Address_Index', false);
#// search tables - needed for lookups
#@define('CONST_Tablespace_Search_Data', false);
#@define('CONST_Tablespace_Search_Index', false);
#// additional data, e.g. TIGER data, type searches - needed for lookups
#@define('CONST_Tablespace_Aux_Data', false);
#@define('CONST_Tablespace_Aux_Index', false);
# The following settings configure the API responses. You must rerun
# setup.php --setup-website after changing any of them.
# Send permissive CORS access headers.
# When enabled, send CORS headers to allow access to everybody.
NOMINATIM_CORS_NOACCESSCONTROL=yes
# URL for static icon images.
# Set this to the /mapicon directory of your nominatim-ui to enable returning
# icon URLs with the results.
NOMINATIM_MAPICON_URL=
# Language to assume when no particular language is requested.
# When unset, the local language (i.e. the name tag without suffix) will be used.
NOMINATIM_DEFAULT_LANGUAGE=
# Enable a special batch query mode.
# This features is currently undocumented and potentially broken.
NOMINATIM_SEARCH_BATCH_MODE=no
# Threshold for searches by name only.
# Threshold where the lookup strategy in the database is switched. If there
# are less occurences of a tem than given, the search does the lookup only
# against the name, otherwise it uses indexes for name and address.
NOMINATIM_SEARCH_NAME_ONLY_THRESHOLD=500
# Maximum number of OSM ids accepted by /lookup.
NOMINATIM_LOOKUP_MAX_COUNT=50
# Number of different geometry formats that may be queried in parallel.
# Set to zero to disable polygon output.
NOMINATIM_POLYGON_OUTPUT_MAX_TYPES=1
### Log settings
#
#//// Replication settings
# The following options allow to enable logging of API requests.
# You must rerun setup.php --setup-website after changing any of them.
#
#// Base URL of replication service
#@define('CONST_Replication_Url', 'https://planet.openstreetmap.org/replication/minute');
#
#// Maximum size in MB of data to download per batch
#@define('CONST_Replication_Max_Diff_size', '30');
#// How long until the service publishes the next diff
#// (relative to the age of data in the diff).
#@define('CONST_Replication_Update_Interval', '75');
#// How long to sleep when no update could be found
#@define('CONST_Replication_Recheck_Interval', '60');
#
#// If true, send CORS headers to allow access
#@define('CONST_NoAccessControl', true);
#
#// Set this to the /mapicon directory of your nominatim-ui to enable returning
#// icon URLs with the results.
#@define('CONST_MapIcon_URL', false);
#// Language to assume when none is supplied with the query.
#// When set to false, the local language (i.e. the name tag without suffix)
#// will be used.
#@define('CONST_Default_Language', false);
#
#@define('CONST_Search_AreaPolygons', true);
#
#@define('CONST_Search_BatchMode', false);
#
#@define('CONST_Search_NameOnlySearchFrequencyThreshold', 500);
#// If set to true, then reverse order of queries will be tried by default.
#// When set to false only selected languages allow reverse search.
#@define('CONST_Search_ReversePlanForAll', true);
#
#// Maximum number of OSM ids that may be queried at once
#// for the places endpoint.
#@define('CONST_Places_Max_ID_count', 50);
#
#// Number of different geometry formats that may be queried in parallel.
#// Set to zero to disable polygon output.
#@define('CONST_PolygonOutput_MaximumTypes', 1);
#
#// Log settings
#// Set to true to log into new_query_log table.
#// You should set up a cron job that regularly clears out this table.
#@define('CONST_Log_DB', false);
#// Set to a file name to enable logging to a file.
#@define('CONST_Log_File', false);
# Enable logging of requests into the DB.
# The request will be logged into the new_query_log table.
# You should set up a cron job that regularly clears out this table.
NOMINATIM_LOG_DB=no
# Enable logging of requests into a file.
# To enable logging set this setting to the file to log to.
NOMINATIM_LOG_FILE=

View File

@@ -2,6 +2,8 @@
require_once(CONST_LibDir.'/init-cmd.php');
loadSettings(false);
$term_colors = array(
'green' => "\033[92m",
'red' => "\x1B[31m",
@@ -166,7 +168,7 @@ END;
if (CONST_Use_US_Tiger_Data) {
if (getSettingBool('USE_US_TIGER_DATA')) {
echo 'Checking TIGER table exists ... ';
if ($oDB->tableExists('location_property_tiger')) {
$print_success();

View File

@@ -16,8 +16,6 @@ getCmdOpt($_SERVER['argv'], $aCMDOptions, $aCMDResult, true, true);
setupHTTPProxy();
include(CONST_Phrase_Config);
if (true) {
$sURL = 'https://wiki.openstreetmap.org/wiki/Special:Export/Nominatim/Country_Codes';
$sWikiPageXML = file_get_contents($sURL);

View File

@@ -118,7 +118,11 @@ if ($aCMDResult['load-data'] || $aCMDResult['all']) {
if ($aCMDResult['import-tiger-data']) {
$bDidSomething = true;
$oSetup->importTigerData();
$sTigerPath = getSetting('TIGER_DATA_PATH');
if (!$sTigerPath) {
$sTigerPath = CONST_DataDir.'/data/tiger';
}
$oSetup->importTigerData($sTigerPath);
}
if ($aCMDResult['calculate-postcodes'] || $aCMDResult['all']) {

View File

@@ -16,15 +16,17 @@ getCmdOpt($_SERVER['argv'], $aCMDOptions, $aCMDResult, true, true);
setupHTTPProxy();
include(CONST_Phrase_Config);
include(getSettingConfig('PHRASE_CONFIG', 'phrase_settings.php'));
if ($aCMDResult['wiki-import']) {
$oNormalizer = Transliterator::createFromRules(CONST_Term_Normalization_Rules);
$oNormalizer = Transliterator::createFromRules(getSetting('TERM_NORMALIZATION'));
$aPairs = array();
$sLanguageIn = CONST_Languages ? CONST_Languages :
('af,ar,br,ca,cs,de,en,es,et,eu,fa,fi,fr,gl,hr,hu,'.
'ia,is,it,ja,mk,nl,no,pl,ps,pt,ru,sk,sl,sv,uk,vi');
$sLanguageIn = getSetting(
LANGUAGES,
'af,ar,br,ca,cs,de,en,es,et,eu,fa,fi,fr,gl,hr,hu,'.
'ia,is,it,ja,mk,nl,no,pl,ps,pt,ru,sk,sl,sv,uk,vi';
);
foreach (explode(',', $sLanguageIn) as $sLanguage) {
$sURL = 'https://wiki.openstreetmap.org/wiki/Special:Export/Nominatim/Special_Phrases/'.strtoupper($sLanguage);

View File

@@ -67,7 +67,7 @@ if ($iCacheMemory + 500 > getTotalMemoryMB()) {
echo "WARNING: resetting cache memory to $iCacheMemory\n";
}
$oOsm2pgsqlCmd = (new \Nominatim\Shell(CONST_Osm2pgsql_Binary))
$oOsm2pgsqlCmd = (new \Nominatim\Shell(getOsm2pgsqlBinary()))
->addParams('--hstore')
->addParams('--latlong')
->addParams('--append')
@@ -77,7 +77,7 @@ $oOsm2pgsqlCmd = (new \Nominatim\Shell(CONST_Osm2pgsql_Binary))
->addParams('--number-processes', 1)
->addParams('--cache', $iCacheMemory)
->addParams('--output', 'gazetteer')
->addParams('--style', CONST_Import_Style)
->addParams('--style', getImportStyle())
->addParams('--database', $aDSNInfo['database'])
->addParams('--port', $aDSNInfo['port']);
@@ -90,8 +90,8 @@ if (isset($aDSNInfo['username']) && $aDSNInfo['username']) {
if (isset($aDSNInfo['password']) && $aDSNInfo['password']) {
$oOsm2pgsqlCmd->addEnvPair('PGPASSWORD', $aDSNInfo['password']);
}
if (!is_null(CONST_Osm2pgsql_Flatnode_File) && CONST_Osm2pgsql_Flatnode_File) {
$oOsm2pgsqlCmd->addParams('--flat-nodes', CONST_Osm2pgsql_Flatnode_File);
if (getSetting('FLATNODE_FILE')) {
$oOsm2pgsqlCmd->addParams('--flat-nodes', getSetting('FLATNODE_FILE'));
}
if ($fPostgresVersion >= 11.0) {
$oOsm2pgsqlCmd->addEnvPair(
@@ -121,31 +121,34 @@ if (isset($aDSNInfo['password']) && $aDSNInfo['password']) {
$oIndexCmd->addEnvPair('PGPASSWORD', $aDSNInfo['password']);
}
$sPyosmiumBin = getSetting('PYOSMIUM_BINARY');
$sBaseURL = getSetting('REPLICATION_URL');
if ($aResult['init-updates']) {
// sanity check that the replication URL is correct
$sBaseState = file_get_contents(CONST_Replication_Url.'/state.txt');
$sBaseState = file_get_contents($sBaseURL.'/state.txt');
if ($sBaseState === false) {
echo "\nCannot find state.txt file at the configured replication URL.\n";
echo "Does the URL point to a directory containing OSM update data?\n\n";
fail('replication URL not reachable.');
}
// sanity check for pyosmium-get-changes
if (!CONST_Pyosmium_Binary) {
echo "\nCONST_Pyosmium_Binary not configured.\n";
if (!$sPyosmiumBin) {
echo "\nNOMINATIM_PYOSMIUM_BINARY not configured.\n";
echo "You need to install pyosmium and set up the path to pyosmium-get-changes\n";
echo "in your local settings file.\n\n";
fail('CONST_Pyosmium_Binary not configured');
echo "in your local .env file.\n\n";
fail('NOMINATIM_PYOSMIUM_BINARY not configured');
}
$aOutput = 0;
$oCMD = new \Nominatim\Shell(CONST_Pyosmium_Binary, '--help');
$oCMD = new \Nominatim\Shell($sPyosmiumBin, '--help');
exec($oCMD->escapedCmd(), $aOutput, $iRet);
if ($iRet != 0) {
echo "Cannot execute pyosmium-get-changes.\n";
echo "Make sure you have pyosmium installed correctly\n";
echo "and have set up CONST_Pyosmium_Binary to point to pyosmium-get-changes.\n";
echo "and have set up NOMINATIM_PYOSMIUM_BINARY to point to pyosmium-get-changes.\n";
fail('pyosmium-get-changes not found or not usable');
}
@@ -166,9 +169,9 @@ if ($aResult['init-updates']) {
// get the appropriate state id
$aOutput = 0;
$oCMD = (new \Nominatim\Shell(CONST_Pyosmium_Binary))
$oCMD = (new \Nominatim\Shell($sPyosmiumBin))
->addParams('--start-date', $sWindBack)
->addParams('--server', CONST_Replication_Url);
->addParams('--server', $sBaseURL);
exec($oCMD->escapedCmd(), $aOutput, $iRet);
if ($iRet != 0 || $aOutput[0] == 'None') {
@@ -196,7 +199,7 @@ if ($aResult['check-for-updates']) {
}
$oCmd = (new \Nominatim\Shell(CONST_BinDir.'/check_server_for_updates.py'))
->addParams(CONST_Replication_Url)
->addParams($sBaseURL)
->addParams($aLastState['sequence_id']);
$iRet = $oCmd->run();
@@ -293,8 +296,9 @@ if ($aResult['index']) {
}
if ($aResult['update-address-levels']) {
echo 'Updating address levels from '.CONST_Address_Level_Config.".\n";
$oAlParser = new \Nominatim\Setup\AddressLevelParser(CONST_Address_Level_Config);
$sAddressLevelConfig = getSettingConfig('ADDRESS_LEVEL_CONFIG', 'address-levels.json');
echo 'Updating address levels from '.$sAddressLevelConfig.".\n";
$oAlParser = new \Nominatim\Setup\AddressLevelParser($sAddressLevelConfig);
$oAlParser->createTable($oDB, 'address_levels');
}
@@ -317,17 +321,17 @@ if ($aResult['recompute-importance']) {
if ($aResult['import-osmosis'] || $aResult['import-osmosis-all']) {
//
if (strpos(CONST_Replication_Url, 'download.geofabrik.de') !== false && CONST_Replication_Update_Interval < 86400) {
if (strpos($sBaseURL, 'download.geofabrik.de') !== false && getSetting('REPLICATION_UPDATE_INTERVAL') < 86400) {
fail('Error: Update interval too low for download.geofabrik.de. ' .
"Please check install documentation (https://nominatim.org/release-docs/latest/admin/Import-and-Update#setting-up-the-update-process)\n");
}
$sImportFile = CONST_InstallDir.'/osmosischange.osc';
$oCMDDownload = (new \Nominatim\Shell(CONST_Pyosmium_Binary))
->addParams('--server', CONST_Replication_Url)
$oCMDDownload = (new \Nominatim\Shell($sPyosmiumBin))
->addParams('--server', $sBaseURL)
->addParams('--outfile', $sImportFile)
->addParams('--size', CONST_Replication_Max_Diff_size);
->addParams('--size', getSetting('REPLICATION_MAX_DIFF'));
$oCMDImport = (clone $oOsm2pgsqlCmd)->addParams($sImportFile);
@@ -347,7 +351,7 @@ if ($aResult['import-osmosis'] || $aResult['import-osmosis-all']) {
if ($aLastState['indexed']) {
// Sleep if the update interval has not yet been reached.
$fNextUpdate = $aLastState['unix_ts'] + CONST_Replication_Update_Interval;
$fNextUpdate = $aLastState['unix_ts'] + getSetting('REPLICATION_UPDATE_INTERVAL');
if ($fNextUpdate > $fStartTime) {
$iSleepTime = $fNextUpdate - $fStartTime;
echo "Waiting for next update for $iSleepTime sec.";
@@ -368,8 +372,9 @@ if ($aResult['import-osmosis'] || $aResult['import-osmosis-all']) {
exec($oCMD->escapedCmd(), $aOutput, $iResult);
if ($iResult == 3) {
echo 'No new updates. Sleeping for '.CONST_Replication_Recheck_Interval." sec.\n";
sleep(CONST_Replication_Recheck_Interval);
$sSleep = getSetting('REPLICATION_RECHECK_INTERVAL');
echo 'No new updates. Sleeping for '.$sSleep." sec.\n";
sleep($sSleep);
} elseif ($iResult != 0) {
echo 'ERROR: updates failed.';
exit($iResult);

View File

@@ -15,15 +15,6 @@ $oGeocode = new Nominatim\Geocode($oDB);
$aLangPrefOrder = $oParams->getPreferredLanguages();
$oGeocode->setLanguagePreference($aLangPrefOrder);
if (CONST_Search_ReversePlanForAll
|| isset($aLangPrefOrder['name:de'])
|| isset($aLangPrefOrder['name:ru'])
|| isset($aLangPrefOrder['name:ja'])
|| isset($aLangPrefOrder['name:pl'])
) {
$oGeocode->setReverseInPlan(true);
}
// Format for output
$sOutputFormat = $oParams->getSet('format', array('xml', 'json', 'jsonv2', 'geojson', 'geocodejson'), 'jsonv2');
set_exception_handler_by_format($sOutputFormat);