]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib/lib.php
give mild preference to results in viewbox
[nominatim.git] / lib / lib.php
index 998e0429740107343ad939e625bdf44fe3701bfe..3ed66237e955cdff43da2122cbcfe6bad6f52d19 100644 (file)
        }
 
 
        }
 
 
-       function getWordSets($aWords)
+       function getWordSets($aWords, $iDepth)
        {
                $aResult = array(array(join(' ',$aWords)));
                $sFirstToken = '';
        {
                $aResult = array(array(join(' ',$aWords)));
                $sFirstToken = '';
-               while(sizeof($aWords) > 1)
-               {
-                       $sWord = array_shift($aWords);
-                       $sFirstToken .= ($sFirstToken?' ':'').$sWord;
-                       $aRest = getWordSets($aWords);
-                       foreach($aRest as $aSet)
+               if ($iDepth < 7) {
+                       while(sizeof($aWords) > 1)
                        {
                        {
-                               $aResult[] = array_merge(array($sFirstToken),$aSet);
+                               $sWord = array_shift($aWords);
+                               $sFirstToken .= ($sFirstToken?' ':'').$sWord;
+                               $aRest = getWordSets($aWords, $iDepth+1);
+                               foreach($aRest as $aSet)
+                               {
+                                       $aResult[] = array_merge(array($sFirstToken),$aSet);
+                               }
                        }
                }
                return $aResult;
                        }
                }
                return $aResult;
        }
 
 
        }
 
 
-       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();
        function geocodeReverse($fLat, $fLon, $iZoom=18)
        {
                $oDB =& getDB();
                return $iPlaceID;
        }
 
                return $iPlaceID;
        }
 
-       function loadStructuredAddressElement(&$aStructuredQuery, &$iMinAddressRank, &$iMaxAddressRank, $aParams, $sKey, $iNewMinAddressRank, $iNewMaxAddressRank)
+       function loadStructuredAddressElement(&$aStructuredQuery, &$iMinAddressRank, &$iMaxAddressRank, &$aAddressRankList, $aParams, $sKey, $iNewMinAddressRank, $iNewMaxAddressRank, $aItemListValues)
        {
                if (!isset($_GET[$sKey])) return false;
                $sValue = trim($_GET[$sKey]);
        {
                if (!isset($_GET[$sKey])) return false;
                $sValue = trim($_GET[$sKey]);
                        $iMinAddressRank = $iNewMinAddressRank;
                        $iMaxAddressRank = $iNewMaxAddressRank;
                }
                        $iMinAddressRank = $iNewMinAddressRank;
                        $iMaxAddressRank = $iNewMaxAddressRank;
                }
+               if ($aItemListValues) $aAddressRankList = array_merge($aAddressRankList, $aItemListValues);
                return true;
        }
                return true;
        }
+
+       function addQuotes($s)
+       {
+               return "'".$s."'";
+       }