public function withinRange(Point $point, $rangeInMiles = 50, $prefix = '') { $points = $point->getGeoBox($rangeInMiles); $upperLeft = $points[0]; $bottomRight = $points[1]; return $this->where($prefix . 'point.latitude BETWEEN :upperLeftLatitude AND :bottomRightLatitude')->andWhere($prefix . 'point.longitude BETWEEN :upperLeftLongitude AND :bottomRightLongitude')->setParameter('upperLeftLatitude', $upperLeft->getLatitude())->setParameter('upperLeftLongitude', $upperLeft->getLongitude())->setParameter('bottomRightLatitude', $bottomRight->getLatitude())->setParameter('bottomRightLongitude', $bottomRight->getLongitude()); }
public function testGetGeoBox() { $point = new Point($this->latitude, $this->longitude); $points = $point->getGeoBox(50); $upperLeft = $points[0]; $bottomRight = $points[1]; $this->assertEquals(33.3285403, $upperLeft->getLatitude(), '', FLOAT_DELTA); $this->assertEquals(-118.9673787, $upperLeft->getLongitude(), '', FLOAT_DELTA); $this->assertEquals(34.7759277, $bottomRight->getLatitude(), '', FLOAT_DELTA); $this->assertEquals(-117.5199913, $bottomRight->getLongitude(), '', FLOAT_DELTA); }