Beispiel #1
0
 /**
  * @param CM_Geo_Point $pointTo
  * @return float
  */
 public function calculateDistanceTo(CM_Geo_Point $pointTo)
 {
     $pi180 = M_PI / 180;
     $currentRadianLatitude = $this->getLatitude() * $pi180;
     $currentRadianLongitude = $this->getLongitude() * $pi180;
     $againstRadianLatitude = $pointTo->getLatitude() * $pi180;
     $againstRadianLongitude = $pointTo->getLongitude() * $pi180;
     $arcCosine = acos(sin($currentRadianLatitude) * sin($againstRadianLatitude) + cos($currentRadianLatitude) * cos($againstRadianLatitude) * cos($currentRadianLongitude - $againstRadianLongitude));
     return CM_Model_Location::EARTH_RADIUS * $arcCosine;
 }
Beispiel #2
0
 /**
  * @expectedException CM_Exception_Invalid
  */
 public function testGetSetLongitudeOutOfRange()
 {
     $point = new CM_Geo_Point(11.2, 13.2);
     $point->setLongitude(300);
 }
Beispiel #3
0
 public function testFromArray()
 {
     $data = ['latitude' => 51.3, 'longitude' => 52.4];
     $point = new CM_Geo_Point(51.3, 52.4);
     $this->assertEquals($point, CM_Geo_Point::fromArray($data));
 }