Exemplo n.º 1
0
 public static function fromCenterAndDistance(GeolocationInterface $center, Distance $distance)
 {
     $radLat = deg2rad($center->getLat());
     $radLon = deg2rad($center->getLong());
     // angular distance in radians on a great circle
     $radDist = $distance->getMeters() / GeolocationInterface::EARTH_RADIUS;
     $minLat = $radLat - $radDist;
     $maxLat = $radLat + $radDist;
     $deltaLon = asin(sin($radDist) / cos($radLat));
     $minLon = $radLon - $deltaLon;
     //if (minLon < MIN_LON) {minLon += 2d * Math.PI;}
     $maxLon = $radLon + $deltaLon;
     //if (maxLon > MAX_LON) {maxLon -= 2d * Math.PI;}
     $min = new Geolocation(rad2deg($maxLat), rad2deg($minLon));
     $max = new Geolocation(rad2deg($minLat), rad2deg($maxLon));
     return new BoundingBox($min, $max);
 }
Exemplo n.º 2
0
 public function add(Distance $distance)
 {
     return new Distance($this->getMeters() + $distance->getMeters());
 }
Exemplo n.º 3
0
 /**
  * @covers \Base\Geospatial\Distance
  */
 public function testGetter()
 {
     $distance = new Distance(1);
     $this->assertEquals(1, $distance->getMeters());
 }