From 87909a799b2129c0ab218abce62beef34a4624d7 Mon Sep 17 00:00:00 2001 From: Krivchikov Dmitry Date: Fri, 11 Dec 2015 17:33:04 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D1=80=D0=B0=D1=81=D1=81=D1=87=D1=91=D1=82=20=D0=BA?= =?UTF-8?q?=D0=BE=D0=BE=D1=80=D0=B4=D0=B8=D0=BD=D0=B0=D1=82=20=D0=B4=D0=BB?= =?UTF-8?q?=D1=8F=20=D0=BF=D0=BE=D0=B8=D1=81=D0=BA=D0=B0=20=D1=82=D0=BE?= =?UTF-8?q?=D1=87=D0=B5=D0=BA=20=D0=BF=D0=BE=D0=B1=D0=BB=D0=B8=D0=B7=D0=BE?= =?UTF-8?q?=D1=81=D1=82=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/Point.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/models/Point.php b/models/Point.php index b75e5b9..81ce1ae 100644 --- a/models/Point.php +++ b/models/Point.php @@ -49,10 +49,14 @@ class Point extends Model public function getClosestPoints($pointId) { + $degrees = 1; + $point = Point::model()->getByPK($pointId); $lat = floatval($point->lat); $lng = floatval($point->lng); + $delta = (1+abs(SIN($lat/100)*SIN($lat/100)*5))*$degrees; + $query = ' SELECT *, ( (POW(`lat`-:lat,2)+POW(`lng`-:lng,2)) @@ -71,7 +75,7 @@ class Point extends Model LIMIT 6;'; $res = App::DB()->prepare($query, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY)); - $res->execute(array(':lat' => $lat, ':lng' => $lng, ':minLat' => $lat - 1, ':minLng' => $lng - 1, ':maxLat' => $lat + 1, ':maxLng' => $lng + 1)); + $res->execute(array(':lat' => $lat, ':lng' => $lng, ':minLat' => $lat - $degrees, ':minLng' => $lng - $delta, ':maxLat' => $lat + $degrees, ':maxLng' => $lng + $delta)); $ready = array(); $calledClass = get_called_class();