]> git.openstreetmap.org Git - nominatim.git/commitdiff
Merge remote-tracking branch 'upstream/master'
authorSarah Hoffmann <lonvia@denofr.de>
Fri, 16 Nov 2018 23:11:29 +0000 (00:11 +0100)
committerSarah Hoffmann <lonvia@denofr.de>
Fri, 16 Nov 2018 23:11:29 +0000 (00:11 +0100)
1  2 
CMakeLists.txt
lib/Geocode.php
lib/lib.php
website/reverse.php

diff --combined CMakeLists.txt
index 0c6d4094ed7eaadd78d42b7898e33793d7e72450,d6f7d2cb94d5abcd32ef4d59672f4ce1230981cb..7c5763fd47b678f03f7ac7f998c04c6b394c8023
@@@ -103,17 -103,8 +103,16 @@@ set(CUSTOMFILE
      website/reverse.php
      website/search.php
      website/status.php
 +    website/403.html
 +    website/509.html
 +    website/crossdomain.xml
 +    website/favicon.ico
 +    website/last_update.php
 +    website/nominatim.xml
 +    website/robots.txt
 +    website/taginfo.json
      utils/blocks.php
      utils/country_languages.php
-     utils/imports.php
      utils/importWikipedia.php
      utils/export.php
      utils/query.php
diff --combined lib/Geocode.php
index 1dd5a0e5ea3dd484d963d362959d2aafeae369c1,e2fd7272c34db0deb4220d1ef83a6d95b6dbf9da..5343873fb9d59bdd8987954f7f20692bc0866be3
@@@ -18,7 -18,7 +18,7 @@@ class Geocod
      protected $aLangPrefOrder = array();
  
      protected $aExcludePlaceIDs = array();
 -    protected $bReverseInPlan = false;
 +    protected $bReverseInPlan = true;
  
      protected $iLimit = 20;
      protected $iFinalLimit = 10;
          // Do we have anything that looks like a lat/lon pair?
          $sQuery = $oCtx->setNearPointFromQuery($sQuery);
  
-         $aResults = array();
          if ($sQuery || $this->aStructuredQuery) {
              // Start with a single blank search
              $aSearches = array(new SearchDescription($oCtx));
              // Start the search process
              $iGroupLoop = 0;
              $iQueryLoop = 0;
+             $aNextResults = array();
              foreach ($aGroupedSearches as $iGroupedRank => $aSearches) {
                  $iGroupLoop++;
+                 $aResults = $aNextResults;
                  foreach ($aSearches as $oSearch) {
                      $iQueryLoop++;
  
                      if ($iQueryLoop > 20) break;
                  }
  
+                 if (!empty($aResults)) {
+                     $aSplitResults = Result::splitResults($aResults);
+                     Debug::printVar('Split results', $aSplitResults);
+                     if ($iGroupLoop <= 4 && empty($aSplitResults['tail'])
+                         && reset($aSplitResults['head'])->iResultRank > 0) {
+                         // Haven't found an exact match for the query yet.
+                         // Therefore add result from the next group level.
+                         $aNextResults = $aSplitResults['head'];
+                         foreach ($aNextResults as $oRes) {
+                             $oRes->iResultRank--;
+                         }
+                         $aResults = array();
+                     } else {
+                         $aResults = $aSplitResults['head'];
+                     }
+                 }
                  if (!empty($aResults) && ($this->iMinAddressRank != 0 || $this->iMaxAddressRank != 30)) {
                      // Need to verify passes rank limits before dropping out of the loop (yuk!)
                      // reduces the number of place ids, like a filter
diff --combined lib/lib.php
index 0f87c37eca00c1f4f6077ef0452218ed25030abf,cd23b06843ca550304a50924bb071be3108d8a8b..37ef5e190ba2d405447abe736cc1cc3feac12daf
@@@ -61,6 -61,13 +61,13 @@@ function byImportance($a, $b
  
  function javascript_renderData($xVal, $iOptions = 0)
  {
+     $sCallback = isset($_GET['json_callback']) ? $_GET['json_callback'] : '';
+     if ($sCallback && !preg_match('/^[$_\p{L}][$_\p{L}\p{Nd}.[\]]*$/u', $sCallback)) {
+         // Unset, we call javascript_renderData again during exception handling
+         unset($_GET['json_callback']);
+         throw new Exception('Invalid json_callback value', 400);
+     }
      $iOptions |= JSON_UNESCAPED_UNICODE;
      if (isset($_GET['pretty']) && in_array(strtolower($_GET['pretty']), array('1', 'true'))) {
          $iOptions |= JSON_PRETTY_PRINT;
  
      $jsonout = json_encode($xVal, $iOptions);
  
-     if (!isset($_GET['json_callback'])) {
+     if ($sCallback) {
+         header('Content-Type: application/javascript; charset=UTF-8');
+         echo $_GET['json_callback'].'('.$jsonout.')';
+     } else {
          header('Content-Type: application/json; charset=UTF-8');
          echo $jsonout;
-     } else {
-         if (preg_match('/^[$_\p{L}][$_\p{L}\p{Nd}.[\]]*$/u', $_GET['json_callback'])) {
-             header('Content-Type: application/javascript; charset=UTF-8');
-             echo $_GET['json_callback'].'('.$jsonout.')';
-         } else {
-             header('HTTP/1.0 400 Bad Request');
-         }
      }
  }
  
@@@ -174,10 -177,10 +177,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);
diff --combined website/reverse.php
index 5f9268c680e31e222370b001b8f9edcdeb355134,963f7500cf225ad0ceaece2e8f2604d9b59542c0..075d4cf032c7678e8b643935b14c95293db67a27
@@@ -13,6 -13,7 +13,7 @@@ $oParams = new Nominatim\ParameterParse
  
  // Format for output
  $sOutputFormat = $oParams->getSet('format', array('html', 'xml', 'json', 'jsonv2', 'geojson', 'geocodejson'), 'xml');
+ set_exception_handler_by_format($sOutputFormat);
  
  // Preferred language
  $aLangPrefOrder = $oParams->getPreferredLanguages();
@@@ -67,7 -68,6 +68,7 @@@ if (isset($aPlace)) 
      $aPlace = array();
  }
  
 +logEnd($oDB, $hLog, sizeof($aPlace)?1:0);
  
  if (CONST_Debug) {
      var_dump($aPlace);