Location\Polyline::getLength PHP Method

getLength() public method

Calculates the length of the polyline.
public getLength ( Location\Distance\DistanceInterface $calculator ) : float
$calculator Location\Distance\DistanceInterface instance of distance calculation class
return float
    public function getLength(DistanceInterface $calculator)
    {
        $distance = 0.0;
        if (count($this->points) <= 1) {
            return $distance;
        }
        foreach ($this->getSegments() as $segment) {
            $distance += $segment->getLength($calculator);
        }
        return $distance;
    }

Usage Example

Beispiel #1
0
 public function testGetLength()
 {
     $this->assertEquals(10576798.9, $this->polyline->getLength(new Vincenty()), '', 0.1);
 }
All Usage Examples Of Location\Polyline::getLength