]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib-php/Geocode.php
Merge remote-tracking branch 'upstream/master'
[nominatim.git] / lib-php / Geocode.php
index 9e3b0b92fbc47638dd4ff4227a45b9617a9c2a6c..3529d8356e774c61603a2e5cb941b0c076ea0a93 100644 (file)
@@ -103,7 +103,7 @@ class Geocode
         }
 
         $this->iFinalLimit = $iLimit;
         }
 
         $this->iFinalLimit = $iLimit;
-        $this->iLimit = $iLimit + min($iLimit, 10);
+        $this->iLimit = $iLimit + max($iLimit, 10);
     }
 
     public function setFeatureType($sFeatureType)
     }
 
     public function setFeatureType($sFeatureType)
@@ -257,19 +257,21 @@ class Geocode
     public function setQueryFromParams($oParams)
     {
         // Search query
     public function setQueryFromParams($oParams)
     {
         // Search query
-        $sQuery = $oParams->getString('q');
-        if (!$sQuery) {
-            $this->setStructuredQuery(
-                $oParams->getString('amenity'),
-                $oParams->getString('street'),
-                $oParams->getString('city'),
-                $oParams->getString('county'),
-                $oParams->getString('state'),
-                $oParams->getString('country'),
-                $oParams->getString('postalcode')
-            );
-        } else {
-            $this->setQuery($sQuery);
+        $this->setStructuredQuery(
+            $oParams->getString('amenity'),
+            $oParams->getString('street'),
+            $oParams->getString('city'),
+            $oParams->getString('county'),
+            $oParams->getString('state'),
+            $oParams->getString('country'),
+            $oParams->getString('postalcode')
+        );
+        if (!$this->sQuery) {
+            $sQuery = $oParams->getString('q');
+
+            if ($sQuery) {
+                $this->setQuery($sQuery);
+            }
         }
     }
 
         }
     }
 
@@ -294,26 +296,28 @@ class Geocode
     {
         $this->sQuery = false;
 
     {
         $this->sQuery = false;
 
-        // Reset
-        $this->iMinAddressRank = 0;
-        $this->iMaxAddressRank = 30;
-        $this->aAddressRankList = array();
-
-        $this->aStructuredQuery = array();
-        $this->sAllowedTypesSQLList = false;
-
-        $this->loadStructuredAddressElement($sAmenity, 'amenity', 26, 30, false);
-        $this->loadStructuredAddressElement($sStreet, 'street', 26, 30, false);
-        $this->loadStructuredAddressElement($sCity, 'city', 14, 24, false);
-        $this->loadStructuredAddressElement($sCounty, 'county', 9, 13, false);
-        $this->loadStructuredAddressElement($sState, 'state', 8, 8, false);
-        $this->loadStructuredAddressElement($sPostalCode, 'postalcode', 5, 11, array(5, 11));
-        $this->loadStructuredAddressElement($sCountry, 'country', 4, 4, false);
-
-        if (!empty($this->aStructuredQuery)) {
-            $this->sQuery = join(', ', $this->aStructuredQuery);
-            if ($this->iMaxAddressRank < 30) {
-                $this->sAllowedTypesSQLList = '(\'place\',\'boundary\')';
+        if ($sAmenity || $sStreet || $sCity || $sCounty || $sState || $sCountry || $sPostalCode) {
+            // Reset
+            $this->iMinAddressRank = 0;
+            $this->iMaxAddressRank = 30;
+            $this->aAddressRankList = array();
+
+            $this->aStructuredQuery = array();
+            $this->sAllowedTypesSQLList = false;
+
+            $this->loadStructuredAddressElement($sAmenity, 'amenity', 26, 30, false);
+            $this->loadStructuredAddressElement($sStreet, 'street', 26, 30, false);
+            $this->loadStructuredAddressElement($sCity, 'city', 14, 24, false);
+            $this->loadStructuredAddressElement($sCounty, 'county', 9, 13, false);
+            $this->loadStructuredAddressElement($sState, 'state', 8, 8, false);
+            $this->loadStructuredAddressElement($sPostalCode, 'postalcode', 5, 11, array(5, 11));
+            $this->loadStructuredAddressElement($sCountry, 'country', 4, 4, false);
+
+            if (!empty($this->aStructuredQuery)) {
+                $this->sQuery = join(', ', $this->aStructuredQuery);
+                if ($this->iMaxAddressRank < 30) {
+                    $this->sAllowedTypesSQLList = '(\'place\',\'boundary\')';
+                }
             }
         }
     }
             }
         }
     }
@@ -695,7 +699,7 @@ class Geocode
                         }
                     }
 
                         }
                     }
 
-                    if ($iQueryLoop > 20) {
+                    if ($iQueryLoop > 30) {
                         break;
                     }
                 }
                         break;
                     }
                 }
@@ -772,7 +776,7 @@ class Geocode
                     $aResults = $tempIDs;
                 }
 
                     $aResults = $tempIDs;
                 }
 
-                if (!empty($aResults) || $iGroupLoop > 4 || $iQueryLoop > 30) {
+                if (!empty($aResults) || $iGroupLoop > 6 || $iQueryLoop > 40) {
                     break;
                 }
             }
                     break;
                 }
             }
@@ -874,7 +878,7 @@ class Geocode
                 $iCountWords = 0;
                 $sAddress = $aResult['langaddress'];
                 foreach ($aRecheckWords as $i => $sWord) {
                 $iCountWords = 0;
                 $sAddress = $aResult['langaddress'];
                 foreach ($aRecheckWords as $i => $sWord) {
-                    if (stripos($sAddress, $sWord)!==false) {
+                    if (grapheme_stripos($sAddress, $sWord)!==false) {
                         $iCountWords++;
                         if (preg_match('/(^|,)\s*'.preg_quote($sWord, '/').'\s*(,|$)/', $sAddress)) {
                             $iCountWords += 0.1;
                         $iCountWords++;
                         if (preg_match('/(^|,)\s*'.preg_quote($sWord, '/').'\s*(,|$)/', $sAddress)) {
                             $iCountWords += 0.1;