]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib/Geocode.php
Merge remote-tracking branch 'upstream/master'
[nominatim.git] / lib / Geocode.php
index c79dcf1ea5d41e49af50b7c0cbd4168af264c28d..c1fae0bbec399305b1efcbccc02b41e3e9f43163 100644 (file)
                        $this->bBoundedSearch = (bool)$bBoundedSearch;
                }
 
-               function setViewBox($fLeft, $fBottom, $fRight, $fTop)
+               function setViewBox($sLeft, $sBottom, $sRight, $sTop)
                {
-                       $this->aViewBox = array($fLeft, $fBottom, $fRight, $fTop);
+                       $fLeft = (float)$sLeft;
+                       $fRight = (float)$sRight;
+                       $fTop = (float)$sTop;
+                       $fBottom = (float)$sBottom;
+                       if ($fRight > $fLeft && $fBottom < $fTop
+                           && ($fRight - $fLeft) < 2 && ($fTop - $fBottom) < 2)
+                               $this->aViewBox = array($fLeft, $fBottom, $fRight, $fTop);
                }
 
                function getViewBoxString()
                                if (isset($aClassType[$aResult['class'].':'.$aResult['type'].':'.$aResult['admin_level']]['defdiameter'])
                                                && $aClassType[$aResult['class'].':'.$aResult['type'].':'.$aResult['admin_level']]['defdiameter'])
                                {
-                                       $fDiameter = $aClassType[$aResult['class'].':'.$aResult['type'].':'.$aResult['admin_level']]['defzoom'];
+                                       $fDiameter = $aClassType[$aResult['class'].':'.$aResult['type'].':'.$aResult['admin_level']]['defdiameter'];
                                }
                                elseif (isset($aClassType[$aResult['class'].':'.$aResult['type']]['defdiameter'])
                                                && $aClassType[$aResult['class'].':'.$aResult['type']]['defdiameter'])
                             */
                                                        elseif (preg_match('#POINT\\((-?[0-9.]+) (-?[0-9.]+)\\)#',$aPointPolygon['astext'],$aMatch))
                                                        {
-                                                               $iSteps = ($fRadius * 40000)^2;
+                                                               $iSteps = max(8, min(100, ($fRadius * 40000)^2));
                                                                $fStepSize = (2*pi())/$iSteps;
                                                                $aPolyPoints = array();
                                                                for($f = 0; $f < 2*pi(); $f += $fStepSize)
                                                        $aPointPolygon['minlon'] = $aPointPolygon['minlon'] - $fRadius;
                                                        $aPointPolygon['maxlon'] = $aPointPolygon['maxlon'] + $fRadius;
                                                }
-                                               $aResult['aBoundingBox'] = array($aPointPolygon['minlat'],$aPointPolygon['maxlat'],$aPointPolygon['minlon'],$aPointPolygon['maxlon']);
+                                               $aResult['aBoundingBox'] = array((string)$aPointPolygon['minlat'],(string)$aPointPolygon['maxlat'],(string)$aPointPolygon['minlon'],(string)$aPointPolygon['maxlon']);
                                        }
                                }