コード例 #1
0
ファイル: PointTest.php プロジェクト: rickogden/Location
 public function testLongitudeRetrieval()
 {
     $this->assertEquals($this->point->getLongitude(), $this->lon);
     $this->assertEquals($this->point->lon, $this->lon);
     $this->assertEquals($this->point->longitude, $this->lon);
 }
コード例 #2
0
ファイル: Point.php プロジェクト: rickogden/Location
 /**
  * Get the bearing from this Point to another.
  *
  * @param Point $point2
  *
  * @return float bearing
  */
 public function initialBearingTo(Point $point2)
 {
     if (function_exists('initial_bearing') && Location::$useSpatialExtension) {
         return initial_bearing($this->jsonSerialize(), $point2->jsonSerialize());
     } else {
         $y = sin(deg2rad($point2->getLongitude() - $this->getLongitude())) * cos($point2->latitudeToRad());
         $x = cos($this->latitudeToRad()) * sin($point2->latitudeToRad()) - sin($this->latitudeToRad()) * cos($point2->latitudeToRad()) * cos(deg2rad($point2->getLongitude() - $this->getLongitude()));
         $result = atan2($y, $x);
         return fmod(rad2deg($result) + 360, 360);
     }
 }
コード例 #3
0
ファイル: PointTest.php プロジェクト: rickogden/Location
 public function testPointCreationAsArray()
 {
     $point = new Point([$this->lon, $this->lat]);
     $this->assertEquals($this->lat, $point->getLatitude());
     $this->assertEquals($this->lon, $point->getLongitude());
 }