League\Geotools\Distance\Distance::setFrom PHP Method

setFrom() public method

{@inheritDoc}
public setFrom ( League\Geotools\Coordinate\CoordinateInterface $from )
$from League\Geotools\Coordinate\CoordinateInterface
    public function setFrom(CoordinateInterface $from)
    {
        $this->from = $from;
        return $this;
    }

Usage Example

 /**
  * Calculates the distance between two Coordinate objects
  *
  * @param  Coordinate      $coordinate
  * @param  DistanceUnit    $unit
  * @param  DistanceFormula $formula
  * @return Real
  */
 public function distanceFrom(Coordinate $coordinate, DistanceUnit $unit = null, DistanceFormula $formula = null)
 {
     if (null === $unit) {
         $unit = DistanceUnit::METER();
     }
     if (null === $formula) {
         $formula = DistanceFormula::FLAT();
     }
     $baseThis = static::getBaseCoordinate($this);
     $baseCoordinate = static::getBaseCoordinate($coordinate);
     $distance = new Distance();
     $distance->setFrom($baseThis)->setTo($baseCoordinate)->in($unit->toNative());
     $value = \call_user_func(array($distance, $formula->toNative()));
     return new Real($value);
 }