]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib/SearchDescription.php
Add reverse-only parameter to setup
[nominatim.git] / lib / SearchDescription.php
index ec14e54600ee11f106d83b54ab6510b9b98be708..bf32df9642e40a9fd03edae98f0554079bd86d29 100644 (file)
@@ -448,11 +448,18 @@ class SearchDescription
 
             //now search for housenumber, if housenumber provided
             if ($this->sHouseNumber && !empty($aResults)) {
 
             //now search for housenumber, if housenumber provided
             if ($this->sHouseNumber && !empty($aResults)) {
-                $aNamedPlaceIDs = $aResults;
-                $aResults = $this->queryHouseNumber($oDB, $aNamedPlaceIDs);
+                // Downgrade the rank of the street results, they are missing
+                // the housenumber.
+                foreach ($aResults as $oRes) {
+                    $oRes->iResultRank++;
+                }
+
+                $aHnResults = $this->queryHouseNumber($oDB, $aResults);
 
 
-                if (empty($aResults) && $this->looksLikeFullAddress()) {
-                    $aResults = $aNamedPlaceIDs;
+                if (!empty($aHnResults)) {
+                    foreach ($aHnResults as $oRes) {
+                        $aResults[$oRes->iId] = $oRes;
+                    }
                 }
             }
 
                 }
             }
 
@@ -469,16 +476,13 @@ class SearchDescription
             if ($sPlaceIds) {
                 $sSQL = 'SELECT place_id FROM placex';
                 $sSQL .= ' WHERE place_id in ('.$sPlaceIds.')';
             if ($sPlaceIds) {
                 $sSQL = 'SELECT place_id FROM placex';
                 $sSQL .= ' WHERE place_id in ('.$sPlaceIds.')';
-                $sSQL .= " AND postcode = '".$this->sPostcode."'";
+                $sSQL .= " AND postcode != '".$this->sPostcode."'";
                 Debug::printSQL($sSQL);
                 $aFilteredPlaceIDs = chksql($oDB->getCol($sSQL));
                 if ($aFilteredPlaceIDs) {
                 Debug::printSQL($sSQL);
                 $aFilteredPlaceIDs = chksql($oDB->getCol($sSQL));
                 if ($aFilteredPlaceIDs) {
-                    $aNewResults = array();
                     foreach ($aFilteredPlaceIDs as $iPlaceId) {
                     foreach ($aFilteredPlaceIDs as $iPlaceId) {
-                        $aNewResults[$iPlaceId] = $aResults[$iPlaceId];
+                        $aResults[$iPlaceId]->iResultRank++;
                     }
                     }
-                    $aResults = $aNewResults;
-                    Debug::printVar('Place IDs after postcode filtering', $aResults);
                 }
             }
         }
                 }
             }
         }