コード例 #1
0
ファイル: Map.php プロジェクト: necromant2005/twee-tag
 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;
 }
コード例 #2
0
ファイル: Tweet.php プロジェクト: necromant2005/twee-tag
 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;
 }