Merge pull request #2212 from darkshredder/country-name

Ported createCountryNames() to python and Added tests
This commit is contained in:
Sarah Hoffmann
2021-03-15 09:36:06 +01:00
committed by GitHub
7 changed files with 73 additions and 31 deletions

View File

@@ -198,7 +198,7 @@ if ($aCMDResult['create-search-indices'] || $aCMDResult['all']) {
if ($aCMDResult['create-country-names'] || $aCMDResult['all']) {
$bDidSomething = true;
$oSetup->createCountryNames($aCMDResult);
run(clone($oNominatimCmd))->addParams('transition', '--create-country-names');
}
if ($aCMDResult['setup-website'] || $aCMDResult['all']) {

View File

@@ -130,33 +130,6 @@ class SetupFunctions
$this->db()->exec($sSQL);
}
public function createCountryNames()
{
info('Create search index for default country names');
$this->pgsqlRunScript("select getorcreate_country(make_standard_name('uk'), 'gb')");
$this->pgsqlRunScript("select getorcreate_country(make_standard_name('united states'), 'us')");
$this->pgsqlRunScript('select count(*) from (select getorcreate_country(make_standard_name(country_code), country_code) from country_name where country_code is not null) as x');
$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 ';
$sLanguages = getSetting('LANGUAGES');
if ($sLanguages) {
$sSQL .= 'in ';
$sDelim = '(';
foreach (explode(',', $sLanguages) as $sLang) {
$sSQL .= $sDelim."'name:$sLang'";
$sDelim = ',';
}
$sSQL .= ')';
} else {
// all include all simple name tags
$sSQL .= "like 'name:%'";
}
$sSQL .= ') v';
$this->pgsqlRunScript($sSQL);
}
/**
* Return the connection to the database.
*