]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib/ReverseGeocode.php
Merge pull request #986 from mtmail/php-replace-sizeof
[nominatim.git] / lib / ReverseGeocode.php
index 0bcd3d3313f71e87c381558d1bc674607daed462..27f8c89cb5b3d90e555d1b3f76984cb32773da39 100644 (file)
@@ -132,9 +132,10 @@ class ReverseGeocode
                 $sSQL .= '   LIMIT 1000) as p WHERE';
             }
             $sSQL .= ' rank_search != 28 and rank_search >= '.$iMaxRank;
-            $sSQL .= ' and (name is not null or housenumber is not null)';
+            $sSQL .= ' and (name is not null or housenumber is not null';
+            $sSQL .= '      or rank_search between 26 and 27)';
             $sSQL .= ' and class not in (\'waterway\',\'railway\',\'tunnel\',\'bridge\',\'man_made\')';
-            $sSQL .= ' and indexed_status = 0 ';
+            $sSQL .= ' and indexed_status = 0 and linked_place_id is null';
             $sSQL .= ' and (ST_GeometryType(geometry) not in (\'ST_Polygon\',\'ST_MultiPolygon\') ';
             $sSQL .= ' OR ST_DWithin('.$sPointSQL.', centroid, '.$fSearchDiam.'))';
             $sSQL .= ' ORDER BY distance ASC limit 1';
@@ -205,9 +206,10 @@ class ReverseGeocode
             } else {
                 $iPlaceID = $oResult->iId;
             }
-            $sSQL  = 'select address_place_id';
-            $sSQL .= ' FROM place_addressline';
-            $sSQL .= " WHERE place_id = $iPlaceID";
+            $sSQL  = 'select a.address_place_id';
+            $sSQL .= ' FROM place_addressline a, placex p';
+            $sSQL .= " WHERE a.place_id = $iPlaceID and a.address_place_id = p.place_id";
+            $sSQL .= '   AND p.linked_place_id is null';
             $sSQL .= " ORDER BY abs(cached_rank_address - $iMaxRank) asc,cached_rank_address desc,isaddress desc,distance desc";
             $sSQL .= ' LIMIT 1';
             $iPlaceID = chksql($this->oDB->getOne($sSQL), 'Could not get parent for place.');