Author: Marcus Jaschen (mjaschen@gmail.com)
Example #1
0
 /**
  * @param float     $lat       -90.0 .. +90.0
  * @param float     $lng       -180.0 .. +180.0
  * @param Ellipsoid $ellipsoid if omitted, WGS-84 is used
  *
  * @throws \InvalidArgumentException
  */
 public function __construct($lat, $lng, Ellipsoid $ellipsoid = null)
 {
     if (!$this->isValidLatitude($lat)) {
         throw new \InvalidArgumentException("Latitude value must be numeric -90.0 .. +90.0 (given: {$lat})");
     }
     if (!$this->isValidLongitude($lng)) {
         throw new \InvalidArgumentException("Longitude value must be numeric -180.0 .. +180.0 (given: {$lng})");
     }
     $this->lat = doubleval($lat);
     $this->lng = doubleval($lng);
     if ($ellipsoid !== null) {
         $this->ellipsoid = $ellipsoid;
     } else {
         $this->ellipsoid = Ellipsoid::createDefault();
     }
 }
Example #2
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     $ellipsoidConfig = array('name' => 'WGS-84', 'a' => 6378137.0, 'f' => 298.257223563);
     $this->ellipsoid = Ellipsoid::createFromArray($ellipsoidConfig);
     $this->calculator = new Haversine();
 }
Example #3
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     $ellipsoidConfig = ['name' => 'WGS-84', 'a' => 6378137.0, 'f' => 298.257223563];
     $this->ellipsoid = Ellipsoid::createFromArray($ellipsoidConfig);
 }
Example #4
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     $ellipsoidConfig = array('name' => 'WGS-84', 'a' => 6378137.0, 'f' => 298.257223563);
     $this->ellipsoid = Ellipsoid::createFromArray($ellipsoidConfig);
     $this->coordinate = new Coordinate(52.5, 13.5, $this->ellipsoid);
 }