]> git.openstreetmap.org Git - nominatim.git/commitdiff
Merge remote-tracking branch 'upstream/master'
authorSarah Hoffmann <lonvia@denofr.de>
Thu, 13 Oct 2016 06:08:04 +0000 (08:08 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Thu, 13 Oct 2016 06:08:04 +0000 (08:08 +0200)
1  2 
lib/Geocode.php

diff --combined lib/Geocode.php
index fd381c7a10f983adc66e699772399a805ae65697,7fa349cacefdfddf5d1fb2fed9932e317a1b9327..b5f0c74f9612a1e01e943a277c6414f5f77dbb64
@@@ -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]
+         $this->aViewBox[0] = max(-180.0, min(180, $this->aViewBox[0]));
+         $this->aViewBox[1] = max(-90.0, min(90, $this->aViewBox[1]));
+         $this->aViewBox[2] = max(-180.0, min(180, $this->aViewBox[2]));
+         $this->aViewBox[3] = max(-90.0, min(90, $this->aViewBox[3]));
+         if (abs($this->aViewBox[0] - $this->aViewBox[2]) < 0.000000001
+             || abs($this->aViewBox[1] - $this->aViewBox[3]) < 0.000000001
          ) {
-             userError("Bad parameter 'viewbox'. Out of range.");
+             userError("Bad parameter 'viewbox'. Not a box.");
          }
  
          $fHeight = $this->aViewBox[0] - $this->aViewBox[2];
                          // 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'])."'";