]> git.openstreetmap.org Git - nominatim.git/commitdiff
recheck the rank limits before dropping out of the search loop - otherwise we can...
authorBrian Quinion <brian.quinion@mapquest.com>
Tue, 11 Jun 2013 16:13:37 +0000 (17:13 +0100)
committerBrian Quinion <brian.quinion@mapquest.com>
Tue, 11 Jun 2013 16:13:37 +0000 (17:13 +0100)
website/search.php

index 76daa98c4bd73b1dee7bca99a62ced7f460b60e0..a29cb0cbfb9d77d89ca52c771304949c3eb15541 100755 (executable)
                                                if ($sViewboxLargeSQL) $sImportanceSQL .= " * case when ST_Contains($sViewboxLargeSQL, centroid) THEN 1 ELSE 0.5 END";
                                                $aOrder[] = "$sImportanceSQL DESC";
                                                if (sizeof($aSearch['aFullNameAddress']))
                                                if ($sViewboxLargeSQL) $sImportanceSQL .= " * case when ST_Contains($sViewboxLargeSQL, centroid) THEN 1 ELSE 0.5 END";
                                                $aOrder[] = "$sImportanceSQL DESC";
                                                if (sizeof($aSearch['aFullNameAddress']))
+                                               {
                                                        $aOrder[] = '(select count(*) from (select unnest(ARRAY['.join($aSearch['aFullNameAddress'],",").']) INTERSECT select unnest(nameaddress_vector))s) DESC';
                                                        $aOrder[] = '(select count(*) from (select unnest(ARRAY['.join($aSearch['aFullNameAddress'],",").']) INTERSECT select unnest(nameaddress_vector))s) DESC';
+                                               }
 
                                                if (sizeof($aTerms))
                                                {
 
                                                if (sizeof($aTerms))
                                                {
                                        if ($iQueryLoop > 20) break;
                                }
 
                                        if ($iQueryLoop > 20) break;
                                }
 
+                               if (isset($aResultPlaceIDs) && sizeof($aResultPlaceIDs) && ($iMinAddressRank != 0 || $iMaxAddressRank != 30))
+                               {
+                                       // Need to verify passes rank limits before dropping out of the loop (yuk!)
+                                       $sSQL = "select place_id from placex where place_id in (".join(',',$aResultPlaceIDs).") ";
+                                       $sSQL .= "and (placex.rank_address between $iMinAddressRank and $iMaxAddressRank ";
+                                       if (14 >= $iMinAddressRank && 14 <= $iMaxAddressRank) $sSQL .= " OR (extratags->'place') = 'city'";
+                                       if ($aAddressRankList) $sSQL .= " OR placex.rank_address in (".join(',',$aAddressRankList).")";
+                                       $sSQL .= ") ";
+                                       if (CONST_Debug) var_dump($sSQL);
+                                       $aResultPlaceIDs = $oDB->getCol($sSQL);
+                               }
+
+
                                //exit;
                                if (isset($aResultPlaceIDs) && sizeof($aResultPlaceIDs)) break;
                                if ($iGroupLoop > 4) break;
                                //exit;
                                if (isset($aResultPlaceIDs) && sizeof($aResultPlaceIDs)) break;
                                if ($iGroupLoop > 4) break;