public function distance(Location $p1, Location $p2) { $R = 6371; $d = acos( sin($this->toRad($p1->getLatitude()))*sin($this->toRad($p2->getLatitude())) + cos($this->toRad($p1->getLatitude()))*cos($this->toRad($p2->getLatitude())) * cos($this->toRad($p2->getLongitude())-$this->toRad($p1->getLongitude()))) * $R; return $d; }
public function saveLocationByUsername($username, Location $location=null) { try { if ($location) { $this->_dbTable->insert(array( 'username'=>$username, 'latitude'=>$location->getLatitude(), 'longitude'=>$location->getLongitude())); } else { $this->_dbTable->insert(array('username'=>$username)); } } catch (\Zend\Db\Statement\Exception $e) { } return $location; }