X-Git-Url: https://git.openstreetmap.org/nominatim.git/blobdiff_plain/ec2d491dc8939ecf28ab84e26955bc7189618096..7db0da40ad02694b82fe9a387f277a58ca7c5fce:/utils/update.php diff --git a/utils/update.php b/utils/update.php index a18c1721..4317367a 100644 --- a/utils/update.php +++ b/utils/update.php @@ -42,6 +42,7 @@ $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)'), ); @@ -320,6 +321,23 @@ 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) { @@ -352,7 +370,7 @@ if ($aResult['import-osmosis'] || $aResult['import-osmosis-all']) { $sBatchEnd = $aLastState['lastimportdate']; $iEndSequence = $aLastState['sequence_id']; - if ($aLastState['indexed'] == 't') { + if ($aLastState['indexed']) { // Sleep if the update interval has not yet been reached. $fNextUpdate = $aLastState['unix_ts'] + CONST_Replication_Update_Interval; if ($fNextUpdate > $fStartTime) {