X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/e5eb7ecdc1e0dd054a3aa166d32391c115d20405..aa5f27fb91a567b489032a2788debfee38380461:/utils/update.php diff --git a/utils/update.php b/utils/update.php index c3620b06..7b9338d5 100644 --- a/utils/update.php +++ b/utils/update.php @@ -42,12 +42,14 @@ $aCMDOptions array('deduplicate', '', 0, 1, 0, 0, 'bool', 'Deduplicate tokens'), 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('recompute-importance', '', 0, 1, 0, 0, 'bool', 'Recompute place importances'), array('no-npi', '', 0, 1, 0, 0, 'bool', '(obsolete)'), ); getCmdOpt($_SERVER['argv'], $aCMDOptions, $aResult, true, true); if (!isset($aResult['index-instances'])) $aResult['index-instances'] = 1; + if (!isset($aResult['index-rank'])) $aResult['index-rank'] = 0; date_default_timezone_set('Etc/UTC'); @@ -80,6 +82,14 @@ if (!is_null(CONST_Osm2pgsql_Flatnode_File) && CONST_Osm2pgsql_Flatnode_File) { $sOsm2pgsqlCmd .= ' --flat-nodes '.CONST_Osm2pgsql_Flatnode_File; } +$sIndexCmd = CONST_BasePath.'/nominatim/nominatim.py'; +if (!$aResult['quiet']) { + $sIndexCmd .= ' -v'; +} +if ($aResult['verbose']) { + $sIndexCmd .= ' -v'; +} + if ($aResult['init-updates']) { // sanity check that the replication URL is correct $sBaseState = file_get_contents(CONST_Replication_Url.'/state.txt'); @@ -301,7 +311,11 @@ if ($aResult['recompute-word-counts']) { } if ($aResult['index']) { - $sCmd = CONST_InstallPath.'/nominatim/nominatim -i -d '.$aDSNInfo['database'].' -P '.$aDSNInfo['port'].' -t '.$aResult['index-instances'].' -r '.$aResult['index-rank']; + $sCmd = $sIndexCmd + .' -d '.$aDSNInfo['database'] + .' -P '.$aDSNInfo['port'] + .' -t '.$aResult['index-instances'] + .' -r '.$aResult['index-rank']; if (isset($aDSNInfo['hostspec']) && $aDSNInfo['hostspec']) { $sCmd .= ' -H ' . $aDSNInfo['hostspec']; } @@ -320,17 +334,37 @@ if ($aResult['update-address-levels']) { $oAlParser->createTable($oDB, 'address_levels'); } +if ($aResult['recompute-importance']) { + echo "Updating importance values for database.\n"; + $oDB = new Nominatim\DB(); + $oDB->connect(); + + $sSQL = 'ALTER TABLE placex DISABLE TRIGGER ALL;'; + $sSQL .= 'UPDATE placex SET (wikipedia, importance) ='; + $sSQL .= ' (SELECT wikipedia, importance'; + $sSQL .= ' FROM compute_importance(extratags, country_code, osm_type, osm_id));'; + $sSQL .= 'UPDATE placex s SET wikipedia = d.wikipedia, importance = d.importance'; + $sSQL .= ' FROM placex d'; + $sSQL .= ' WHERE s.place_id = d.linked_place_id and d.wikipedia is not null'; + $sSQL .= ' and (s.wikipedia is null or s.importance < d.importance);'; + $sSQL .= 'ALTER TABLE placex ENABLE TRIGGER ALL;'; + $oDB->exec($sSQL); +} + if ($aResult['import-osmosis'] || $aResult['import-osmosis-all']) { // if (strpos(CONST_Replication_Url, 'download.geofabrik.de') !== false && CONST_Replication_Update_Interval < 86400) { fail('Error: Update interval too low for download.geofabrik.de. ' . - "Please check install documentation (http://nominatim.org/release-docs/latest/Import-and-Update#setting-up-the-update-process)\n"); + "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'; $sCMDDownload = CONST_Pyosmium_Binary.' --server '.CONST_Replication_Url.' -o '.$sImportFile.' -s '.CONST_Replication_Max_Diff_size; $sCMDImport = $sOsm2pgsqlCmd.' '.$sImportFile; - $sCMDIndex = CONST_InstallPath.'/nominatim/nominatim -i -d '.$aDSNInfo['database'].' -P '.$aDSNInfo['port'].' -t '.$aResult['index-instances']; + $sCMDIndex = $sIndexCmd + .' -d '.$aDSNInfo['database'] + .' -P '.$aDSNInfo['port'] + .' -t '.$aResult['index-instances']; if (isset($aDSNInfo['hostspec']) && $aDSNInfo['hostspec']) { $sCMDIndex .= ' -H ' . $aDSNInfo['hostspec']; }