]> git.openstreetmap.org Git - nominatim.git/blobdiff - website/search.php
hint blocked IPs about missing UA
[nominatim.git] / website / search.php
index d486ed66ba5361bec57f7f3d59bbaa50ec2cfef3..bcd5718e2422ab1b795b24c28b3b993980280208 100755 (executable)
 
        // Preferred language
        $aLangPrefOrder = getPreferredLanguages();
+    $bReverseInPlan = true;
+    /*
        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))."]";
 
                                $sQuery = trim(str_replace($aData[0], ' ', $sQuery));
                        }
                }
-               elseif (preg_match('/(\\[|^|\\b)(-?[0-9]+[0-9.]*)[, ]+(-?[0-9]+[0-9.]*)(\\]|$|\\b)/', $sQuery, $aData))
+               elseif (preg_match('/(\\[|^|\\b)(-?[0-9]+[0-9]*\\.[0-9]+)[, ]+(-?[0-9]+[0-9]*\\.[0-9]+)(\\]|$|\\b)/', $sQuery, $aData))
                {
                        $fQueryLat = $aData[2];
                        $fQueryLon = $aData[3];
                                                        $aValidTokens[$sToken] = $aGBPostcodeLocation;
                                                }
                                        }
+                                       // US ZIP+4 codes - if there is no token,
+                                       //      merge in the 5-digit ZIP code
+                                       else if (!isset($aValidTokens[$sToken]) && preg_match('/^([0-9]{5}) [0-9]{4}$/', $sToken, $aData))
+                                       {
+                                               if (isset($aValidTokens[$aData[1]]))
+                                               {
+                                                       foreach($aValidTokens[$aData[1]] as $aToken)
+                                                       {
+                                                               if (!$aToken['class'])
+                                                               {
+                                                                       if (isset($aValidTokens[$sToken]))
+                                                                       {
+                                                                               $aValidTokens[$sToken][] = $aToken;
+                                                                       }
+                                                                       else
+                                                                       {
+                                                                               $aValidTokens[$sToken] = array($aToken);
+                                                                       }
+                                                               }
+                                                       }
+                                               }
+                                       }
                                }
 
                                foreach($aTokens as $sToken)
                                                                                                $aSearch['sType'] = $aSearchTerm['type'];
                                                                                                if (sizeof($aSearch['aName'])) $aSearch['sOperator'] = 'name';
                                                                                                else $aSearch['sOperator'] = 'near'; // near = in for the moment
+                                                                                               if (strlen($aSearchTerm['operator']) == 0) $aSearch['iSearchRank'] += 1;
 
                                                                                                // Do we have a shortcut id?
                                                                                                if ($aSearch['sOperator'] == 'name')