]> git.openstreetmap.org Git - nominatim.git/commitdiff
Merge remote-tracking branch 'upstream/master'
authorSarah Hoffmann <lonvia@denofr.de>
Wed, 9 Mar 2016 22:28:33 +0000 (23:28 +0100)
committerSarah Hoffmann <lonvia@denofr.de>
Wed, 9 Mar 2016 22:28:33 +0000 (23:28 +0100)
1  2 
lib/Geocode.php
lib/init-website.php
lib/lib.php
tests/features/api/search_params.feature
website/reverse.php

diff --cc lib/Geocode.php
Simple merge
index 013aee4b4a1c07daf07dde2389baff9f85069a11,a34e4c82787ae1dee4f77d5431a66376aeb077dc..03e269656a0516fcad57db2bd687413c4b25b113
        }
        if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') exit;
  
-     header('Content-type: text/html; charset=utf-8');
 -      if (CONST_ClosedForIndexing && strpos(CONST_ClosedForIndexingExceptionIPs, ','.$_SERVER["REMOTE_ADDR"].',') === false)
 -      {
 -              echo "Closed for re-indexing...";
 -              exit;
 -      }
 -
 -      $aBucketKeys = array();
 -
 -      if (isset($_SERVER["HTTP_REFERER"])) $aBucketKeys[] = str_replace('www.','',strtolower(parse_url($_SERVER["HTTP_REFERER"], PHP_URL_HOST)));
 -      if (isset($_SERVER["REMOTE_ADDR"])) $aBucketKeys[] = $_SERVER["REMOTE_ADDR"];
 -      if (isset($_GET["email"])) $aBucketKeys[] = $_GET["email"];
 -
 -      $fBucketVal = doBucket($aBucketKeys, 
 -                      (defined('CONST_ConnectionBucket_PageType')?constant('CONST_ConnectionBucket_Cost_'.CONST_ConnectionBucket_PageType):1) + user_busy_cost(),
 -                      CONST_ConnectionBucket_LeakRate, CONST_ConnectionBucket_BlockLimit);
 -
 -      if ($fBucketVal > CONST_ConnectionBucket_WaitLimit && $fBucketVal < CONST_ConnectionBucket_BlockLimit)
 -      {
 -              $m = getBucketMemcache();
 -              $iCurrentSleeping = $m->increment('sleepCounter');
 -              if (false === $iCurrentSleeping)
 -              {
 -                      $m->add('sleepCounter', 0);
 -                      $iCurrentSleeping = $m->increment('sleepCounter');
 -              }
 -              if ($iCurrentSleeping >= CONST_ConnectionBucket_MaxSleeping || isBucketSleeping($aBucketKeys))
 -              {
 -                      // Too many threads sleeping already.  This becomes a hard block.
 -                      $fBucketVal = doBucket($aBucketKeys, CONST_ConnectionBucket_BlockLimit, CONST_ConnectionBucket_LeakRate, CONST_ConnectionBucket_BlockLimit);
 -              }
 -              else
 -              {
 -                      setBucketSleeping($aBucketKeys, true);
 -                      sleep(($fBucketVal - CONST_ConnectionBucket_WaitLimit)/CONST_ConnectionBucket_LeakRate);
 -                      $fBucketVal = doBucket($aBucketKeys, CONST_ConnectionBucket_LeakRate, CONST_ConnectionBucket_LeakRate, CONST_ConnectionBucket_BlockLimit);
 -                      setBucketSleeping($aBucketKeys, false);
 -              }
 -              $m->decrement('sleepCounter');
 -      }
 -
 -      if (strpos(CONST_BlockedIPs, ','.$_SERVER["REMOTE_ADDR"].',') !== false || $fBucketVal >= CONST_ConnectionBucket_BlockLimit)
 -      {
 -              header("HTTP/1.0 429 Too Many Requests");
 -              echo "Your IP has been blocked. \n";
 -              echo CONST_BlockMessage;
 -              exit;
 -      }
 -
+       header('Content-type: text/html; charset=utf-8');
 -
diff --cc lib/lib.php
index d1afedbd68414278f90dbcb1906c6c067c06147c,51bf7ebb13381e32507535ca394f7aad46545685..e657daf4207c7bd433e85425990b0ccf5cc20ffe
  
                return array('lat' => $fQueryLat, 'lon' => $fQueryLon, 'query' => $sQuery);
        }
 -              elseif (preg_match('#MULTIPOLYGON\\(\\(\\(([- 0-9.,]+)#', $geometry_as_text, $aMatch))
+       function geometryText2Points($geometry_as_text, $fRadius)
+       {
+               $aPolyPoints = NULL;
+               if (preg_match('#POLYGON\\(\\(([- 0-9.,]+)#', $geometry_as_text, $aMatch))
+               {
+                       preg_match_all('/(-?[0-9.]+) (-?[0-9.]+)/', $aMatch[1], $aPolyPoints, PREG_SET_ORDER);
+               }
+               elseif (preg_match('#LINESTRING\\(([- 0-9.,]+)#', $geometry_as_text, $aMatch))
+               {
+                       preg_match_all('/(-?[0-9.]+) (-?[0-9.]+)/', $aMatch[1], $aPolyPoints, PREG_SET_ORDER);
+               }
 -              }
++/*            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);
+               }
+               if (isset($aPolyPoints))
+               {
+                       $aResultPoints = array();
+                       foreach($aPolyPoints as $aPoint)
+                       {
+                               $aResultPoints[] = array($aPoint[1], $aPoint[2]);
+                       }
+                       return $aResultPoints;
+               }
+               return;
+       }
+       function createPointsAroundCenter($fLon, $fLat, $fRadius)
+       {
+                       $iSteps = max(8, min(100, ($fRadius * 40000)^2));
+                       $fStepSize = (2*pi())/$iSteps;
+                       $aPolyPoints = array();
+                       for($f = 0; $f < 2*pi(); $f += $fStepSize)
+                       {
+                               $aPolyPoints[] = array('', $fLon+($fRadius*sin($f)), $fLat+($fRadius*cos($f)) );
+                       }
+                       return $aPolyPoints;
+       }
index d1603fa1e1752f68b55544ea44150dc96bf294a5,d1c554a454352a79914f2f75a4096c182f8fa490..1f6e0aad1114f9acbd14e5baf210ef8cc4e792a9
@@@ -6,6 -6,48 +6,35 @@@
        require_once(CONST_BasePath.'/lib/PlaceLookup.php');
        require_once(CONST_BasePath.'/lib/ReverseGeocode.php');
  
 -      if (strpos(CONST_BulkUserIPs, ','.$_SERVER["REMOTE_ADDR"].',') !== false)
 -      {
 -              $fLoadAvg = getLoadAverage();
 -              if ($fLoadAvg > 2) sleep(60);
 -              if ($fLoadAvg > 4) sleep(120);
 -              if ($fLoadAvg > 6)
 -              {
 -                      echo "Bulk User: Temporary block due to high server load\n";
 -                      exit;
 -              }
 -      }
 -
 -
+       $bAsPoints = false;
+       $bAsGeoJSON = (boolean)isset($_GET['polygon_geojson']) && $_GET['polygon_geojson'];
+       $bAsKML = (boolean)isset($_GET['polygon_kml']) && $_GET['polygon_kml'];
+       $bAsSVG = (boolean)isset($_GET['polygon_svg']) && $_GET['polygon_svg'];
+       $bAsText = (boolean)isset($_GET['polygon_text']) && $_GET['polygon_text'];
+       if ( ( ($bAsGeoJSON?1:0)
+                        + ($bAsKML?1:0)
+                        + ($bAsSVG?1:0)
+                        + ($bAsText?1:0)
+                        + ($bAsPoints?1:0)
+                        ) > CONST_PolygonOutput_MaximumTypes)
+       {
+               if (CONST_PolygonOutput_MaximumTypes)
+               {
+                       userError("Select only ".CONST_PolygonOutput_MaximumTypes." polgyon output option");
+               }
+               else
+               {
+                       userError("Polygon output is disabled");
+               }
+               exit;
+       }
+       // Polygon simplification threshold (optional)
+       $fThreshold = 0.0;
+       if (isset($_GET['polygon_threshold'])) $fThreshold = (float)$_GET['polygon_threshold'];
        $oDB =& getDB();
        ini_set('memory_limit', '200M');