}
- function getWordSuggestions(&$oDB, $sWord)
- {
- $sWordQuoted = getDBQuoted(trim($sWord));
- $sSQL = "select *,levenshtein($sWordQuoted,word) from test_token ";
- $sSQL .= "where (metaphone = dmetaphone($sWordQuoted) or metaphonealt = dmetaphone($sWordQuoted) or ";
- $sSQL .= "metaphone = dmetaphone_alt($sWordQuoted) or metaphonealt = dmetaphone_alt($sWordQuoted)) ";
- $sSQL .= "and len between length($sWordQuoted)-2 and length($sWordQuoted)+2 ";
- $sSQL .= "and levenshtein($sWordQuoted,word) < 3 ";
- $sSQL .= "order by levenshtein($sWordQuoted,word) asc, abs(len - length($sWordQuoted)) asc limit 20";
- $aSimilar = $oDB->getAll($sSQL);
- return $aSimilar;
- }
-
-
function geocodeReverse($fLat, $fLon, $iZoom=18)
{
$oDB =& getDB();
@define('CONST_Search_AreaPolygons_Enabled', true);
@define('CONST_Search_AreaPolygons', true);
- @define('CONST_Suggestions_Enabled', false);
-
@define('CONST_Search_TryDroppedAddressTerms', false);
@define('CONST_Search_NameOnlySearchFrequencyThreshold', false);
$aSearchResults = array();
$aExcludePlaceIDs = array();
$sCountryCodesSQL = false;
- $sSuggestion = $sSuggestionURL = false;
$bDeDupe = isset($_GET['dedupe'])?(bool)$_GET['dedupe']:true;
$bReverseInPlan = false;
$iFinalLimit = isset($_GET['limit'])?(int)$_GET['limit']:10;
}
if (CONST_Debug) var_Dump($aPhrases, $aValidTokens);
- $aSuggestion = array();
- $bSuggestion = false;
- if (CONST_Suggestions_Enabled)
- {
- foreach($aPhrases as $iPhrase => $aPhrase)
- {
- if (!isset($aValidTokens[' '.$aPhrase['wordsets'][0][0]]))
- {
- $sQuotedPhrase = getDBQuoted(' '.$aPhrase['wordsets'][0][0]);
- $aSuggestionWords = getWordSuggestions($oDB, $aPhrase['wordsets'][0][0]);
- $aRow = $aSuggestionWords[0];
- if ($aRow && $aRow['word'])
- {
- $aSuggestion[] = $aRow['word'];
- $bSuggestion = true;
- }
- else
- {
- $aSuggestion[] = $aPhrase['string'];
- }
- }
- else
- {
- $aSuggestion[] = $aPhrase['string'];
- }
- }
- }
- if ($bSuggestion) $sSuggestion = join(', ',$aSuggestion);
-
// Try and calculate GB postcodes we might be missing
foreach($aTokens as $sToken)
{
if ($bShowAddressDetails) $sMoreURL .= '&addressdetails=1';
if (isset($_GET['viewbox']) && $_GET['viewbox']) $sMoreURL .= '&viewbox='.urlencode($_GET['viewbox']);
if (isset($_GET['nearlat']) && isset($_GET['nearlon'])) $sMoreURL .= '&nearlat='.(float)$_GET['nearlat'].'&nearlon='.(float)$_GET['nearlon'];
- if ($sSuggestion)
- {
- $sSuggestionURL = $sMoreURL.'&q='.urlencode($sSuggestion);
- }
$sMoreURL .= '&q='.urlencode($sQuery);
if (CONST_Debug) exit;