X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/b5671859660be6fefc45b3caf9cc783103d9bbc2..3884eb7ca8e76c1a05afca16fc0cba8312102c64:/website/search.php diff --git a/website/search.php b/website/search.php index cea1ec03..0d398cc4 100755 --- a/website/search.php +++ b/website/search.php @@ -71,6 +71,7 @@ if (isset($aLangPrefOrder['name:de'])) $bReverseInPlan = true; if (isset($aLangPrefOrder['name:ru'])) $bReverseInPlan = true; if (isset($aLangPrefOrder['name:ja'])) $bReverseInPlan = true; + if (isset($aLangPrefOrder['name:pl'])) $bReverseInPlan = true; $sLanguagePrefArraySQL = "ARRAY[".join(',',array_map("getDBQuoted",$aLangPrefOrder))."]"; @@ -831,12 +832,19 @@ if ($sCountryCodesSQL) $sSQL .= " join placex using (place_id)"; $sSQL .= " where st_contains($sViewboxSmallSQL, ct.centroid)"; if ($sCountryCodesSQL) $sSQL .= " and country_code in ($sCountryCodesSQL)"; + if (sizeof($aExcludePlaceIDs)) + { + $sSQL .= " and place_id not in (".join(',',$aExcludePlaceIDs).")"; + } if ($sViewboxCentreSQL) $sSQL .= " order by st_distance($sViewboxCentreSQL, ct.centroid) asc"; $sSQL .= " limit $iLimit"; if (CONST_Debug) var_dump($sSQL); $aPlaceIDs = $oDB->getCol($sSQL); - if (!sizeof($aPlaceIDs)) + // If excluded place IDs are given, it is fair to assume that + // there have been results in the small box, so no further + // expansion in that case. + if (!sizeof($aPlaceIDs) && !sizeof($aExcludePlaceIDs)) { $sSQL = "select place_id from place_classtype_".$aSearch['sClass']."_".$aSearch['sType']." ct"; if ($sCountryCodesSQL) $sSQL .= " join placex using (place_id)"; @@ -925,12 +933,17 @@ else $sSQL .= " limit ".$iLimit; - if (CONST_Debug) { var_dump($sSQL); } + if (CONST_Debug) var_dump($sSQL); + $iStartTime = time(); $aViewBoxPlaceIDs = $oDB->getAll($sSQL); if (PEAR::IsError($aViewBoxPlaceIDs)) { failInternalError("Could not get places for search terms.", $sSQL, $aViewBoxPlaceIDs); } + if (time() - $iStartTime > 60) { + file_put_contents(CONST_BasePath.'/log/long_queries.log', date('Y-m-d H:i:s', $iStartTime).' '.$sSQL."\n", FILE_APPEND); + } + //var_dump($aViewBoxPlaceIDs); // Did we have an viewbox matches? $aPlaceIDs = array();