]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib/lib.php
Merge remote-tracking branch 'upstream/master'
[nominatim.git] / lib / lib.php
index 3417c95b0e253968136ddeb996a3ca4236636a4f..07d5bcf370c60a1e1fe3078480ca9857406f3df6 100644 (file)
        }
 
 
-       function getPreferredLanguages()
+       function getPreferredLanguages($sLangString=false)
        {
-               // If we have been provided the value in $_GET it overrides browser value
-               if (isset($_GET['accept-language']) && $_GET['accept-language'])
+               if (!$sLangString)
                {
-                       $_SERVER["HTTP_ACCEPT_LANGUAGE"] = $_GET['accept-language'];
+                       // If we have been provided the value in $_GET it overrides browser value
+                       if (isset($_GET['accept-language']) && $_GET['accept-language'])
+                       {
+                               $_SERVER["HTTP_ACCEPT_LANGUAGE"] = $_GET['accept-language'];
+                               $sLangString = $_GET['accept-language'];
+                       }
+                       else if (isset($_SERVER["HTTP_ACCEPT_LANGUAGE"]))
+                       {
+                               $sLangString = $_SERVER["HTTP_ACCEPT_LANGUAGE"];
+                       }
                }
 
                $aLanguages = array();
-               if (isset($_SERVER["HTTP_ACCEPT_LANGUAGE"]))
+               if ($sLangString)
                {
-                       if (preg_match_all('/(([a-z]{1,8})(-[a-z]{1,8})?)\s*(;\s*q\s*=\s*(1|0\.[0-9]+))?/i', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $aLanguagesParse, PREG_SET_ORDER))
+                       if (preg_match_all('/(([a-z]{1,8})(-[a-z]{1,8})?)\s*(;\s*q\s*=\s*(1|0\.[0-9]+))?/i', $sLangString, $aLanguagesParse, PREG_SET_ORDER))
                        {
                                foreach($aLanguagesParse as $iLang => $aLanguage)
                                {
        {
                $aResult = array(array(join(' ',$aWords)));
                $sFirstToken = '';
-               if ($iDepth < 8) {
+               if ($iDepth < 7) {
                        while(sizeof($aWords) > 1)
                        {
                                $sWord = array_shift($aWords);
 
                if (sizeof($aNearPostcodes))
                {
-                       return array(array('lat' => $aNearPostcodes[0]['lat'], 'lon' => $aNearPostcodes[0]['lon'], 'radius' => 0.005));
+                       $aPostcodes = array();
+                       foreach($aNearPostcodes as $aPostcode)
+                       {
+                               $aPostcodes[] = array('lat' => $aPostcode['lat'], 'lon' => $aPostcode['lon'], 'radius' => 0.005);
+                       }
+
+                       return $aPostcodes;
                }
 
                return false;
                        $sSQL .= ' ORDER BY ST_distance('.$sPointSQL.', geometry) ASC limit 1';
                        //var_dump($sSQL);
                        $aPlace = $oDB->getRow($sSQL);
-                       $iPlaceID = $aPlace['place_id'];
-                       if (PEAR::IsError($iPlaceID))
+                       if (PEAR::IsError($aPlace))
                        {
-                               var_Dump($sSQL, $iPlaceID);
+                               var_Dump($sSQL, $aPlace);
                                exit;
                        }
+                       $iPlaceID = $aPlace['place_id'];
                }
 
                // The point we found might be too small - use the address to find what it is a child of
                return $iPlaceID;
        }
 
-       function loadStructuredAddressElement(&$aStructuredQuery, &$iMinAddressRank, &$iMaxAddressRank, &$aAddressRankList, $aParams, $sKey, $iNewMinAddressRank, $iNewMaxAddressRank, $aItemListValues)
-       {
-               if (!isset($_GET[$sKey])) return false;
-               $sValue = trim($_GET[$sKey]);
-               if (!$sValue) return false;
-               $aStructuredQuery[$sKey] = $sValue;
-               if ($iMinAddressRank == 0 && $iMaxAddressRank == 30)
-               {
-                       $iMinAddressRank = $iNewMinAddressRank;
-                       $iMaxAddressRank = $iNewMaxAddressRank;
-               }
-               if ($aItemListValues) $aAddressRankList = array_merge($aAddressRankList, $aItemListValues);
-               return true;
-       }
-
        function addQuotes($s)
        {
                return "'".$s."'";