]> git.openstreetmap.org Git - nominatim.git/commitdiff
missed some postcode use cases
authorBrian Quinion <brian.quinion@mapquest.com>
Thu, 13 Jun 2013 16:19:27 +0000 (17:19 +0100)
committerBrian Quinion <brian.quinion@mapquest.com>
Thu, 13 Jun 2013 16:19:27 +0000 (17:19 +0100)
website/search.php

index 7cecb9ed5c89443e15f1ee901aa0e942a33bd7e4..92cad8a034c93fcce84c2fe66b3fdbabf8031ad3 100755 (executable)
 
                                /*
                                   Calculate all searches using aValidTokens i.e.
 
                                /*
                                   Calculate all searches using aValidTokens i.e.
-
                                   'Wodsworth Road, Sheffield' =>
 
                                   Phrase Wordset
                                   'Wodsworth Road, Sheffield' =>
 
                                   Phrase Wordset
                                                                                elseif ($sPhraseType == 'postalcode')
                                                                                {
                                                                                        // We need to try the case where the postal code is the primary element (i.e. no way to tell if it is (postalcode, city) OR (city, postalcode) so try both
                                                                                elseif ($sPhraseType == 'postalcode')
                                                                                {
                                                                                        // We need to try the case where the postal code is the primary element (i.e. no way to tell if it is (postalcode, city) OR (city, postalcode) so try both
-                                                                                       if (sizeof($aSearch['aName']))
+                                                                                       if (isset($aSearchTerm['word_id']) && $aSearchTerm['word_id'])
                                                                                        {
                                                                                        {
-                                                                                               $aSearch['aAddress'] = array_merge($aSearch['aAddress'], $aSearch['aName']);
-                                                                                               $aSearch['aName'] = array();
-                                                                                               $aSearch['aName'][$aSearchTerm['word_id']] = $aSearchTerm['word_id'];
+                                                                                               // If we already have a name try putting the postcode first
+                                                                                               if (sizeof($aSearch['aName']))
+                                                                                               {
+                                                                                                       $aNewSearch = $aSearch;
+                                                                                                       $aNewSearch['aAddress'] = array_merge($aNewSearch['aAddress'], $aNewSearch['aName']);
+                                                                                                       $aNewSearch['aName'] = array();
+                                                                                                       $aNewSearch['aName'][$aSearchTerm['word_id']] = $aSearchTerm['word_id'];
+                                                                                                       if ($aSearch['iSearchRank'] < $iMaxRank) $aNewWordsetSearches[] = $aNewSearch;
+                                                                                               }
+
+                                                                                               if (sizeof($aSearch['aName']))
+                                                                                               {
+                                                                                                       if ((!$bStructuredPhrases || $iPhrase > 0) && $sPhraseType != 'country' && (!isset($aValidTokens[$sToken]) || strlen($sToken) < 4 || strpos($sToken, ' ') !== false))
+                                                                                                       {
+                                                                                                               $aSearch['aAddress'][$aSearchTerm['word_id']] = $aSearchTerm['word_id'];
+                                                                                                       }
+                                                                                                       else
+                                                                                                       {
+                                                                                                               $aCurrentSearch['aFullNameAddress'][$aSearchTerm['word_id']] = $aSearchTerm['word_id'];
+                                                                                                               $aSearch['iSearchRank'] += 1000; // skip;
+                                                                                                       }
+                                                                                               }
+                                                                                               else
+                                                                                               {
+                                                                                                       $aSearch['aName'][$aSearchTerm['word_id']] = $aSearchTerm['word_id'];
+                                                                                                       //$aSearch['iNamePhrase'] = $iPhrase;
+                                                                                               }
+                                                                                               if ($aSearch['iSearchRank'] < $iMaxRank) $aNewWordsetSearches[] = $aSearch;
                                                                                        }
                                                                                        }
-                                                                                       if ($aSearch['iSearchRank'] < $iMaxRank) $aNewWordsetSearches[] = $aSearch;
+
                                                                                }
                                                                                elseif (($sPhraseType == '' || $sPhraseType == 'street') && $aSearchTerm['class'] == 'place' && $aSearchTerm['type'] == 'house')
                                                                                {
                                                                                }
                                                                                elseif (($sPhraseType == '' || $sPhraseType == 'street') && $aSearchTerm['class'] == 'place' && $aSearchTerm['type'] == 'house')
                                                                                {
                                        //if (CONST_Debug) _debugDumpGroupedSearches($aGroupedSearches, $aValidTokens);
 
                                }
                                        //if (CONST_Debug) _debugDumpGroupedSearches($aGroupedSearches, $aValidTokens);
 
                                }
+
                        }
                        else
                        {
                        }
                        else
                        {