]> git.openstreetmap.org Git - nominatim.git/commitdiff
Merge remote-tracking branch 'upstream/master'
authorSarah Hoffmann <lonvia@denofr.de>
Wed, 12 Oct 2016 20:28:48 +0000 (22:28 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Wed, 12 Oct 2016 20:28:48 +0000 (22:28 +0200)
1  2 
lib/Geocode.php
lib/lib.php

diff --combined lib/Geocode.php
index 83618113ad00e74fcf50640c9384c4f8a9eefc95,273fc0f006ff12361fdd106ad30c69d89f1ebdbe..fd381c7a10f983adc66e699772399a805ae65697
@@@ -24,7 -24,7 +24,7 @@@ class Geocod
  
      protected $aExcludePlaceIDs = array();
      protected $bDeDupe = true;
 -    protected $bReverseInPlan = false;
 +    protected $bReverseInPlan = true;
  
      protected $iLimit = 20;
      protected $iFinalLimit = 10;
      {
          $this->aViewBox = array_map('floatval', $aViewbox);
  
+         if ($this->aViewBox[0] < -180
+             || $this->aViewBox[2] > 180
+             || $this->aViewBox[0] >= $this->aViewBox[2]
+             || $this->aViewBox[1] < -90
+             || $this->aViewBox[3] > 90
+             || $this->aViewBox[1] >= $this->aViewBox[3]
+         ) {
+             userError("Bad parameter 'viewbox'. Out of range.");
+         }
          $fHeight = $this->aViewBox[0] - $this->aViewBox[2];
          $fWidth = $this->aViewBox[1] - $this->aViewBox[3];
          $aBigViewBox[0] = $this->aViewBox[0] + $fHeight;
  
          $aViewbox = $oParams->getStringList('viewboxlbrt');
          if ($aViewbox) {
+             if (count($aViewbox) != 4) {
+                 userError("Bad parmater 'viewbox'. Expected 4 coordinates.");
+             }
              $this->setViewbox($aViewbox);
          } else {
              $aViewbox = $oParams->getStringList('viewbox');
              if ($aViewbox) {
+                 if (count($aViewbox) != 4) {
+                     userError("Bad parmater 'viewbox'. Expected 4 coordinates.");
+                 }
                  $this->setViewBox(array(
                                     $aViewbox[0],
                                     $aViewbox[3],
              foreach ($aPhrases as $iPhrase => $sPhrase) {
                  $aPhrase = chksql(
                      $this->oDB->getRow("select make_standard_name('".pg_escape_string($sPhrase)."') as string"),
-                     "Cannot nomralize query string (is it an UTF-8 string?)"
+                     "Cannot normalize query string (is it a UTF-8 string?)"
                  );
                  if (trim($aPhrase['string'])) {
                      $aPhrases[$iPhrase] = $aPhrase;
                          // TODO: filter out the pointless search terms (2 letter name tokens and less)
                          // they might be right - but they are just too darned expensive to run
                          if (sizeof($aSearch['aName'])) $aTerms[] = "name_vector @> ARRAY[".join($aSearch['aName'], ",")."]";
 -                        if (sizeof($aSearch['aNameNonSearch'])) $aTerms[] = "array_cat(name_vector,ARRAY[]::integer[]) @> ARRAY[".join($aSearch['aNameNonSearch'], ",")."]";
 +                        //if (sizeof($aSearch['aNameNonSearch'])) $aTerms[] = "array_cat(name_vector,ARRAY[]::integer[]) @> ARRAY[".join($aSearch['aNameNonSearch'], ",")."]";
                          if (sizeof($aSearch['aAddress']) && $aSearch['aName'] != $aSearch['aAddress']) {
                              // For infrequent name terms disable index usage for address
                              if (CONST_Search_NameOnlySearchFrequencyThreshold
                                  && sizeof($aSearch['aName']) == 1
                                  && $aWordFrequencyScores[$aSearch['aName'][reset($aSearch['aName'])]] < CONST_Search_NameOnlySearchFrequencyThreshold
                              ) {
 -                                $aTerms[] = "array_cat(nameaddress_vector,ARRAY[]::integer[]) @> ARRAY[".join(array_merge($aSearch['aAddress'], $aSearch['aAddressNonSearch']), ",")."]";
 +                                //$aTerms[] = "array_cat(nameaddress_vector,ARRAY[]::integer[]) @> ARRAY[".join(array_merge($aSearch['aAddress'], $aSearch['aAddressNonSearch']), ",")."]";
 +                                $aTerms[] = "array_cat(nameaddress_vector,ARRAY[]::integer[]) @> ARRAY[".join($aSearch['aAddress'],",")."]";
                              } else {
                                  $aTerms[] = "nameaddress_vector @> ARRAY[".join($aSearch['aAddress'], ",")."]";
 -                                if (sizeof($aSearch['aAddressNonSearch'])) {
 +                                /*if (sizeof($aSearch['aAddressNonSearch'])) {
                                      $aTerms[] = "array_cat(nameaddress_vector,ARRAY[]::integer[]) @> ARRAY[".join($aSearch['aAddressNonSearch'], ",")."]";
 -                                }
 +                                }*/
                              }
                          }
                          if ($aSearch['sCountryCode']) $aTerms[] = "country_code = '".pg_escape_string($aSearch['sCountryCode'])."'";
diff --combined lib/lib.php
index 9de2a548b54ae9378b96d7c12aa8b254e6f9ede8,e14f52f9327bc632af7952b19d3bea0c470224b6..c7f131bdf77810097d90791728a396ccee728064
@@@ -55,7 -55,7 +55,7 @@@ function getWordSets($aWords, $iDepth
  {
      $aResult = array(array(join(' ', $aWords)));
      $sFirstToken = '';
-     if ($iDepth < 8) {
+     if ($iDepth < 7) {
          while (sizeof($aWords) > 1) {
              $sWord = array_shift($aWords);
              $sFirstToken .= ($sFirstToken?' ':'').$sWord;
@@@ -691,10 -691,10 +691,10 @@@ function geometryText2Points($geometry_
          //
          preg_match_all('/(-?[0-9.]+) (-?[0-9.]+)/', $aMatch[1], $aPolyPoints, PREG_SET_ORDER);
          //
 -    } elseif (preg_match('#MULTIPOLYGON\\(\\(\\(([- 0-9.,]+)#', $geometry_as_text, $aMatch)) {
 +/*    } elseif (preg_match('#MULTIPOLYGON\\(\\(\\(([- 0-9.,]+)#', $geometry_as_text, $aMatch)) {
          //
          preg_match_all('/(-?[0-9.]+) (-?[0-9.]+)/', $aMatch[1], $aPolyPoints, PREG_SET_ORDER);
 -        //
 +        */
      } elseif (preg_match('#POINT\\((-?[0-9.]+) (-?[0-9.]+)\\)#', $geometry_as_text, $aMatch)) {
          //
          $aPolyPoints = createPointsAroundCenter($aMatch[1], $aMatch[2], $fRadius);