src/Lootils/Geo/Location.php
public function distance(LocationInterface $location, $method = 'default') {

    if (!isset($this->distanceCache[$method])) {

      if (!isset($this->distanceMethods[$method])) {
        throw new Exception('Distance method not registered.');
      }
      elseif (!class_exists($this->distanceMethods[$method])) {
        throw new Exception('The class associated with the name does not exist.');
      }

      // @todo: Should this verify the proper interface is implemented? If not
      // it will simply explode.

      $this->distanceCache[$method] = new $this->distanceMethods[$method];
    }

    return $this->distanceCache[$method]->distance($this, $location);
  }
public function distance(LocationInterface $location, $method = 'default') {

    if (!isset($this->distanceCache[$method])) {

      if (!isset($this->distanceMethods[$method])) {
        throw new Exception('Distance method not registered.');
      }
      elseif (!class_exists($this->distanceMethods[$method])) {
        throw new Exception('The class associated with the name does not exist.');
      }

      // @todo: Should this verify the proper interface is implemented? If not
      // it will simply explode.

      $this->distanceCache[$method] = new $this->distanceMethods[$method];
    }

    return $this->distanceCache[$method]->distance($this, $location);
  }
Get the distance between this location and another one.

@param \Lootils\Geo\LocationInterface $location
The other location object to diff the distance of.
@param string $method
The registered method to use for this calculation. Because the Earth is
an irregular ellipse there are multiple math equations attempting to
best calculate the distance.

@return float
The estimated distance between the two locations in meters.