Exemple #1
0
 public function testLongitudeRetrieval()
 {
     $this->assertEquals($this->point->getLongitude(), $this->lon);
     $this->assertEquals($this->point->lon, $this->lon);
     $this->assertEquals($this->point->longitude, $this->lon);
 }
Exemple #2
0
 /**
  * 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);
     }
 }
Exemple #3
0
 public function testPointCreationAsArray()
 {
     $point = new Point([$this->lon, $this->lat]);
     $this->assertEquals($this->lat, $point->getLatitude());
     $this->assertEquals($this->lon, $point->getLongitude());
 }