]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib-php/SearchDescription.php
Merge remote-tracking branch 'upstream/master'
[nominatim.git] / lib-php / SearchDescription.php
index fbf6b650bc9ee8dffcdfc738e15239e5d2bc69a9..b98c2e723ae7e4419facfed29ddb426725af314c 100644 (file)
@@ -264,6 +264,8 @@ class SearchDescription
     {
         if (empty($this->aName)) {
             $this->bNameNeedsAddress = $bNeedsAddress;
     {
         if (empty($this->aName)) {
             $this->bNameNeedsAddress = $bNeedsAddress;
+        } elseif ($bSearchable && count($this->aName) >= 2) {
+            $this->bNameNeedsAddress = false;
         } else {
             $this->bNameNeedsAddress &= $bNeedsAddress;
         }
         } else {
             $this->bNameNeedsAddress &= $bNeedsAddress;
         }
@@ -642,6 +644,7 @@ class SearchDescription
             // Housenumbers on streets and places.
             $sPlacexSql = 'SELECT array_agg(place_id) FROM placex';
             $sPlacexSql .= ' WHERE parent_place_id = sin.place_id AND sin.address_rank < 30';
             // Housenumbers on streets and places.
             $sPlacexSql = 'SELECT array_agg(place_id) FROM placex';
             $sPlacexSql .= ' WHERE parent_place_id = sin.place_id AND sin.address_rank < 30';
+            $sPlacexSql .= $this->oContext->excludeSQL(' AND place_id');
             $sPlacexSql .= '       and housenumber ~* E'.$sHouseNumberRegex;
 
             // Interpolations on streets and places.
             $sPlacexSql .= '       and housenumber ~* E'.$sHouseNumberRegex;
 
             // Interpolations on streets and places.
@@ -804,6 +807,7 @@ class SearchDescription
                 $sSQL = 'SELECT geometry FROM placex';
                 $sSQL .= " WHERE place_id in ($sPlaceIDs)";
                 $sSQL .= "   AND rank_search < $iMaxRank + 5";
                 $sSQL = 'SELECT geometry FROM placex';
                 $sSQL .= " WHERE place_id in ($sPlaceIDs)";
                 $sSQL .= "   AND rank_search < $iMaxRank + 5";
+                $sSQL .= '   AND ST_Area(Box2d(geometry)) < 20';
                 $sSQL .= "   AND ST_GeometryType(geometry) in ('ST_Polygon','ST_MultiPolygon')";
                 $sSQL .= ' ORDER BY rank_search ASC ';
                 $sSQL .= ' LIMIT 1';
                 $sSQL .= "   AND ST_GeometryType(geometry) in ('ST_Polygon','ST_MultiPolygon')";
                 $sSQL .= ' ORDER BY rank_search ASC ';
                 $sSQL .= ' LIMIT 1';