Location\Line::getLength PHP Method

getLength() public method

Calculates the length of the line (distance between the two coordinates).
public getLength ( Location\Distance\DistanceInterface $calculator ) : float
$calculator Location\Distance\DistanceInterface instance of distance calculation class
return float
    public function getLength(DistanceInterface $calculator)
    {
        return $calculator->getDistance($this->point1, $this->point2);
    }

Usage Example

示例#1
0
 public function testCalculateLength()
 {
     $point1 = new Coordinate(52.5, 13.5);
     $point2 = new Coordinate(64.09999999999999, -21.9);
     $line = new Line($point1, $point2);
     $this->assertEquals(2397867.8, $line->getLength(new Vincenty()), '', 0.01);
 }