]> git.openstreetmap.org Git - nominatim.git/commitdiff
do not allow importance to become 0
authorSarah Hoffmann <lonvia@denofr.de>
Mon, 19 Feb 2018 22:24:12 +0000 (23:24 +0100)
committerSarah Hoffmann <lonvia@denofr.de>
Thu, 1 Mar 2018 21:37:45 +0000 (22:37 +0100)
Importance is weighed against a viewbox factor which disappears
when the importance is 0.

Fixes #930.

lib/Geocode.php
lib/SearchDescription.php

index d5647c761edbc90a7a575edf17227eb8789f1710..26fafb734fa93d2d0beddbff4e52557537d3fad4 100644 (file)
@@ -921,12 +921,12 @@ class Geocode
                 $aResult['importance'] = 0.001;
                 $aResult['foundorder'] = $aResult['addressimportance'];
             } else {
-                // Adjust importance for the number of exact string matches in the result
+                $aResult['importance'] = max(0.001, $aResult['importance']);
                 $aResult['importance'] *= $this->viewboxImportanceFactor(
                     $aResult['lon'],
                     $aResult['lat']
                 );
-                $aResult['importance'] = max(0.001, $aResult['importance']);
+                // Adjust importance for the number of exact string matches in the result
                 $iCountWords = 0;
                 $sAddress = $aResult['langaddress'];
                 foreach ($aRecheckWords as $i => $sWord) {
index c379fdf3bec852895d6eca462ddee97a3d8f8d12..a1910231ef8b53285ff561b52f1a00a1191c88ab 100644 (file)
@@ -679,7 +679,7 @@ class SearchDescription
         if ($this->sHouseNumber) {
             $sImportanceSQL = '- abs(26 - address_rank) + 3';
         } else {
-            $sImportanceSQL = '(CASE WHEN importance = 0 OR importance IS NULL THEN 0.75-(search_rank::float/40) ELSE importance END)';
+            $sImportanceSQL = '(CASE WHEN importance = 0 OR importance IS NULL THEN 0.75001-(search_rank::float/40) ELSE importance END)';
         }
         $sImportanceSQL .= $this->oContext->viewboxImportanceSQL('centroid');
         $aOrder[] = "$sImportanceSQL DESC";